diff --git a/parser/parser_lex.l b/parser/parser_lex.l index 22db7e742..fdf02bc02 100644 --- a/parser/parser_lex.l +++ b/parser/parser_lex.l @@ -24,6 +24,7 @@ %option noyywrap %option nounput %option stack +%option nodefault %{ #include @@ -240,7 +241,16 @@ ADD_ASSIGN \+= ARROW -> LT_EQUAL <= -/* IF adding new state please update state_names table at eof */ +/* IF adding new state please update state_names table and default rule (just + * above the state_names table) at the eof. + * + * The nodefault option is set so missing adding to the default rule isn't + * fatal but can't take advantage of additional debug the default rule might + * have. + * + * If a state is not added to the default rule it can result in the message + * "flex scanner jammed" + */ %x SUB_ID %x SUB_ID_WS %x SUB_VALUE @@ -274,7 +284,7 @@ LT_EQUAL <= } %} -{ +{ {WS}+ { DUMP_PREPROCESS; /* Ignoring whitespace */ } } @@ -469,6 +479,7 @@ LT_EQUAL <= \\\n { DUMP_PREPROCESS; current_lineno++ ; } \r?\n { + /* don't use shared rule because we need POP() here */ DUMP_PREPROCESS; current_lineno++; POP(); @@ -695,18 +706,20 @@ include/{WS} { POP_NODUMP(); RETURN_TOKEN(TOK_END_OF_RULE); } +} - \r?\n { +{ + \r?\n { DUMP_PREPROCESS; current_lineno++; } } -{ - [^\n] { +{ + (.|\n) { DUMP_PREPROCESS; /* Something we didn't expect */ - yyerror(_("Found unexpected character: '%s'"), yytext); + yyerror(_("Lexer found unexpected character: '%s' (0x%x) in state: %s"), yytext, yytext[0], state_names[YY_START].c_str()); } } %% diff --git a/parser/tst/simple_tests/abi/bad_1.sd b/parser/tst/simple_tests/abi/bad_1.sd index 1070ed76d..274309841 100644 --- a/parser/tst/simple_tests/abi/bad_1.sd +++ b/parser/tst/simple_tests/abi/bad_1.sd @@ -1,7 +1,6 @@ # #=DESCRIPTION abi testing - abi relative path in quotes #=EXRESULT FAIL -#=TODO abi "abi/4.19,