G
Guest
I'm starting to design a meta pre-processor for the C language. It could
also be used for other languages, by C is my focus. The purpose of this
pre-processor is to select sections of code from files to be included in
other files. The goal is the ability to code related items such as structs,
and functions or macros that use those structs, in a single file, while the
actual code needs to be split up into separate .c and .h files, and combined
the parts from other code, for compiling. This is to allow my code to be
organized more like modules. That way a module can be added in without the
need to change existing code. The meta pre-processor would extract code from
these modules and construct the code to be compiled as well as the header to
be exported.
What I am looking for suggestions on is how to define a control statement
for the meta pre-processor to look for. This control statement will be
removed from the code, so it does not have to be something that would be
ignored or bypassed in the C pre-processor and C compiler. But it does
need to be something that no one would ever need to code in C that the meta
pre-processor would mistakenly think is its control statement when it is
not. The control decisions will be on a line-by-line basis and will not be
embedded in code within a line, much like the C pre-processor.
My first inclination is to use ## as a prefix, possibly with the added
requirement that it must be in positions 0 and 1 (0 based) on the line,
and/or must be followed with a unique keyword. There would be additional
control words and arguments to these meta pre-processor statements.
Any suggestions?
also be used for other languages, by C is my focus. The purpose of this
pre-processor is to select sections of code from files to be included in
other files. The goal is the ability to code related items such as structs,
and functions or macros that use those structs, in a single file, while the
actual code needs to be split up into separate .c and .h files, and combined
the parts from other code, for compiling. This is to allow my code to be
organized more like modules. That way a module can be added in without the
need to change existing code. The meta pre-processor would extract code from
these modules and construct the code to be compiled as well as the header to
be exported.
What I am looking for suggestions on is how to define a control statement
for the meta pre-processor to look for. This control statement will be
removed from the code, so it does not have to be something that would be
ignored or bypassed in the C pre-processor and C compiler. But it does
need to be something that no one would ever need to code in C that the meta
pre-processor would mistakenly think is its control statement when it is
not. The control decisions will be on a line-by-line basis and will not be
embedded in code within a line, much like the C pre-processor.
My first inclination is to use ## as a prefix, possibly with the added
requirement that it must be in positions 0 and 1 (0 based) on the line,
and/or must be followed with a unique keyword. There would be additional
control words and arguments to these meta pre-processor statements.
Any suggestions?