]> ocean-lang.org Git - ocean/blobdiff - csrc/indent_test.cgm
indent test: various fixed to match new design.
[ocean] / csrc / indent_test.cgm
index d5c31561f415dc780a56f01059b83a24836854cc..974c1676e55c5e531e64733b3906bd9876a77d6d 100644 (file)
@@ -117,12 +117,8 @@ Program -> Statementlist ${ print_statement($1, 0); }$
 OptNL -> NEWLINE
        |
 
-Newlines -> NEWLINE
-       | NEWLINE Newlines
-
 $*statement
-       Statementlist -> SimpleStatements ${ $0 = $<1; }$
-               | Statements ${ $0 = $<1; }$
+       Statementlist ->  Statements ${ $0 = $<1; }$
 
        Statements -> Statements Statement ${
                                {
@@ -134,10 +130,15 @@ $*statement
                                        *s = $<2;
                                }
                                }$
-                       | ${ $0 = NULL; }$
+                       | Statement ${ $0 = $<1; }$
                        | ERROR ${ printf("statement ERROR\n"); $0 = NULL; }$
 
-       Block -> OptNL { Statementlist OptNL } ${ $0 = $<3; }$
+       Open -> {
+               | NEWLINE {
+       Close -> }
+               | NEWLINE }
+       Block -> Open Statementlist Close ${ $0 = $<2; }$
+               | Open SimpleStatements } ${ $0 = $<2; }$
                | : Statementlist ${ $0 = $2; $2 = NULL; }$
 
        SimpleStatements -> SimpleStatements ; SimpleStatement ${
@@ -151,6 +152,7 @@ $*statement
                        }
                        }$
                | SimpleStatement ${ $0 = $<1; }$
+               | SimpleStatements ; ${ $0 = $<1; }$
 
        SimpleStatement -> Factor = Expression ${
                        $0 = calloc(1, sizeof(struct statement));
@@ -159,31 +161,35 @@ $*statement
                        $0->expr->op = $2.txt;
                        $0->expr->right = $<3;
                        }$
-       Statement -> SimpleStatements Newlines ${
-                       $0 = $<1;
-                       }$
-               | SimpleStatements ; Newlines ${
+       Statement -> SimpleStatements NEWLINE ${
                        $0 = $<1;
                        }$
                | IfStatement ${ $0 = $<1; }$
+               | Statement NEWLINE ${ $0 = $<1; }$
 
-       IfStatement -> if Expression Block ${
+       IfStatement -> if Expression Block OptNL ${
                                $0 = calloc(1, sizeof(struct statement));
                                $0->expr = $<2;
                                $0->thenpart = $<3;
                                }$
-               | if Expression SimpleStatement ${
+               | if Expression : SimpleStatements ${
                                $0 = calloc(1, sizeof(struct statement));
                                $0->expr = $<2;
-                               $0->thenpart = $<3;
+                               $0->thenpart = $<4;
                                }$
-               | if Expression Block Newlines else Block ${
+               | if Expression Block OptNL else Block ${
                                $0 = calloc(1, sizeof(struct statement));
                                $0->expr = $<2;
                                $0->thenpart = $<3;
                                $0->elsepart = $<6;
                                }$
-               | if Expression Block Newlines else IfStatement ${
+               | if Expression Block OptNL else : SimpleStatements ${
+                               $0 = calloc(1, sizeof(struct statement));
+                               $0->expr = $<2;
+                               $0->thenpart = $<3;
+                               $0->elsepart = $<7;
+                               }$
+               | if Expression Block OptNL else IfStatement ${
                                $0 = calloc(1, sizeof(struct statement));
                                $0->expr = $<2;
                                $0->thenpart = $<3;