* src/print.c (print_core): Use %empty for empty rules.
* src/print_graph.c (print_core): Ditto.
* tests/conflicts.at, tests/output.at, tests/reduce.at: Adjust
expectations.
for (sp = rules[r].rhs; sp < sp1; sp++)
fprintf (out, " %s", symbols[*sp]->tag);
fputs (" .", out);
- for (/* Nothing */; *sp >= 0; ++sp)
- fprintf (out, " %s", symbols[*sp]->tag);
+ if (0 <= *rules[r].rhs)
+ for (/* Nothing */; 0 <= *sp; ++sp)
+ fprintf (out, " %s", symbols[*sp]->tag);
+ else
+ fprintf (out, " %%empty");
/* Display the lookahead tokens? */
if (report_flag & report_lookahead_tokens
obstack_1grow (oout, '.');
- for (/* Nothing */; *sp >= 0; ++sp)
- obstack_printf (oout, " %s", escape (symbols[*sp]->tag));
+ if (0 <= *r->rhs)
+ for (/* Nothing */; *sp >= 0; ++sp)
+ obstack_printf (oout, " %s", escape (symbols[*sp]->tag));
+ else
+ obstack_printf (oout, " %%empty");
/* Experimental feature: display the lookahead tokens. */
if (report_flag & report_lookahead_tokens
0 $accept: . start $end
1 start: . resolved_conflict 'a' reported_conflicts 'a'
2 resolved_conflict: . 'a' unreachable1
- 3 | . ['a']
+ 3 | . %empty ['a']
$default reduce using rule 3 (resolved_conflict)
1 start: resolved_conflict 'a' . reported_conflicts 'a'
8 reported_conflicts: . 'a'
9 | . 'a'
- 10 | . ['a']
+ 10 | . %empty ['a']
'a' shift, and go to state 5
6 | . empty_c1 'c'
7 | . empty_c2 'c'
8 | . empty_c3 'c'
- 9 empty_a: . ['a']
- 10 empty_b: . []
- 11 empty_c1: . []
- 12 empty_c2: . []
- 13 empty_c3: . ['c']
+ 9 empty_a: . %empty ['a']
+ 10 empty_b: . %empty []
+ 11 empty_c1: . %empty []
+ 12 empty_c2: . %empty []
+ 13 empty_c3: . %empty ['c']
'b' shift, and go to state 1
6 | . empty_c1 'c'
7 | . empty_c2 'c'
8 | . empty_c3 'c'
- 9 empty_a: . []
- 10 empty_b: . []
- 11 empty_c1: . []
- 12 empty_c2: . ['c']
- 13 empty_c3: . ['c']
+ 9 empty_a: . %empty []
+ 10 empty_b: . %empty []
+ 11 empty_c1: . %empty []
+ 12 empty_c2: . %empty ['c']
+ 13 empty_c3: . %empty ['c']
'a' error (nonassociative)
'b' error (nonassociative)
b: 'b';
]],
[[
- 0 [label="State 0\n\l 0 $accept: . exp $end\l 1 exp: . a '?' b\l 2 a: .\l"]
+ 0 [label="State 0\n\l 0 $accept: . exp $end\l 1 exp: . a '?' b\l 2 a: . %empty\l"]
0 -> 1 [style=dashed label="exp"]
0 -> 2 [style=dashed label="a"]
0 -> "0R2" [style=solid]
empty_c: %prec 'c';
]],
[[
- 0 [label="State 0\n\l 0 $accept: . start $end\l 1 start: . 'a'\l 2 | . empty_a 'a'\l 3 | . 'b'\l 4 | . empty_b 'b'\l 5 | . 'c'\l 6 | . empty_c 'c'\l 7 empty_a: . ['a']\l 8 empty_b: . ['b']\l 9 empty_c: . ['c']\l"]
+ 0 [label="State 0\n\l 0 $accept: . start $end\l 1 start: . 'a'\l 2 | . empty_a 'a'\l 3 | . 'b'\l 4 | . empty_b 'b'\l 5 | . 'c'\l 6 | . empty_c 'c'\l 7 empty_a: . %empty ['a']\l 8 empty_b: . %empty ['b']\l 9 empty_c: . %empty ['c']\l"]
0 -> 1 [style=solid label="'a'"]
0 -> 2 [style=solid label="'b'"]
0 -> 3 [style=solid label="'c'"]
empty_c: %prec 'c';
]],
[[
- 0 [label="State 0\n\l 0 $accept: . start $end\l 1 start: . 'a'\l 2 | . empty_a 'a'\l 3 | . 'b'\l 4 | . empty_b 'b'\l 5 | . 'c'\l 6 | . empty_c 'c'\l 7 empty_a: . ['a']\l 8 empty_b: . []\l 9 empty_c: . []\l"]
+ 0 [label="State 0\n\l 0 $accept: . start $end\l 1 start: . 'a'\l 2 | . empty_a 'a'\l 3 | . 'b'\l 4 | . empty_b 'b'\l 5 | . 'c'\l 6 | . empty_c 'c'\l 7 empty_a: . %empty ['a']\l 8 empty_b: . %empty []\l 9 empty_c: . %empty []\l"]
0 -> 1 [style=solid label="'b'"]
0 -> 2 [style=solid label="'c'"]
0 -> 3 [style=dashed label="start"]
b: ;
]],
[[
- 0 [label="State 0\n\l 0 $accept: . exp $end\l 1 exp: . a\l 2 | . b\l 3 a: . [$end]\l 4 b: . [$end]\l"]
+ 0 [label="State 0\n\l 0 $accept: . exp $end\l 1 exp: . a\l 2 | . b\l 3 a: . %empty [$end]\l 4 b: . %empty [$end]\l"]
0 -> 1 [style=dashed label="exp"]
0 -> 2 [style=dashed label="a"]
0 -> 3 [style=dashed label="b"]
c: ;
]],
[[
- 0 [label="State 0\n\l 0 $accept: . exp $end\l 1 exp: . a ';'\l 2 | . a ';'\l 3 | . a '.'\l 4 | . b '?'\l 5 | . b '!'\l 6 | . c '?'\l 7 | . c ';'\l 8 a: . [';', '.']\l 9 b: . ['?', '!']\l 10 c: . [';', '?']\l"]
+ 0 [label="State 0\n\l 0 $accept: . exp $end\l 1 exp: . a ';'\l 2 | . a ';'\l 3 | . a '.'\l 4 | . b '?'\l 5 | . b '!'\l 6 | . c '?'\l 7 | . c ';'\l 8 a: . %empty [';', '.']\l 9 b: . %empty ['?', '!']\l 10 c: . %empty [';', '?']\l"]
0 -> 1 [style=dashed label="exp"]
0 -> 2 [style=dashed label="a"]
0 -> 3 [style=dashed label="b"]
"11R7d" [label="R7", fillcolor=5, shape=diamond, style=filled]
11 -> "11R7" [style=solid]
"11R7" [label="R7", fillcolor=3, shape=diamond, style=filled]
- 12 [label="State 12\n\l 4 ifexp: \"if\" exp \"then\" exp . elseexp\l 5 elseexp: . \"else\" exp\l 6 | . [$end, \"then\", \"else\", '+']\l 7 opexp: exp . '+' exp\l"]
+ 12 [label="State 12\n\l 4 ifexp: \"if\" exp \"then\" exp . elseexp\l 5 elseexp: . \"else\" exp\l 6 | . %empty [$end, \"then\", \"else\", '+']\l 7 opexp: exp . '+' exp\l"]
12 -> 13 [style=solid label="\"else\""]
12 -> 9 [style=solid label="'+'"]
12 -> 14 [style=dashed label="elseexp"]
4 A: 'a' 'a' . B
5 B: . 'a'
- 6 | . ]AT_COND_CASE([[LALR]], [[['a', 'b']]], [[['a']]])[
+ 6 | . %empty ]AT_COND_CASE([[LALR]], [[['a', 'b']]], [[['a']]])[
]AT_COND_CASE([[canonical LR]], [['a']],
[[$default]])[ reduce using rule 6 (B)
4 A: 'a' 'a' . B
5 B: . 'a'
- 6 | . [$end]
+ 6 | . %empty [$end]
7 c: 'a' 'a' . 'b'
'a' shift, and go to state ]AT_COND_CASE([[canonical LR]], [[20]],
4 A: 'a' 'a' . B
5 B: . 'a'
- 6 | . ['b']
+ 6 | . %empty ['b']
'a' shift, and go to state ]AT_COND_CASE([[canonical LR]], [[23]],
[[16]])[
1 start: a . b
2 | a . b 'a'
3 | a . c 'b'
- 5 b: . [$end, 'a']
- 6 c: . ['b']]AT_COND_CASE([[most]], [[
+ 5 b: . %empty [$end, 'a']
+ 6 c: . %empty ['b']]AT_COND_CASE([[most]], [[
'b' reduce using rule 6 (c)
$default reduce using rule 5 (b)]], [[