commit eb90e50e34471fcbe785588d8113c4d581754f99 from: Omar Polo date: Thu Oct 01 09:53:11 2020 UTC trying to improve error message on some cases, user will get better errors, instead of "foo.conf:5 syntax error". This is the yacc complement for what's been done previously in the parser also. commit - 7d3286caede96d7b813eff7dc3691d683d0f9bf9 commit + eb90e50e34471fcbe785588d8113c4d581754f99 blob - 68bb6d1db282d70709de7d07b094a10d72e3aa5a blob + c7d08960aee4514944304cffe58565ede13f46c0 --- parse.y +++ parse.y @@ -31,7 +31,10 @@ #define EXEC(S) ((struct action){.type = (AEXEC), .str = (S) }) %} - + +/* for bison: */ +/* %define parse.error verbose */ + %union { struct key key; char *str; @@ -58,7 +61,6 @@ groups : /* empty */ { $$ = NULL; } | groups group { $2->next = $1; config = $$ = $2; } - | error '\n' ; group : matches keys { $$ = new_group($1, $2); } @@ -71,11 +73,13 @@ matches : /* empty */ { $$ = NULL; } match : TMATCH TALL { $$ = new_match(MANY, NULL); } | TMATCH TCLASS TSTRING { $$ = new_match(MCLASS, $3); } + | error '\n' { yyerror("invalid match directive"); } ; keys : /* empty */ { $$ = NULL; } | keys '\n' { $$ = $1; } | keys key '\n' { $2->next = $1; $$ = $2; } + | error '\n' { yyerror("invalid key definition"); } ; key : TON TKEY TDO action { $$ = new_rule($2, $4); }