![]() The specification of the preprocessor in C99 says that when we see a macro name that we are already expanding that we refuse to expand it now, (which we've done for a while), but also that we refuse to ever expand it later if seen in other contexts at which it would be legitimate to expand. We add a test case for that here, and fix it to work. The fix takes advantage of a new token_t value for tokens and argument words along with the recently added IDENTIFIER_FINALIZED token type which instructs the parser to not even look for another expansion. |
pirms 15 gadiem | |
---|---|---|
main | Add hash table implementation from glsl2 project. | pirms 15 gadiem |
tests | Avoid re-expanding a macro name that has once been rejected from expansion. | pirms 15 gadiem |
.gitignore | Add a very simple test for the pre-processor. | pirms 15 gadiem |
Makefile | Add a wrapper function around the lexer. | pirms 15 gadiem |
README | Add README file describing glcpp. | pirms 15 gadiem |
glcpp-lex.l | Avoid re-expanding a macro name that has once been rejected from expansion. | pirms 15 gadiem |
glcpp-parse.y | Avoid re-expanding a macro name that has once been rejected from expansion. | pirms 15 gadiem |
glcpp.c | Fix defines involving both literals and other defined macros. | pirms 15 gadiem |
glcpp.h | Avoid re-expanding a macro name that has once been rejected from expansion. | pirms 15 gadiem |
hash_table.c | Add hash table implementation from glsl2 project. | pirms 15 gadiem |
hash_table.h | Add hash table implementation from glsl2 project. | pirms 15 gadiem |
xtalloc.c | Rewrite macro handling to support function-like macro invocation in macro values | pirms 15 gadiem |
glcpp -- GLSL "C" preprocessor
This is a simple preprocessor designed to provide the preprocessing
needs of the GLSL language. The requirements for this preprocessor are
specified in the GLSL 1.30 specification availble from:
http://www.opengl.org/registry/doc/GLSLangSpec.Full.1.30.08.pdf
This specification is not precise on some semantics, (for example,
#define and #if), defining these merely "as is standard for C++
preprocessors". To fill in these details, I've been using the C99
standard (for which I had a convenient copy) as available from:
http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1124.pdf