summaryrefslogtreecommitdiffstats
path: root/src/glsl/glcpp/glcpp-lex.l
Commit message (Collapse)AuthorAgeFilesLines
* glcpp: Fix so that trailing punctuation does not prevent macro expansionCarl Worth2012-02-021-1/+9
| | | | | | | | | | | | | | | | | | | | 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 <[email protected]> NOTE: This is a candidate for stable release branches.
* glsl: Define YY_NO_UNISTD_H on MSVC.José Fonseca2011-03-041-0/+4
|
* glcpp: Remove trailing contexts from #if rules.Kenneth Graunke2011-03-031-6/+6
| | | | These are now unnecessary.
* glcpp: Rework lexer to use a SKIP state rather than REJECT.Kenneth Graunke2011-03-031-21/+16
| | | | | | | | | | | | | | | | | | | 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.
* Convert everything from the talloc API to the ralloc API.Kenneth Graunke2011-01-311-7/+7
|
* glcpp: Return NEWLINE token for newlines inside multi-line comments.Kenneth Graunke2010-10-211-2/+2
| | | | This is necessary for the main compiler to get correct line numbers.
* glcpp: Fix handling of "#line 0"Carl Worth2010-08-231-2/+3
| | | | | | | | | | | | | | | | 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.)
* glcpp: Fix source numbers set with "#line LINE_NUMBER SOURCE_NUMBER"Carl Worth2010-08-231-2/+7
| | | | | | | 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.
* glcpp: Add basic #line support (adapted from the main compiler).Kenneth Graunke2010-08-181-0/+31
|
* glcpp: Don't include the newline when discarding single-line commentsCarl Worth2010-08-171-4/+1
| | | | | | | | | | | | | | | | | | | | | | | | | 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).
* glcpp: Remove spurious newline generated by #version handling.Kenneth Graunke2010-08-161-3/+1
| | | | | | 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.
* glsl2: Use --nounistd to fix MSVC buildIan Romanick2010-08-131-0/+1
| | | | | Also remove the --never-interactive command line option for the preprocessor lexer. This was already done for main compiler lexer.
* glcpp: Initialize line and column numbers to 1, not 0.Carl Worth2010-08-111-1/+1
| | | | | 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.
* glcpp: Remove xtalloc wrappers in favor of plain talloc.Kenneth Graunke2010-08-041-7/+7
| | | | | | 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.
* glcpp: Add __VERSION__ define to the current language version.Eric Anholt2010-07-281-1/+9
| | | | | | | Fixes: glsl-version-define glsl-version-define-110 glsl-version-define-120
* glcpp: Avoid warnings in generated flex code.Carl Worth2010-07-201-1/+12
| | | | | | | | | | | 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.
* glcpp-lex: Declare some generated functions to eliminate compiler warnings.Carl Worth2010-07-201-0/+5
| | | | | | 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.
* glcpp: Fix support for nested #ifdef and nested #ifndefCarl Worth2010-07-201-2/+4
| | | | | | | | | | | 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.
* glcpp: Support #if(expression) with no intervening space.Carl Worth2010-07-201-1/+1
| | | | And add a test case to ensure that this works.
* glsl2: Initialize yylineno and yycolumn so line numbers are sane.Kenneth Graunke2010-07-071-0/+1
|
* glcpp: Add #error support.Kenneth Graunke2010-07-021-0/+8
|
* glsl2: Move the compiler to the subdirectory it will live in in Mesa.Eric Anholt2010-06-241-0/+257