report: use %empty to denote empty rules

* src/gram.c (rule_rhs_print): Use %empty for empty rules.
* tests/conflicts.at, tests/regression.at, tests/sets.at: Adjust.
This commit is contained in:
Akim Demaille
2013-02-16 12:46:09 +01:00
parent 42d101da8d
commit 8b807f1177
4 changed files with 17 additions and 19 deletions

View File

@@ -93,16 +93,14 @@ rule_rhs_length (rule const *r)
void void
rule_rhs_print (rule const *r, FILE *out) rule_rhs_print (rule const *r, FILE *out)
{ {
if (*r->rhs >= 0) if (0 <= *r->rhs)
{ {
item_number *rp; item_number *rp;
for (rp = r->rhs; *rp >= 0; rp++) for (rp = r->rhs; *rp >= 0; rp++)
fprintf (out, " %s", symbols[*rp]->tag); fprintf (out, " %s", symbols[*rp]->tag);
} }
else else
{ fputs (" %empty", out);
fprintf (out, " /* %s */", _("empty"));
}
} }
static void static void

View File

@@ -1299,13 +1299,13 @@ AT_CHECK([[cat input.output]], 0,
2 resolved_conflict: 'a' unreachable1 2 resolved_conflict: 'a' unreachable1
4 unreachable1: 'a' unreachable2 4 unreachable1: 'a' unreachable2
5 | /* empty */ 5 | %empty
6 unreachable2: /* empty */ 6 unreachable2: %empty
7 | /* empty */ 7 | %empty
9 reported_conflicts: 'a' 9 reported_conflicts: 'a'
10 | /* empty */ 10 | %empty
State 4 conflicts: 1 shift/reduce State 4 conflicts: 1 shift/reduce
@@ -1319,17 +1319,17 @@ Grammar
1 start: resolved_conflict 'a' reported_conflicts 'a' 1 start: resolved_conflict 'a' reported_conflicts 'a'
2 resolved_conflict: 'a' unreachable1 2 resolved_conflict: 'a' unreachable1
3 | /* empty */ 3 | %empty
4 unreachable1: 'a' unreachable2 4 unreachable1: 'a' unreachable2
5 | /* empty */ 5 | %empty
6 unreachable2: /* empty */ 6 unreachable2: %empty
7 | /* empty */ 7 | %empty
8 reported_conflicts: 'a' 8 reported_conflicts: 'a'
9 | 'a' 9 | 'a'
10 | /* empty */ 10 | %empty
Terminals, with rules where they appear Terminals, with rules where they appear

View File

@@ -263,11 +263,11 @@ AT_CHECK([cat input.output], [],
0 $accept: expr $end 0 $accept: expr $end
1 $@1: /* empty */ 1 $@1: %empty
2 expr: 'a' $@1 'b' 2 expr: 'a' $@1 'b'
3 $@2: /* empty */ 3 $@2: %empty
4 expr: $@2 'c' 4 expr: $@2 'c'
@@ -573,7 +573,7 @@ AT_CHECK([cat input.output], 0,
2 CONST_DEC_LIST: CONST_DEC 2 CONST_DEC_LIST: CONST_DEC
3 | CONST_DEC_LIST CONST_DEC 3 | CONST_DEC_LIST CONST_DEC
4 $@1: /* empty */ 4 $@1: %empty
5 CONST_DEC: $@1 undef_id_tok '=' const_id_tok ';' 5 CONST_DEC: $@1 undef_id_tok '=' const_id_tok ';'

View File

@@ -86,7 +86,7 @@ AT_CHECK([[cat sets]], [],
0 e $end 0 e $end
e derives e derives
1 'e' 1 'e'
2 /* empty */ 2 %empty
NULLABLE NULLABLE
$accept: no $accept: no
e: yes e: yes
@@ -100,10 +100,10 @@ FDERIVES
$accept derives $accept derives
0 e $end 0 e $end
1 'e' 1 'e'
2 /* empty */ 2 %empty
e derives e derives
1 'e' 1 'e'
2 /* empty */ 2 %empty
]]) ]])
AT_CLEANUP AT_CLEANUP