From f67c1ce937736ff243430a288bba55867a5e563d Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Sat, 2 Jan 2021 07:33:08 +0100 Subject: [PATCH] glr.c: example: use the exact same display as in the C++ example * examples/c/glr/c++-types.y: Add a space after the commas. * examples/c/glr/c++-types.test: Adjust expectations. --- examples/c/glr/c++-types.test | 16 ++++++++-------- examples/c/glr/c++-types.y | 12 ++++++------ 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/examples/c/glr/c++-types.test b/examples/c/glr/c++-types.test index 46e10483..079538c3 100644 --- a/examples/c/glr/c++-types.test +++ b/examples/c/glr/c++-types.test @@ -35,13 +35,13 @@ T (y y) = z + q; z + q; EOF run 0 "\ -1.0-4: +(z,q) -3.0-2: (T,x) -5.0-6: (T,x,y) -7.0-4: =(x,y) -9.0-8: +((x,T),y) -11.0-4: ((T,x),(x,T)) -13.0-12: ((T,y,+(z,q)),=((y,T),+(z,q))) +1.0-4: +(z, q) +3.0-2: (T, x) +5.0-6: (T, x, y) +7.0-4: =(x, y) +9.0-8: +((x, T), y) +11.0-4: ((T, x), (x, T)) +13.0-12: ((T, y, +(z, q)), =((y, T), +(z, q))) 15.0-14: -17.0-4: +(z,q) +17.0-4: +(z, q) err: 15.5: syntax error, unexpected identifier, expecting '=' or '+' or ')'" diff --git a/examples/c/glr/c++-types.y b/examples/c/glr/c++-types.y index b44bd6ad..2d52b2b1 100644 --- a/examples/c/glr/c++-types.y +++ b/examples/c/glr/c++-types.y @@ -106,15 +106,15 @@ stmt : expr ';' %merge { $$ = $1; } expr : ID | TYPENAME '(' expr ')' - { $$ = new_nterm ("(%s,%s)", $3, $1, NULL); } - | expr '+' expr { $$ = new_nterm ("+(%s,%s)", $1, $3, NULL); } - | expr '=' expr { $$ = new_nterm ("=(%s,%s)", $1, $3, NULL); } + { $$ = new_nterm ("(%s, %s)", $3, $1, NULL); } + | expr '+' expr { $$ = new_nterm ("+(%s, %s)", $1, $3, NULL); } + | expr '=' expr { $$ = new_nterm ("=(%s, %s)", $1, $3, NULL); } ; decl : TYPENAME declarator ';' - { $$ = new_nterm ("(%s,%s)", $1, $2, NULL); } + { $$ = new_nterm ("(%s, %s)", $1, $2, NULL); } | TYPENAME declarator '=' expr ';' - { $$ = new_nterm ("(%s,%s,%s)", $1, + { $$ = new_nterm ("(%s, %s, %s)", $1, $2, $4); } ; @@ -291,7 +291,7 @@ static void node_print (FILE *out, Node *n) static Node* stmtMerge (YYSTYPE x0, YYSTYPE x1) { - return new_nterm ("(%s,%s)", x0.stmt, x1.stmt, NULL); + return new_nterm ("(%s, %s)", x0.stmt, x1.stmt, NULL); } static int