diff options
author | Carl Worth <[email protected]> | 2014-06-20 14:28:20 -0700 |
---|---|---|
committer | Carl Worth <[email protected]> | 2014-07-29 15:11:48 -0700 |
commit | 5dbdc341e8e8502ab5d98784a24b54c6f3907472 (patch) | |
tree | de3a0c6f1307fb234e030a2cd318949e082fafba /src/glsl/glcpp/glcpp-lex.l | |
parent | 21dda50549c5f220eff7ec04a72fb02e5eb09e76 (diff) |
glsl/glcpp: Add testing for EOF sans newline (and fix for <DEFINE>, <COMMENT>)
The glcpp implementation has long had code to support a file that ends without
a final newline. But we didn't have a "make check" test for this.
Additionally, the <EOF> action was restricted only to the <INITIAL> state so
it would fail to get invoked if the EOF was encountered in the <COMMENT> or
the <DEFINE> case. Neither of these was a bug, per se, since EOF in either
of these cases is an error anyway, (either "unterminated comment" or
"missing macro name for #define").
But with the new explicit support for these cases, we not generate clean error
messages in these cases, (rather than "unexpected $end" from before).
Reviewed-by: Jordan Justen <[email protected]>
Diffstat (limited to 'src/glsl/glcpp/glcpp-lex.l')
-rw-r--r-- | src/glsl/glcpp/glcpp-lex.l | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/glsl/glcpp/glcpp-lex.l b/src/glsl/glcpp/glcpp-lex.l index 5f0bb324990..44547fde0e9 100644 --- a/src/glsl/glcpp/glcpp-lex.l +++ b/src/glsl/glcpp/glcpp-lex.l @@ -398,8 +398,11 @@ HEXADECIMAL_INTEGER 0[xX][0-9a-fA-F]+[uU]? return NEWLINE; } - /* Handle missing newline at EOF. */ -<INITIAL><<EOF>> { +<INITIAL,COMMENT,DEFINE><<EOF>> { + if (YY_START == COMMENT) + glcpp_error(yylloc, yyextra, "Unterminated comment"); + if (YY_START == DEFINE) + glcpp_error(yylloc, yyextra, "#define without macro name"); BEGIN DONE; /* Don't keep matching this rule forever. */ yyextra->lexing_directive = 0; return NEWLINE; |