]> ocean-lang.org Git - ocean/commitdiff
indent test: various fixed to match new design.
authorNeilBrown <neil@brown.name>
Fri, 3 Oct 2014 03:29:14 +0000 (13:29 +1000)
committerNeilBrown <neil@brown.name>
Fri, 3 Oct 2014 03:29:14 +0000 (13:29 +1000)
Signed-off-by: NeilBrown <neil@brown.name>
csrc/indent_test.cgm
csrc/itest.code

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;
index 9ce8305e0d2ea0d0da372273868c7fdf434ea52b..86b71a4a3276492e6ca1c013b1318adbed8da093 100644 (file)
                     x +
                     y
                     / two;
-       else if cond2:
+        else if cond2:
                there1 =x
                there1a=x
        there2=x
        there3=x;
        all = y;
-       if true {yes=x;} else no=x;
+       if true {yes=x;} else : no=x
+       if true: yes = no; no = yes;
+
+       if false {
+               print = OK
+       } else {
+               print = not_OK
+       }
+
+       if a:
+               if b:
+                       c= d
+       x = y