summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAkim Demaille <akim@lrde.epita.fr>2013-11-26 15:24:53 +0100
committerAkim Demaille <akim@lrde.epita.fr>2013-11-26 15:31:52 +0100
commit21cf80399f199a565fc5cffe2cad734313ad4e8f (patch)
treeced3a9ad1af6db2c32dfe0c62cd7300d8a6180f3
parent7b0ca050f7153f3d038243bf1182b23854996788 (diff)
downloadbison-21cf80399f199a565fc5cffe2cad734313ad4e8f.tar.gz
reports: display %empty in the generated pointed-rules
* 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.
-rw-r--r--src/print.c7
-rw-r--r--src/print_graph.c7
-rw-r--r--tests/conflicts.at24
-rw-r--r--tests/output.at12
-rw-r--r--tests/reduce.at10
5 files changed, 33 insertions, 27 deletions
diff --git a/src/print.c b/src/print.c
index 824bb4ae..53779def 100644
--- a/src/print.c
+++ b/src/print.c
@@ -106,8 +106,11 @@ print_core (FILE *out, state *s)
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
diff --git a/src/print_graph.c b/src/print_graph.c
index 7e429dbd..f15bc523 100644
--- a/src/print_graph.c
+++ b/src/print_graph.c
@@ -84,8 +84,11 @@ print_core (struct obstack *oout, state *s)
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
diff --git a/tests/conflicts.at b/tests/conflicts.at
index bbb3f89d..1ba94bcd 100644
--- a/tests/conflicts.at
+++ b/tests/conflicts.at
@@ -1447,7 +1447,7 @@ State 0
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)
@@ -1483,7 +1483,7 @@ State 4
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
@@ -1576,11 +1576,11 @@ AT_CHECK([[cat input.output | sed -n '/^State 0$/,/^State 1$/p']], 0,
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
@@ -1652,11 +1652,11 @@ AT_CHECK([[cat input.output | sed -n '/^State 0$/,/^State 1$/p']], 0,
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)
diff --git a/tests/output.at b/tests/output.at
index 6c98ef7e..266a5032 100644
--- a/tests/output.at
+++ b/tests/output.at
@@ -290,7 +290,7 @@ a: ;
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]
@@ -332,7 +332,7 @@ empty_b: %prec 'b';
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'"]
@@ -399,7 +399,7 @@ empty_b: %prec 'b';
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"]
@@ -447,7 +447,7 @@ a: ;
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"]
@@ -480,7 +480,7 @@ 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"]
@@ -595,7 +595,7 @@ imm: '0';
"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"]
diff --git a/tests/reduce.at b/tests/reduce.at
index 7e4977a0..9da9f49b 100644
--- a/tests/reduce.at
+++ b/tests/reduce.at
@@ -1057,7 +1057,7 @@ State 12
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)
@@ -1087,7 +1087,7 @@ State 15
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]],
@@ -1150,7 +1150,7 @@ State 22]])[
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]])[
@@ -1575,8 +1575,8 @@ State 3
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)]], [[