Age | Commit message (Collapse) | Author | Files | Lines |
|
Rather than using the (munged) output of "gcc -E" we now capture
precisely the output we expect from every test case. This allows us to
stay immune from strange output from gcc (unpredictable whitespace
output---aprticularly with different gcc versions).
This will also allow us to write tests that capture expected error
messages from the preprocessor as well.
|
|
To do this correctly, we change the lexer to lex integers as string values,
(new token type of INTEGER_STRING), and only convert to integer values when
evaluating an expression value.
Add a new test case for this, (which does pass now).
|
|
We rename the generated lexer from yylex to glcpp_lex. Then we
implement our own yylex function in glcpp-parse.y that calls
glcpp_lex. This doesn't change the behavior at all yet, but gives us a
place where we can do implement alternate lexing in the future.
(We want this because instead of re-lexing from strings for macro
expansion, we want to lex from pre-parsed token lists. We need this so
that when we terminate recursion due to an already active macro
expansion, we can ensure that that symbol never gets expanded again
later.)
|
|
We were correctly parsing this already, but simply not returning any
value (for no good reason). Fortunately the fix is quite simple.
This makes the test added in the previous commit now pass.
|
|
Otherwise, running "make test" can run an old version of the code,
(even when new changes are sitting in the source waiting to be
compiled).
|
|
We accept the structure of arguments in both macro definition and
macro invocation, but we don't yet expand those arguments. This is
just enough code to pass the recently-added tests, but does not yet
provide any sort of useful function-like macro.
|
|
The lexer was previously using strdup (expecting the parser to free),
but is now more consistent, easier to use, and slightly more efficent
by using talloc along with the parser.
Also, we add xtalloc and xtalloc_strdup wrappers around talloc and
talloc_strdup to put all of the out-of-memory-checking code in one
place.
|
|
We now store a list of tokens in our hash-table rather than a single
string. This lets us replace each macro in the value as necessary.
This code adds a link dependency on talloc which does exactly what we
want in terms of memory management for a parser.
The 3 tests added in the previous commit now pass.
|
|
Validate desired test cases by ensuring the output of glcpp matches
the output of the gcc preprocessor, (ignoring any lines of the gcc
output beginning with '#').
Only one test case so far with a trivial #define.
|
|
This compiles the debugging code for teh parser. It's not active
unless the yydebug variable is set to a non-zero value.
|
|
The preprocessor here is intended to become part of the glsl2 codebase
eventually anyway.
|
|
Most of the current problems were (mostly) harmless things like
missing declarations, but there was at least one real error, (reversed
argument order for yyerrror).
|
|
It doesn't really *do* anything yet---merlely parsing a stream of
whitespace-separated tokens, (and not interpreting them at all).
|