From c2b97854d3f61123adde77452cfdbdf10ebc3280 Mon Sep 17 00:00:00 2001 From: overflowerror Date: Thu, 20 May 2021 20:20:54 +0200 Subject: [PATCH] fixed non-reachable token in lexer --- src/parser.y | 3 ++- src/scanner.l | 9 ++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/parser.y b/src/parser.y index cd286b8..9fcbba4 100644 --- a/src/parser.y +++ b/src/parser.y @@ -51,11 +51,12 @@ template: metaSection SECTION mainSection $$ = $1; $$.tree = $3; } - | mainSection +/* | mainSection { $$ = newTemplate(); $$.tree = $1; } +*/ ; metaSection: /* empty */ diff --git a/src/scanner.l b/src/scanner.l index 221b1d8..ca61a5e 100644 --- a/src/scanner.l +++ b/src/scanner.l @@ -19,7 +19,7 @@ id [a-zA-Z_][a-zA-Z0-9_]* type_prefixes "enum"|"struct" type_prefix {type_prefixes}{whitespace}+ type_pointer {whitespace}*"*" -type {type_prefix}?{id}{type_pointer}? +type_or_id {type_prefix}?{id}{type_pointer}? %option noyywrap %option nounput @@ -52,11 +52,10 @@ type {type_prefix}?{id}{type_pointer}? {statement_begin} { BEGIN(STATEMENT); return STATEMENT_BEGIN; } {section} { isMetaSection = false; BEGIN(MAIN_SECTION); return SECTION; } {output_begin} { fprintf(stderr, "error: output block not allowed in meta section (line %d)\n", yylineno); exit(1); } -{whitespace}+ { /* ignore whitespaces */ } -. { fprintf(stderr, "error: raw text not allowed in meta section (line %d)\n", yylineno); exit(1); } +{whitespace}+ { /* ignore whitespaces */ } +. { fprintf(stderr, "error: raw text not allowed in meta section (line %d)\n", yylineno); exit(1); } -{type} { yylval.text = strdup(yytext); return TEXT; } -{id} { yylval.text = strdup(yytext); return TEXT; } +{type_or_id} { yylval.text = strdup(yytext); return TEXT; } {params_end} { BEGIN(META_SECTION); return PARAMS_END; } "," { return COMMA; } {whitespace}+ { /* ignore whitespaces */ }