From 720591a5a06d6fbaca0b018ae7b1670882fc0f26 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Sun, 11 May 2014 16:59:56 +1000 Subject: [PATCH] indent_test: make use of new $ --- csrc/indent_test.cgm | 61 ++++++++++++++++++-------------------------- 1 file changed, 25 insertions(+), 36 deletions(-) diff --git a/csrc/indent_test.cgm b/csrc/indent_test.cgm index d95858a..50fc4a5 100644 --- a/csrc/indent_test.cgm +++ b/csrc/indent_test.cgm @@ -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 ${ -- 2.43.0