diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2015-08-14 23:10:28 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2015-08-14 23:10:28 -0700 |
commit | 899655aa3b256dab10e764889c8323a53a585a04 (patch) | |
tree | 984c361037b86a01648b934ab2df24bc04df8e0a | |
parent | 280b5082e7967033cf345d94f7f260bc05e4a137 (diff) | |
download | txr-899655aa3b256dab10e764889c8323a53a585a04.tar.gz txr-899655aa3b256dab10e764889c8323a53a585a04.tar.bz2 txr-899655aa3b256dab10e764889c8323a53a585a04.zip |
Get Berkeley Yacc port of the parser working again.
* parser.y (byacc_fool): New grammar nonterminal symbol and
dummy rule set.
(spec): Use dummy byacc_fool to create a fake continuation
in the grammar, so the Berkeley-Yacc-generated parser doesn't
throw a syntax error. Our YYACCEPT prevents the byacc_fool part
from consuming more than one token of lookahead.
Bison doesn't need this because it has $default actions which reduce
regardless of the lookahead token. BYacc insists on reducing only
if it can match $end (end of input), and not other tokens, which
constitute syntax errors.
-rw-r--r-- | parser.y | 7 |
1 files changed, 7 insertions, 0 deletions
@@ -120,6 +120,7 @@ int yyparse(scanner_t *, parser_t *); %type <val> strlit chrlit quasilit quasi_items quasi_item litchars wordslit %type <val> wordsqlit not_a_clause %type <chr> regchar +%type <val> byacc_fool %type <lineno> '(' '[' '@' %nonassoc LOW /* used for precedence assertion */ @@ -141,6 +142,7 @@ spec : clauses { parser->syntax_tree = $1; } | /* empty */ { parser->syntax_tree = nil; } | SECRET_ESCAPE_R regexpr { parser->syntax_tree = $2; end_of_regex(scnr); } | SECRET_ESCAPE_E n_expr { parser->syntax_tree = $2; YYACCEPT; } + byacc_fool { internal_error("notreached"); } | SECRET_ESCAPE_E { if (yychar == YYEOF) { parser->syntax_tree = nao; YYACCEPT; @@ -156,6 +158,11 @@ spec : clauses { parser->syntax_tree = $1; } ; +/* Hack needed for Berkeley Yacc */ +byacc_fool : n_expr { internal_error("notreached"); } + | { internal_error("notreached"); } + ; + clauses : clauses_rev { $$ = nreverse($1); } clauses_rev : clause { $$ = check_for_include(cons($1, nil)); } |