- no longer generate CONSTANT lines for #defined constants
- "#define FOO 1" turns "return FOO;" into "return 1;"
- Macros expanding into a macro is not supported:
#define FOO 1
#define BAR FOO
will expand BAR to FOO, not to 1
- Expansion inside #if conditions is not supported.
- Function-like macros are not supported.
- // and # lines always appear in the result of read_all_tokens
- in bootstrap mode, // tokens (but not the subsequent lines) and #
lines are stripped. no preprocessing happens.
- in non-bootstrap mode, // lines are stripped and # lines stay for the
preprocessing phase
- updates tests to pass --bootstrap-mode when necessary
- support for #if, #elif, #else, #endif, but no macro expansion just
yet. Any macro is treated as undefined and expands to 0.
for example:
./bin/M2-Planet -E test.c
#if 1 == FOO
foo
#else
bar
#endif
results in
bar
- change the lexer to not remove preprocessor directives
- preprocess() removes any lines starting with a macro directive that it
doesn't understand (which is currently all of them)
- needed to determine start and end of macro directives
- the main parser doesn't need them, so strip out the newline tokens
before parsing to avoid changing it