diff options
author | Akim Demaille <akim.demaille@gmail.com> | 2019-08-30 06:57:26 -0500 |
---|---|---|
committer | Akim Demaille <akim.demaille@gmail.com> | 2019-09-14 10:09:08 +0200 |
commit | 5e95bb6251cc1089e95cb5b1ec8f08f029b60131 (patch) | |
tree | 0168db9a801e491d8951e8be73ca1c5bfe0d098b /data | |
parent | 569125a6bf68f37bae9eca5914b39a9e7bcaa3c4 (diff) | |
download | bison-5e95bb6251cc1089e95cb5b1ec8f08f029b60131.tar.gz |
d: handle eof in yytranslate
This changes the traces from
Reading a token:
Now at end of input.
to
Reading a token:
Next token is token $end (7FFEE56E6474)
which is ok. Actually it is even better, as it gives the location
when locations are enabled, and is clearer when rules explicitly use
the EOF token.
* data/skeletons/lalr1.d (yytranslate_): Handle eof here, as is done
in lalr1.cc.
Diffstat (limited to 'data')
-rw-r--r-- | data/skeletons/lalr1.d | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/data/skeletons/lalr1.d b/data/skeletons/lalr1.d index fd19e852..672c8a14 100644 --- a/data/skeletons/lalr1.d +++ b/data/skeletons/lalr1.d @@ -500,17 +500,9 @@ m4_popdef([b4_at_dollar])])dnl } /* Convert token to internal form. */ - if (yychar <= YYTokenType.EOF) - { - yychar = yytoken = YYTokenType.EOF;]b4_parse_trace_if([[ - yycdebug ("Now at end of input.\n");]])[ - } - else - { - yytoken = yytranslate_ (yychar);]b4_parse_trace_if([[ - yy_symbol_print ("Next token is", - yytoken, yylval]b4_locations_if([, yylloc])[);]])[ - } + yytoken = yytranslate_ (yychar);]b4_parse_trace_if([[ + yy_symbol_print ("Next token is", + yytoken, yylval]b4_locations_if([, yylloc])[);]])[ /* If the proper action on seeing token YYTOKEN is to reduce or to detect an error, take that action. */ @@ -833,7 +825,9 @@ m4_popdef([b4_at_dollar])])dnl ]b4_translate[ @}; - if (0 <= t && t <= yyuser_token_number_max_) + if (t <= 0) + return YYTokenType.EOF; + else if (t <= yyuser_token_number_max_) return translate_table[t]; else return yyundef_token_;]])[ |