]> ocean-lang.org Git - ocean/commitdiff
ident_test: declare precedence for 'else'
authorNeilBrown <neil@brown.name>
Sat, 15 Jun 2019 23:20:30 +0000 (09:20 +1000)
committerNeilBrown <neil@brown.name>
Sat, 15 Jun 2019 23:20:30 +0000 (09:20 +1000)
By declaring precedence for 'else', we suppress conflict warnings
Normally newlines and indents will resolve any conflict, but
if not, else associates to the right - it should be shifted, not cause
a reduce (which is the default anyway)

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

index d8e945ec3dab627994bb91492c080aac1d56b1a9..983d223dd6135f08b8e6fa3eb336a0ab7e2a3062 100644 (file)
@@ -187,12 +187,14 @@ $*statement
                | IfStatement ${ $0 = $<1; }$
                | Statement NEWLINE ${ $0 = $<1; }$
 
                | IfStatement ${ $0 = $<1; }$
                | Statement NEWLINE ${ $0 = $<1; }$
 
-       IfStatement -> if Expression Block OptNL ${
+       $RIGHT else
+
+       IfStatement -> if Expression Block OptNL $$else ${
                                $0 = calloc(1, sizeof(struct statement));
                                $0->expr = $<2;
                                $0->thenpart = $<3;
                                }$
                                $0 = calloc(1, sizeof(struct statement));
                                $0->expr = $<2;
                                $0->thenpart = $<3;
                                }$
-               | if Expression : SimpleStatements ${
+               | if Expression : SimpleStatements $$else ${
                                $0 = calloc(1, sizeof(struct statement));
                                $0->expr = $<2;
                                $0->thenpart = $<4;
                                $0 = calloc(1, sizeof(struct statement));
                                $0->expr = $<2;
                                $0->thenpart = $<4;