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.
This commit is contained in:
Akim Demaille
2021-01-02 07:33:08 +01:00
parent 5a4e606275
commit f67c1ce937
2 changed files with 14 additions and 14 deletions

View File

@@ -35,13 +35,13 @@ T (y y) = z + q;
z + q;
EOF
run 0 "\
1.0-4: +(z,q)
3.0-2: <declare>(T,x)
5.0-6: <init-declare>(T,x,y)
7.0-4: =(x,y)
9.0-8: +(<cast>(x,T),y)
11.0-4: <OR>(<declare>(T,x),<cast>(x,T))
13.0-12: <OR>(<init-declare>(T,y,+(z,q)),=(<cast>(y,T),+(z,q)))
1.0-4: +(z, q)
3.0-2: <declare>(T, x)
5.0-6: <init-declare>(T, x, y)
7.0-4: =(x, y)
9.0-8: +(<cast>(x, T), y)
11.0-4: <OR>(<declare>(T, x), <cast>(x, T))
13.0-12: <OR>(<init-declare>(T, y, +(z, q)), =(<cast>(y, T), +(z, q)))
15.0-14: <error>
17.0-4: +(z,q)
17.0-4: +(z, q)
err: 15.5: syntax error, unexpected identifier, expecting '=' or '+' or ')'"

View File

@@ -106,15 +106,15 @@ stmt : expr ';' %merge <stmtMerge> { $$ = $1; }
expr : ID
| TYPENAME '(' expr ')'
{ $$ = new_nterm ("<cast>(%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 ("<cast>(%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 ("<declare>(%s,%s)", $1, $2, NULL); }
{ $$ = new_nterm ("<declare>(%s, %s)", $1, $2, NULL); }
| TYPENAME declarator '=' expr ';'
{ $$ = new_nterm ("<init-declare>(%s,%s,%s)", $1,
{ $$ = new_nterm ("<init-declare>(%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 ("<OR>(%s,%s)", x0.stmt, x1.stmt, NULL);
return new_nterm ("<OR>(%s, %s)", x0.stmt, x1.stmt, NULL);
}
static int