aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOmar Polo <op@omarpolo.com>2020-10-01 11:52:03 +0200
committerOmar Polo <op@omarpolo.com>2020-10-01 11:53:11 +0200
commiteb90e50e34471fcbe785588d8113c4d581754f99 (patch)
tree913ee1cef5cc36805375c0d8a1eefd5942a4062f
parent7d3286caede96d7b813eff7dc3691d683d0f9bf9 (diff)
downloadstar-platinum-eb90e50e34471fcbe785588d8113c4d581754f99.tar.gz
star-platinum-eb90e50e34471fcbe785588d8113c4d581754f99.tar.bz2
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.
-rw-r--r--parse.y8
1 files changed, 6 insertions, 2 deletions
diff --git a/parse.y b/parse.y
index 68bb6d1..c7d0896 100644
--- a/parse.y
+++ b/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); }