]> ocean-lang.org Git - ocean/commitdiff
parsergen: allow $$OUT as well as $$NEWLINE
authorNeilBrown <neil@brown.name>
Sat, 22 Jun 2019 23:00:06 +0000 (09:00 +1000)
committerNeilBrown <neil@brown.name>
Sat, 22 Jun 2019 23:00:06 +0000 (09:00 +1000)
Both of these mean the same thing: the product must end
in a 2-d visible way

Signed-off-by: NeilBrown <neil@brown.name>
csrc/indent_test.mdc
csrc/parsergen.mdc

index 6ba2479e58ecbd449811c6a355295cb4b7b629a8..88e93914aa6f88a7b49638e230c3d99e372019eb 100644 (file)
@@ -162,7 +162,7 @@ $*statement
                | Open SimpleStatements } ${ $0 = $<2; }$
                | : SimpleStatements $$NEWLINE ${ $0 = $<2; }$
                | : StatementBlock ${ $0 = $<2; }$
                | Open SimpleStatements } ${ $0 = $<2; }$
                | : SimpleStatements $$NEWLINE ${ $0 = $<2; }$
                | : StatementBlock ${ $0 = $<2; }$
-       StatementBlock -> Statementlist $$NEWLINE ${ $0 = $<1; }$
+       StatementBlock -> Statementlist $$OUT ${ $0 = $<1; }$
 
        SimpleStatements -> SimpleStatements ; SimpleStatement ${
                        {
 
        SimpleStatements -> SimpleStatements ; SimpleStatement ${
                        {
index 679fab6996de66a9fe267d914c654812f74771f3..76fec3a70a779cefe4589a9d79e861a61acd726e 100644 (file)
@@ -499,6 +499,8 @@ Now we have all the bits we need to parse a full production.
                        vs = sym_find(g, tk.txt);
                        if (vs->num == TK_newline)
                                p.line_like = 1;
                        vs = sym_find(g, tk.txt);
                        if (vs->num == TK_newline)
                                p.line_like = 1;
+                       else if (vs->num == TK_out)
+                               p.line_like = 2;
                        else if (vs->precedence == 0) {
                                err = "symbol after $$ must have precedence";
                                goto abort;
                        else if (vs->precedence == 0) {
                                err = "symbol after $$ must have precedence";
                                goto abort;
@@ -1651,8 +1653,10 @@ it up a bit.  First the items, with production number and associativity.
                        printf(" [%d%s]", s->precedence,
                               assoc_names[s->assoc]);
                }
                        printf(" [%d%s]", s->precedence,
                               assoc_names[s->assoc]);
                }
-               if (pr->line_like)
+               if (pr->line_like == 1)
                        printf(" $$NEWLINE");
                        printf(" $$NEWLINE");
+               else if (pr->line_like)
+                       printf(" $$OUT");
                printf("\n");
        }
 
                printf("\n");
        }