From a62354a9877e327c44ce4f0898359b4a3db41727 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Tue, 1 Jul 2014 15:10:02 -0700 Subject: glsl: Add flex options to eliminate the default rule MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We've had bugs in the past where we have been inadvertently matching the default rule. Just as we did in the pre-processor in the previous commit, we can use: %option warn nodefault in the compiler to instruct flex to not generate the default rule, and further to warn if our set of rules could let any characters go unmatched. With this warning active, flex actually warns that the catch-all rule we recently added to the compiler could never be matched. Since that is all safely determined at compile time now, we can safely drop this run-time compiler error message, (as we do in this commit). Reviewed-by: Kenneth Graunke Reviewed-by: Kristian Høgsberg --- src/glsl/glsl_lexer.ll | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) (limited to 'src') diff --git a/src/glsl/glsl_lexer.ll b/src/glsl/glsl_lexer.ll index 1a0dde2e9b8..b7c4aad3a9e 100644 --- a/src/glsl/glsl_lexer.ll +++ b/src/glsl/glsl_lexer.ll @@ -152,6 +152,7 @@ literal_integer(char *text, int len, struct _mesa_glsl_parse_state *state, %option never-interactive %option prefix="_mesa_glsl_lexer_" %option extra-type="struct _mesa_glsl_parse_state *" +%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 @@ -559,16 +560,6 @@ subroutine KEYWORD(0, 300, 0, 0, SUBROUTINE); . { return yytext[0]; } - /* This is a catch-all to avoid the annoying default flex action which - * matches any character and prints it. If any input ever matches this - * rule, then we have made a mistake above and need to fix one or more - * of the preceding patterns to match that input. */ -. { - _mesa_glsl_error(yylloc, yyextra, - "Internal compiler error: Unexpected character: %s", yytext); -} - - %% int -- cgit v1.2.3