diff options
author | Carl Worth <cworth@cworth.org> | 2014-07-01 15:04:38 -0700 |
---|---|---|
committer | Carl Worth <cworth@cworth.org> | 2014-07-29 15:11:51 -0700 |
commit | bc8721f16f2f4a08e6ad935723cc52de1748b63f (patch) | |
tree | b3d910733941590a1ecdc8aeedc1ff5fcff0a751 /src/glsl/glcpp | |
parent | 4ebff9bca638d96b562640c093b2dcc5d02fb443 (diff) | |
download | external_mesa3d-bc8721f16f2f4a08e6ad935723cc52de1748b63f.zip external_mesa3d-bc8721f16f2f4a08e6ad935723cc52de1748b63f.tar.gz external_mesa3d-bc8721f16f2f4a08e6ad935723cc52de1748b63f.tar.bz2 |
glsl/glcpp: Add flex options to eliminate the default rule.
We've had multiple bugs in the past where we have been inadvertently matching
the default rule, (which we never want to do). We recently added a catch-all
rule to avoid this, (and made this rule robust for future start conditions).
Kristian pointed out that flex allows us to go one step better. This syntax:
%option warn nodefault
instructs flex to not generate the default rule at all. Further, flex will
generate a warning at compile time if the set of rules we provide are
inadequate, (such that it would be possible for the default rule to be
matched).
With this warning in place, I found that the catch-all rule was in fact
missing something. The catch-all rule uses a pattern of "." which doesn't
match newlines. So here we extend the newline-matching rule to all start
conditions. That is enough to convince flex that it really doesn't need
any default rule.
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Kristian Høgsberg <krh@bitplanet.net>
Diffstat (limited to 'src/glsl/glcpp')
-rw-r--r-- | src/glsl/glcpp/glcpp-lex.l | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/glsl/glcpp/glcpp-lex.l b/src/glsl/glcpp/glcpp-lex.l index 79a7ad7..4b9ab23 100644 --- a/src/glsl/glcpp/glcpp-lex.l +++ b/src/glsl/glcpp/glcpp-lex.l @@ -160,6 +160,7 @@ glcpp_lex_update_state_per_token (glcpp_parser_t *parser, int token) %option prefix="glcpp_" %option stack %option never-interactive +%option warn nodefault /* Note: When adding any start conditions to this list, you must also * update the "Internal compiler error" catch-all rule near the end of @@ -516,7 +517,7 @@ HEXADECIMAL_INTEGER 0[xX][0-9a-fA-F]+[uU]? /* We preserve all newlines, even between #if 0..#endif, so no skipping.. */ -[\r\n] { +<*>[\r\n] { if (parser->commented_newlines) { BEGIN NEWLINE_CATCHUP; } |