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
This commit is contained in:
Akim Demaille
2020-04-10 18:31:07 +02:00
parent 95421df67b
commit e50de09886
11 changed files with 70 additions and 28 deletions

16
TODO
View File

@@ -6,7 +6,7 @@ should not have to dispatch to several APIs.
** Documentation
- yyexpected_tokens in all the languages.
- YYENOMEM
- YYERRCODE?
- YYERRCODE, YYUNDEF, YYEOF
- i18n in Java
- symbol.type_get should be kind_get, and it's not documented.
@@ -85,6 +85,20 @@ push parsers on top of pull parser. Which is currently not relevant, since
push parsers are measurably slower.
* Bison 3.7
** Counter example generation
See https://github.com/akimd/bison/pull/15.
** Clean up
Rename user_token_number for tokens as "code". It's not a "user number",
it's the token code, and the user can control it, but this code always
exists.
Rename endtoken as eoftoken.
Don't rename in Bison 3.6 (it would be logical to do so) because that
would probably create many conflicts in Vincent's work (see previous point).
* Bison 3.8
** Unit rules / Injection rules (Akim Demaille)
Maybe we could expand unit rules (or "injections", see
https://homepages.cwi.nl/~daybuild/daily-books/syntax/2-sdf/sdf.html), i.e.,