summaryrefslogtreecommitdiff
path: root/TODO
diff options
context:
space:
mode:
authorAdela Vais <adela.vais99@gmail.com>2020-09-11 15:53:45 +0300
committerAkim Demaille <akim.demaille@gmail.com>2020-09-12 17:09:32 +0200
commit2bc886dc02f00e7ebbaa008af8fdfce45cebadcd (patch)
treee00f686be30decc87c5fbf44350921704e854305 /TODO
parentb5e6d9c4cae1a9057a02b416b07c35d306d71768 (diff)
downloadbison-2bc886dc02f00e7ebbaa008af8fdfce45cebadcd.tar.gz
d: make enum SymbolKind idiomatic D
Taking into account comments from H. S. Teoh. https://lists.gnu.org/r/bison-patches/2020-09/msg00021.html * data/skeletons/d.m4, data/skeletons/lalr1.d (SymbolKind): Wrap the enum in a structure that contains its string representation.
Diffstat (limited to 'TODO')
-rw-r--r--TODO84
1 files changed, 0 insertions, 84 deletions
diff --git a/TODO b/TODO
index 98849e7a..3f4d1978 100644
--- a/TODO
+++ b/TODO
@@ -242,90 +242,6 @@ are. Keep the same variable names. If you change the wording in one place,
do it in the others too. In other words: make sure to keep the
maintenance *simple* by avoiding any gratuitous difference.
-** Rename the D example
-Move the current content of examples/d into examples/d/simple.
-
-** Create a second example
-Duplicate examples/d/simple into examples/d/calc.
-
-** Add location tracking to d/calc
-Look at the examples in the other languages to see how to do that.
-
-** yysymbol_name
-The SymbolKind is an enum. For a given SymbolKind we want to get its string
-representation. Currently it's a separate table in the parser that does
-that:
-
- /* Symbol kinds. */
- public enum SymbolKind
- {
- S_YYEMPTY = -2, /* No symbol. */
- S_YYEOF = 0, /* "end of file" */
- S_YYerror = 1, /* error */
- S_YYUNDEF = 2, /* "invalid token" */
- S_EQ = 3, /* "=" */
- ...
- S_input = 14, /* input */
- S_line = 15, /* line */
- S_exp = 16, /* exp */
- };
-
- ...
-
- /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
- First, the terminals, then, starting at \a yyntokens_, nonterminals. */
- private static immutable string[] yytname_ =
- [
- "\"end of file\"", "error", "\"invalid token\"", "\"=\"", "\"+\"",
- "\"-\"", "\"*\"", "\"/\"", "\"(\"", "\")\"", "\"end of line\"",
- "\"number\"", "UNARY", "$accept", "input", "line", "exp", null
- ];
-
- ...
-
-So to get a symbol kind, one runs `yytname_[yykind]`.
-
-Is there a way to attach this conversion to string to SymbolKind? In Java
-for instance, we have:
-
- public enum SymbolKind
- {
- S_YYEOF(0), /* "end of file" */
- S_YYerror(1), /* error */
- S_YYUNDEF(2), /* "invalid token" */
- ...
- S_input(16), /* input */
- S_line(17), /* line */
- S_exp(18); /* exp */
-
- private final int yycode_;
-
- SymbolKind (int n) {
- this.yycode_ = n;
- }
- ...
- /* YYNAMES_[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
- First, the terminals, then, starting at \a YYNTOKENS_, nonterminals. */
- private static final String[] yynames_ = yynames_init();
- private static final String[] yynames_init()
- {
- return new String[]
- {
- i18n("end of file"), i18n("error"), i18n("invalid token"), "!", "+", "-", "*",
- "/", "^", "(", ")", "=", i18n("end of line"), i18n("number"), "NEG",
- "$accept", "input", "line", "exp", null
- };
- }
-
- /* The user-facing name of this symbol. */
- public final String getName() {
- return yynames_[yycode_];
- }
- };
-
-which allows to write more naturally `yykind.getName()` rather than
-`yytname_[yykind]`. Is there something comparable in (idiomatic) D?
-
** Change the return value of yylex
Historically people were allowed to return any int from the scanner (which
is convenient and allows `return '+'` from the scanner). Akim tends to see