From 6a0710bfe1622b5420ba53dca034ed18376b8740 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Sun, 21 Jul 2013 19:27:27 +1000 Subject: [PATCH] parsergen: allow "$void" to remove current type. This allows return to the initial state where nonterminals have no type. Signed-off-by: NeilBrown --- csrc/parsergen.mdc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/csrc/parsergen.mdc b/csrc/parsergen.mdc index e821e2c..0099f57 100644 --- a/csrc/parsergen.mdc +++ b/csrc/parsergen.mdc @@ -235,6 +235,12 @@ The data type name is simply stored and applied to the head of all subsequent productions. It must be the name of a structure, so `$expr` maps to `struct expr`. +Any productions given before the first data type will have no data type +and can carry no information. In order to allow other non-terminals to +have no type, the data type `$void` can be given. This does *not* mean +that `struct void` will be used, but rather than no type will be +associated with future non-terminals. + The precedence line must contain a list of symbols - typically terminal symbols, but not necessarily. It can only contain symbols that have not been seen yet, so precedence declaration must precede @@ -282,6 +288,8 @@ production inherits from the last symbol which has a precedence. assoc = Non; else { g->current_type = t.txt; + if (text_is(t.txt, "void")) + g->current_type.txt = NULL; t = token_next(ts); if (t.num != TK_newline) { err = "Extra tokens after type name"; -- 2.43.0