[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
General outline of what I'm trying to do
From: |
jfw |
Subject: |
General outline of what I'm trying to do |
Date: |
Fri, 13 Jan 2012 17:49:31 -0800 (PST) |
Am I correct in assuming that the following is doable using M4.
If so are there M4 implementations of macros available on the web to do this
sort of thing
that I can model my m4_lib.m4 code on?
Here's what I'm trying to do:
use a library of M4 macros: m4_lib.m4
use text files {g,h,s}.txt containing general definition of items
use specific M4 files: {e,g,h,s}_{enum,name,hash}.m4 to generate files from
the txt files.
generate .h files: {e,g,h,s}_enum.h, {g,h)_name.h, and s_hash.h.
The s_* files require more variant output based on additional flags __HASH
and s__xxx
There would also be s_hash.m4 and s_hash.h files to generate inserts into
unordered_map elements.
example g.txt file:
__in(EMPTY, 0,__ENUM|__NAME,//!< empty flag)
__in( CHAP,0x00000001,__ENUM|__NAME,//!< chapter)
__begbit( 0x00000001)
__in(ANNEX,__nextbit,__ENUM|__NAME,//!< annex)
__in( ART,__nextbit,__ENUM|__NAME,//!< article)
...additional __in()s
__in(CONST,__nextbit,__ENUM|__NAME,//!< constant
which g_enum.m4 would generate:
enum g_flag_t {
\tg_EMPTY\t=\t0,\t//!< empty flag
\tg_CHAP\t=\t0x00000001,\t//!< chapter
\tg_ANNEX\t=\t0x00000002,\t//!< annex
\tg_ART\t=\t0x00000004,\t//!< article
...
\tg_CONST\t=0x80000000,\t//!< constant
and g_name.m4 would generate:
const string g_name[33] = {
\t"EMPTY",
\t"CHAP",
\t"ANNEX",
\t"ART",
...
\t"CONST"
};
example h.txt file:
__in(EMPTY, 0,__ENUM|__NAME,//!< empty flag)
__in( XP,0x00000001,__ENUM|__NAME,//!< </p> needed
__begbit( 0x00000001)
__in( XDHV,__nextbit ,__ENUM|__NAME,//!< </div><!-- hv -->
needed
__in( XDIV,__nextbit ,__ENUM|__NAME,//!< </div> needed
__in(XBODY,__nextbit ,__ENUM|__NAME,//!< </body> needed
__in(XHTML,__nextbit ,__ENUM|__NAME,//!< </html> needed
__genbit(BIT,,31 ,__NAME,)
and h_enum,m4 would generate:
enum h_flag_t {
\th_EMPTY\t=\t0,\t//!< empty flag
\th_XP,\t=\t0x00000001,\t//!< </p> needed
...
\thXHTML\t=\t0x00000010,\t//!< </html> needed
};
and h_name.m4 would generate:
const string h_name[33] = {
\t"EMPTY",
...
\t"XHTML",
\t"BIT06",
\t"BIT07",
...
\t"BIT31",
};
macros:
__in(name,value,flags,comment) definition selected from m4_lib.m4 by flag
settings
__begbit(initial bit value for __nextbit)
__nextbit(return 32bit hex representation of value; increase value*2)
__genbit(named base, begin value (default to last __nextbit),end value)
Thanks for any assistance,
/s/ Jim WIlliams
--
View this message in context:
http://old.nabble.com/General-outline-of-what-I%27m-trying-to-do-tp33137922p33137922.html
Sent from the Gnu - M4 - Discuss mailing list archive at Nabble.com.
- General outline of what I'm trying to do,
jfw <=