diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2017-04-08 07:00:40 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2017-04-08 07:00:40 -0700 |
commit | 44638912c7353e46c5d2d9b6fe9362f662809f02 (patch) | |
tree | 8304aa7454f852e7dd910822ebb9e5a43bed9a67 /parser.y | |
parent | c4eb7f17cf2912575d483b21a0021375f23553cb (diff) | |
download | txr-44638912c7353e46c5d2d9b6fe9362f662809f02.tar.gz txr-44638912c7353e46c5d2d9b6fe9362f662809f02.tar.bz2 txr-44638912c7353e46c5d2d9b6fe9362f662809f02.zip |
parser: add some error cases to hash notations.
Produce better diagnostics for expressions like #[...
or #Habc.
* parser.y (vector, hash, struct, range): Add error
productions.
Diffstat (limited to 'parser.y')
-rw-r--r-- | parser.y | 10 |
1 files changed, 9 insertions, 1 deletions
@@ -818,6 +818,8 @@ vector : '#' list { if (unquotes_occur($2, 0)) cons($2, nil)), $2); else $$ = rlcp(vec_list($2), $2); } + | '#' error { $$ = nil; + yybadtok(yychar, lit("unassigned/reserved # notation")); } ; hash : HASH_H list { if (unquotes_occur($2, 0)) @@ -826,6 +828,8 @@ hash : HASH_H list { if (unquotes_occur($2, 0)) $$ = rl(hash_construct(first($2), rest($2)), num($1)); } + | HASH_H error { $$ = nil; + yybadtok(yychar, lit("hash literal")); } ; struct : HASH_S list { if (unquotes_occur($2, 0)) @@ -835,13 +839,17 @@ struct : HASH_S list { if (unquotes_occur($2, 0)) { val strct = make_struct_lit(first($2), rest($2)); $$ = rl(strct, num($1)); } } + | HASH_S error { $$ = nil; + yybadtok(yychar, lit("struct literal")); } ; range : HASH_R list { if (length($2) != two) yyerr("range literal needs two elements"); { val range = rcons(first($2), second($2)); $$ = rl(range, num($1)); } } - ; + | HASH_R error { $$ = nil; + yybadtok(yychar, lit("range literal")); } + ; list : '(' n_exprs ')' { $$ = rl($2, num($1)); } | '(' '.' n_exprs ')' { val a = car($3); |