From: NeilBrown Date: Sun, 21 Jul 2013 09:27:27 +0000 (+1000) Subject: parsergen: allow "$void" to remove current type. X-Git-Tag: draftparser X-Git-Url: https://ocean-lang.org/code/?p=ocean;a=commitdiff_plain;h=6a0710bfe1622b5420ba53dca034ed18376b8740;hp=36adc544609b6144adefa0a000f77d2845b814e2 parsergen: allow "$void" to remove current type. This allows return to the initial state where nonterminals have no type. Signed-off-by: NeilBrown --- 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";