History log of /external/mesa3d/src/glsl/glcpp/glcpp-lex.l
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
a908f4a75401284dd45bf559de18c83adaacb335 22-Oct-2012 Kenneth Graunke <kenneth@whitecape.org> glcpp: Don't use infinite lookhead for #define differentiation.

Previously, we used lookahead patterns to differentiate:

#define FOO(x) function macro
#define FOO (x) object macro

Unfortunately, our rule for function macros:

{HASH}define{HSPACE}+/{IDENTIFIER}"("

relies on infinite lookahead, and apparently triggers a Flex bug where
the generated code overflows a state buffer (see YY_STATE_BUF_SIZE).

There's no need to use infinite lookahead. We can simply change state,
match the identifier, and use a single character lookahead for the '('.
This apparently makes Flex not generate the giant state array, which
avoids the buffer overflow, and should be more efficient anyway.

Fixes piglit test 17000-consecutive-chars-identifier.frag.

NOTE: This is a candidate for every release branch ever.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Carl Worth <cworth@cworth.org>
(cherry picked from commit 9142ade15416415f2d5eb20b093b898c649cd2bb)
/external/mesa3d/src/glsl/glcpp/glcpp-lex.l
aac78ce8234d96932c38b3f48b1d828077bc0027 10-Jun-2012 Carl Worth <cworth@cworth.org> glsl: glcpp: Move handling of #line directives from lexer to parser.

The GLSL specification requires that #line directives be interpreted
after macro expansion. Our existing implementation of #line macros in
the lexer prevents conformance on this point.

Moving the handling of #line from the lexer to the parser gives us the
macro expansion we need. An additional benefit is that the
preprocessor also now supports comments on the same line as #line
directives.

Finally, the preprocessor now emits the (fully-macro-expanded) #line
directives into the output. This allows the full GLSL compiler to also
see and interpret these directives so it can also generate correct
line numbers in error messages.

Signed-off-by: Carl Worth <cworth@cworth.org>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
/external/mesa3d/src/glsl/glcpp/glcpp-lex.l
7ab1c7f7926c75a07f33eb149d0fc17dcfaffd5e 21-Jan-2012 Carl Worth <cworth@cworth.org> glcpp: Fix so that trailing punctuation does not prevent macro expansion

The trick here is that flex always chooses the rule that matches the most
text. So with a input text of "two:" which we want to be lexed as an
IDENTIFIER token "two" followed by an OTHER token ":" the previous OTHER
rule would match longer as a single token of "two:" which we don't want.

We prevent this by forcing the OTHER pattern to never match any
characters that appear in other constructs, (no letters, numbers, #,
_, whitespace, nor any punctuation that appear in CPP operators).

Fixes bug #44764:

GLSL preprocessor doesn't replace defines ending with ":"
https://bugs.freedesktop.org/show_bug.cgi?id=44764

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>

NOTE: This is a candidate for stable release branches.
/external/mesa3d/src/glsl/glcpp/glcpp-lex.l
f52660c3dc85632b4dce76d16bf6d78266c35173 04-Mar-2011 José Fonseca <jfonseca@vmware.com> glsl: Define YY_NO_UNISTD_H on MSVC.
/external/mesa3d/src/glsl/glcpp/glcpp-lex.l
09e1bebc25140eecafa0c3eacefcf63010ce4f10 03-Mar-2011 Kenneth Graunke <kenneth@whitecape.org> glcpp: Remove trailing contexts from #if rules.

These are now unnecessary.
/external/mesa3d/src/glsl/glcpp/glcpp-lex.l
f20656e9446b9acde55b9dd41a2b47d7d5b7a56a 01-Mar-2011 Kenneth Graunke <kenneth@whitecape.org> glcpp: Rework lexer to use a SKIP state rather than REJECT.

Previously, the rule deleted by this commit was matched every single
time (being the longest match). If not skipping, it used REJECT to
continue on to the actual correct rule.

The flex manual advises against using REJECT where possible, as it is
one of the most expensive lexer features. So using it on every match
seems undesirable. Perhaps more importantly, it made it necessary for
the #if directive rules to contain a look-ahead pattern to make them
as long as the (now deleted) "skip the whole line" rule.

This patch introduces an exclusive start state, SKIP, to avoid REJECTs.
Each time the lexer is called, the code at the top of the rules section
will run, implicitly switching the state to the correct one.

Fixes piglit tests 16384-consecutive-chars.frag and
16385-consecutive-chars.frag.
/external/mesa3d/src/glsl/glcpp/glcpp-lex.l
d3073f58c17d8675a2ecdd5dfa83e5520c78e1a8 21-Jan-2011 Kenneth Graunke <kenneth@whitecape.org> Convert everything from the talloc API to the ralloc API.
/external/mesa3d/src/glsl/glcpp/glcpp-lex.l
bd55ba568b301d0f764cd1ca015e84e1ae932c8b 21-Oct-2010 Kenneth Graunke <kenneth@whitecape.org> glcpp: Return NEWLINE token for newlines inside multi-line comments.

This is necessary for the main compiler to get correct line numbers.
/external/mesa3d/src/glsl/glcpp/glcpp-lex.l
c2280e63817238bb969b20605c7d8dab4ddf1721 23-Aug-2010 Carl Worth <cworth@cworth.org> glcpp: Fix handling of "#line 0"

The existing DECIMAL_INTEGER pattern is the correct thing to use when
looking for a C decimal integer, (that is, a digit-sequence not
starting with 0 which would instead be an octal integer).

But for #line, we really want to accept any digit sequence, (including
"0"), and always interpret it as a decimal constant. So we add a new
DIGITS pattern for this case.

This should fix the compilation failure noted in bug #28138

https://bugs.freedesktop.org/show_bug.cgi?id=28138

(Though the generated file will not be updated until the next commit.)
/external/mesa3d/src/glsl/glcpp/glcpp-lex.l
ff10d239af3b48f4ba13a0ef947e97d3302ea818 23-Aug-2010 Carl Worth <cworth@cworth.org> glcpp: Fix source numbers set with "#line LINE_NUMBER SOURCE_NUMBER"

Previously, the YY_USER_ACTION was overwriting the yylloc->source value
in every action, (after that value had been carefully set by the handling
of the #line directive). Instead, we want to initialize it once in
YY_USER_INIT and then not touch it at all in YY_USER_ACTION.
/external/mesa3d/src/glsl/glcpp/glcpp-lex.l
9cf62bdfeb3982405b9360500d7e0fa52036f38f 19-Aug-2010 Kenneth Graunke <kenneth@whitecape.org> glcpp: Add basic #line support (adapted from the main compiler).
/external/mesa3d/src/glsl/glcpp/glcpp-lex.l
eb26f0d5b68f0218d4c79c1825d0d9e6a905e199 18-Aug-2010 Carl Worth <cworth@cworth.org> glcpp: Don't include the newline when discarding single-line comments

Matching the newline here meant having to do some redundant work here,
(incrementing line number, resetting column number, and returning a
NEWLINE token), that could otherwise simply be left to the existing rule
which matches a newline.

Worse, when the comment rule matches the newline as well, the parser
can lookahead and see a token for something that should actually be skipped.

For example, in a case like this:

#if 0 // comment here
fail
#else
win
#endif

Both fail and win appear in the output, (not that the condition is being
evaluated incorrectly---merely that one token after the comment's newline
was being lexed/parse regardless of the condition).

This commit fixes the above test case, (which is also remarkably similar
to 087-if-comments which now passes).
/external/mesa3d/src/glsl/glcpp/glcpp-lex.l
6be3a8b70af4ba4fa4d037d54ecf6d5f055edbc9 16-Aug-2010 Kenneth Graunke <kenneth@whitecape.org> glcpp: Remove spurious newline generated by #version handling.

This was causing line numbering to be off by one. The newline comes
from the NEWLINE token at the end of the line; there's no need to
insert one.
/external/mesa3d/src/glsl/glcpp/glcpp-lex.l
ab18be74ac5f95ba1ebe6a52259d77e0940b2dbd 13-Aug-2010 Ian Romanick <ian.d.romanick@intel.com> glsl2: Use --nounistd to fix MSVC build

Also remove the --never-interactive command line option for the
preprocessor lexer. This was already done for main compiler lexer.
/external/mesa3d/src/glsl/glcpp/glcpp-lex.l
bc64b8980803a5ba1cc91c63dc2ed1517db800c6 11-Aug-2010 Carl Worth <cworth@cworth.org> glcpp: Initialize line and column numbers to 1, not 0.

Error messages make more sense this way since the convention is for
the first line of a file to be numbered from 1, rather than 0.
/external/mesa3d/src/glsl/glcpp/glcpp-lex.l
1ffc1cd86186ae5d03bb28a1e041c4a57761515e 04-Aug-2010 Kenneth Graunke <kenneth@whitecape.org> glcpp: Remove xtalloc wrappers in favor of plain talloc.

Calling exit() on a memory failure probably made sense for the
standalone preprocessor, but doesn't seem too appealing as part of
the GL library. Also, we don't use it in the main compiler.
/external/mesa3d/src/glsl/glcpp/glcpp-lex.l
d4a04f315560704bf1103df0b93723e468725df7 29-Jul-2010 Eric Anholt <eric@anholt.net> glcpp: Add __VERSION__ define to the current language version.

Fixes:
glsl-version-define
glsl-version-define-110
glsl-version-define-120
/external/mesa3d/src/glsl/glcpp/glcpp-lex.l
fb90560744864e44730330e4c801ac47c4ece0e1 21-Jul-2010 Carl Worth <cworth@cworth.org> glcpp: Avoid warnings in generated flex code.

We define the YY_NO_INPUT macro to avoid one needless function being
generated.

for the other needless functions, (yyunput and yy_top_state), we add a
new UNREACHABLE start condition and call these functions from an
action there. This doesn't change functionality at all, (since we
never enter the UNREACHABLE start condition), but makes the compiler
stop complaining about these two functions being defined but not used.
/external/mesa3d/src/glsl/glcpp/glcpp-lex.l
a9bb4bcde360ef8d0a444bf1c4a7d02a8fdb5fa1 21-Jul-2010 Carl Worth <cworth@cworth.org> glcpp-lex: Declare some generated functions to eliminate compiler warnings.

It's really a bug in flex that these functions are generated with neither
a declaration nor the 'static' keyword, but we can at least avoid the
warnings this way.
/external/mesa3d/src/glsl/glcpp/glcpp-lex.l
1d7e03e48e87328ce0081021dde133921b78b406 20-Jul-2010 Carl Worth <cworth@cworth.org> glcpp: Fix support for nested #ifdef and nested #ifndef

Previously, if the outer #ifdef/#ifndef evaluated to false, the inner
directive would not be parsed correctly, (the identifier as the subject
of the #ifdef/#ifndef would inadvertently be skipped along with the other
content correctly being skipped).

We fix this by setting the lexing_if state in each case here.

We also add a new test to the test suite to ensure that this case is tested.
/external/mesa3d/src/glsl/glcpp/glcpp-lex.l
17f9beb6c313b41ca08984add7b76ecb84a7339e 20-Jul-2010 Carl Worth <cworth@cworth.org> glcpp: Support #if(expression) with no intervening space.

And add a test case to ensure that this works.
/external/mesa3d/src/glsl/glcpp/glcpp-lex.l
388ab9fa6b468d8c162dd4fc645d2f758c49051c 07-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> glsl2: Initialize yylineno and yycolumn so line numbers are sane.
/external/mesa3d/src/glsl/glcpp/glcpp-lex.l
7e908a6a27f196027a4dfd0f4d8c37aa71e163fa 03-Jul-2010 Kenneth Graunke <kenneth@whitecape.org> glcpp: Add #error support.
/external/mesa3d/src/glsl/glcpp/glcpp-lex.l
29285882676388aacff123e8bdf025904abf8ea9 25-Jun-2010 Eric Anholt <eric@anholt.net> glsl2: Move the compiler to the subdirectory it will live in in Mesa.
/external/mesa3d/src/glsl/glcpp/glcpp-lex.l