2010-05-11 12:04:42 -07:00
|
|
|
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
|
2010-05-26 08:11:08 -07:00
|
|
|
|
|
|
|
Known limitations
|
|
|
|
-----------------
|
|
|
|
Macro invocations cannot include embedded newlines.
|
|
|
|
|
|
|
|
The __LINE__, __FILE__, and __VERSION__ macros are not yet supported.
|
|
|
|
|
|
|
|
The argument of the 'defined' operator cannot yet include enclosing
|
|
|
|
parentheses.
|
|
|
|
|
|
|
|
The #error, #pragma, #extension, #version, and #line macros are not
|
|
|
|
yet supported.
|
Treat newlines as space when invoking a function-like macro invocation.
This adds three new pieces of state to the parser, (is_control_line,
newline_as_space, and paren_count), and a large amount of messy
code. I'd definitely like to see a cleaner solution for this.
With this fix, the "define-func-extra-newlines" now passes so we put
it back to test #26 where it was originally (lately it has been known
as test #55).
Also, we tweak test 25 slightly. Previously this test was ending a
file function-like macro name that was not actually a macro (not
followed by a left parenthesis). As is, this fix was making that test
fail because the text_line production expects to see a terminating
NEWLINE, but that NEWLINE is now getting turned into a SPACE here.
This seems unlikely to be a problem in the wild, (function macros
being used in a non-macro sense seems rare enough---but more than
likely they won't happen at the end of a file). Still, we document
this shortcoming in the README.
2010-05-26 15:57:10 -07:00
|
|
|
|
|
|
|
A file that ends with a function-like macro name as the last
|
|
|
|
non-whitespace token will result in a parse error, (where it should be
|
|
|
|
passed through as is).
|