]> ocean-lang.org Git - ocean/blobdiff - csrc/parsergen.mdc
parsergen: allow "$void" to remove current type.
[ocean] / csrc / parsergen.mdc
index e821e2cc4fe361ab2700bf44bcf952b0da96620b..0099f5785db32072118b228473d8aa94ed9bf09f 100644 (file)
@@ -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";