mesa/src/glsl/glcpp
Carl Worth fbe4240626 glcpp: Fix function-like macros with an argument used multiple times.
It's really hard to believe that this case has been broken, but apparently
no test previously exercised it. So this commit adds such a test and fixes
it by making a copy of the argument token-list before expanding it.

This fix causes the following glean tests to now pass:

	glsl1-Preprocessor test 6 (#if 0, #define macro)
	glsl1-Preprocessor test 7 (multi-line #define)
2010-07-22 16:38:12 -07:00
..
tests glcpp: Fix function-like macros with an argument used multiple times. 2010-07-22 16:38:12 -07:00
.gitignore glsl2: Move the compiler to the subdirectory it will live in in Mesa. 2010-06-24 15:36:00 -07:00
glcpp-lex.l glcpp: Avoid warnings in generated flex code. 2010-07-20 17:01:11 -07:00
glcpp-parse.y glcpp: Fix function-like macros with an argument used multiple times. 2010-07-22 16:38:12 -07:00
glcpp.c glsl2: Conditionally define preprocessor tokens for optional extensions 2010-07-01 20:40:08 -07:00
glcpp.h glsl: Fix missing initialization of yylloc.source 2010-07-21 13:52:33 -07:00
Makefile.am glcpp: Delete copies of hash_table.c, hash_table.h, and other headers. 2010-07-20 17:01:11 -07:00
pp.c glsl2: Conditionally define preprocessor tokens for optional extensions 2010-07-01 20:40:08 -07:00
README glsl2: Move the compiler to the subdirectory it will live in in Mesa. 2010-06-24 15:36:00 -07:00
xtalloc.c glcpp: Add missing include in xtalloc.c 2010-07-20 17:01:12 -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

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.

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).