diff options
author | Akim Demaille <akim.demaille@gmail.com> | 2020-04-10 18:31:07 +0200 |
---|---|---|
committer | Akim Demaille <akim.demaille@gmail.com> | 2020-04-12 13:56:44 +0200 |
commit | e50de09886bfdf4febb75accdd1549952787b5e0 (patch) | |
tree | f4c72ebd23bc6a5123d343b3e2c01d30e7ac1ec4 /tests | |
parent | 95421df67b21f7a508404b11f51d27e384335ea1 (diff) | |
download | bison-e50de09886bfdf4febb75accdd1549952787b5e0.tar.gz |
tokens: properly define the YYEOF token kind
Currently EOF is handled in an adhoc way, with a #define YYEOF 0 in
the implementation file. As a result, the user has to define her own
EOF token if she wants to use it, which is a pity.
Give the $end token a visible kind name, YYEOF. Except that in C,
where enums are not scoped, we would have collisions between all the
definitions of YYEOFs in the header files, so in C, make it
<api.PREFIX>EOF.
* data/skeletons/c.m4 (YYEOF): Override its name to avoid collisions.
Unless the user already gave it a different name.
* data/skeletons/glr.c (YYEOF): Remove.
Use ]b4_symbol(0, [id])[ instead.
Add support for "pre_epilogue", for glr.cc.
* data/skeletons/glr.cc: Remove dead code (never emitted #undefs).
* data/skeletons/yacc.c
* src/parse-gram.c
* src/reader.c
* src/symtab.c
* tests/actions.at
* tests/input.at
Diffstat (limited to 'tests')
-rw-r--r-- | tests/actions.at | 9 | ||||
-rw-r--r-- | tests/input.at | 3 |
2 files changed, 11 insertions, 1 deletions
diff --git a/tests/actions.at b/tests/actions.at index 9fa630df..223d00d2 100644 --- a/tests/actions.at +++ b/tests/actions.at @@ -1303,6 +1303,15 @@ AT_CLEANUP AT_SETUP([Default %printer and %destructor for user-defined end token]) +# Enable declaration of default %printer/%destructor. Make the parser +# use these for all user-declared grammar symbols for which the user +# does not declare a specific %printer/%destructor. Thus, the parser +# uses it for token 0 if the user declares it but not if Bison +# generates it as $end. Discussed starting at +# <http://lists.gnu.org/r/bison-patches/2006-02/msg00064.html>, +# <http://lists.gnu.org/r/bison-patches/2006-06/msg00091.html>, and +# <http://lists.gnu.org/r/bison-patches/2006-07/msg00019.html>. + # AT_TEST(TYPED) # -------------- m4_pushdef([AT_TEST], diff --git a/tests/input.at b/tests/input.at index 6d434350..2250406d 100644 --- a/tests/input.at +++ b/tests/input.at @@ -344,6 +344,7 @@ exp: int main (void) { assert (YYERRCODE == 123); + assert (YYTRANSLATE (YYEOF) == YYSYMBOL_YYEOF); assert (YYTRANSLATE (YYERRCODE) == YYSYMBOL_YYERROR); assert (YYTRANSLATE (YYUNDEF) == YYSYMBOL_YYUNDEF); return 0; @@ -430,7 +431,7 @@ exp:; AT_BISON_CHECK([-Wno-other -S./dump-symbols.m4 input.y]) AT_CHECK([cat symbols.csv], [], [[number, class, tag, id, user_number, type, -0, Token, $end, , 0, , +0, Token, $end, YYEOF, 0, , 1, Token, error, YYERRCODE, 256, , 2, Token, $undefined, YYUNDEF, 257, , 3, Token, 'a', , 97, , |