]> ocean-lang.org Git - ocean/commitdiff
indent_test: make use of new $<N syntax.
authorNeilBrown <neilb@suse.de>
Sun, 11 May 2014 06:59:56 +0000 (16:59 +1000)
committerNeilBrown <neilb@suse.de>
Sun, 15 Jun 2014 07:18:59 +0000 (17:18 +1000)
This removes a lot of boring code (also removes some code that was wrong.

Signed-off-by: NeilBrown <neilb@suse.de>
csrc/indent_test.cgm

index d95858a3684c7fa6c620553c6917a8c786b436eb..50fc4a5f7ea69a3601a051e580992b84c79a53d3 100644 (file)
@@ -113,90 +113,79 @@ OptSemi -> NEWLINE
        | ;
 
 $*statement
-       Statementlist -> Statements ${ $0 = $1; $1 = NULL; }$
+       Statementlist -> Statements ${ $0 = $<1; }$
        Statements -> Statements Statement ${
                                {
                                        struct statement **s;
-                                       $0 = $1;
+                                       $0 = $<1;
                                        s = &$0;
                                        while (*s)
                                                s = &(*s)->next;
-                                       if (body[2])
-                                               *s = $2;
-                                       if (body[0])
-                                               $1 = NULL;
-                                       if (body[2])
-                                               $2 = NULL;
+                                       *s = $<2;
                                }
                                }$
-                       | Statements OptSemi ${ $0 = $1; $1 = NULL; }$
+                       | Statements OptSemi ${ $0 = $<1; }$
                        | ${ $0 = NULL; }$
                        | ERROR ${ printf("statement ERROR\n"); $0 = NULL; }$
 
-       Block -> OptNL { Statementlist } OptNL ${ $0 = $3; $3 = NULL; }$
+       Block -> OptNL { Statementlist } OptNL ${ $0 = $<3; }$
                | : Statementlist ${ $0 = $2; $2 = NULL; }$
 
        Statement -> Factor = Expression OptSemi ${
                        $0 = calloc(1, sizeof(struct statement));
                        $0->expr = calloc(1, sizeof(struct expression));
-                       $0->expr->left = $1; $1 = NULL;
+                       $0->expr->left = $<1;
                        $0->expr->op = $2.txt;
-                       $0->expr->right = $3; $3 = NULL;
+                       $0->expr->right = $<3;
                        }$
                | if Expression Block OptNL ${
                                $0 = calloc(1, sizeof(struct statement));
-                               $0->expr = $2; $2 = NULL;
-                               $0->thenpart = $3;
-                               $3 = NULL;
+                               $0->expr = $<2;
+                               $0->thenpart = $<3;
                                }$
                | if Expression Statement ${
                                $0 = calloc(1, sizeof(struct statement));
-                               $0->expr = $2; $2 = NULL;
-                               $0->thenpart = $3;
-                               $3 = NULL;
+                               $0->expr = $<2;
+                               $0->thenpart = $<3;
                                }$
                | if Expression Block OptNL else Block ${
                                $0 = calloc(1, sizeof(struct statement));
-                               $0->expr = $2; $2 = NULL;
-                               $0->thenpart = $3;
-                               $3 = NULL;
-                               $0->elsepart = $6;
-                               $6 = NULL;
+                               $0->expr = $<2;
+                               $0->thenpart = $<3;
+                               $0->elsepart = $<6;
                                }$
                | if Expression Block OptNL else Statement ${
                                $0 = calloc(1, sizeof(struct statement));
-                               $0->expr = $2; $2 = NULL;
-                               $0->thenpart = $3;
-                               $3 = NULL;
-                               $0->elsepart = $6;
-                               $6 = NULL;
+                               $0->expr = $<2;
+                               $0->thenpart = $<3;
+                               $0->elsepart = $<6;
                                }$
 
 $*expression
        Expression -> Expression + Term ${
                                $0 = calloc(1, sizeof(struct expression));
                                $0->op = $2.txt;
-                               $0->left = $1; $1 = NULL;
-                               $0->right = $3; $3 = NULL;
+                               $0->left = $<1;
+                               $0->right = $<3;
                        }$
                    | Expression - Term ${
                                $0 = calloc(1, sizeof(struct expression));
                                $0->op = $2.txt;
-                               $0->left = $1; $1 = NULL;
-                               $0->right = $3; $3 = NULL;
+                               $0->left = $<1;
+                               $0->right = $<3;
                        }$
                    | Term ${ $0 = $1; $1 = NULL; }$
        Term -> Term * Factor ${
                                $0 = calloc(1, sizeof(struct expression));
                                $0->op = $2.txt;
-                               $0->left = $1; $1 = NULL;
-                               $0->right = $3; $3 = NULL;
+                               $0->left = $<1;
+                               $0->right = $<3;
                        }$
              | Term / Factor ${
                                $0 = calloc(1, sizeof(struct expression));
                                $0->op = $2.txt;
-                               $0->left = $1; $1 = NULL;
-                               $0->right = $3; $3 = NULL;
+                               $0->left = $<1;
+                               $0->right = $<3;
                        }$
              | Factor ${ $0 = $1; $1 = NULL; }$
        Factor -> IDENTIFIER ${