Don't apply the default %destructor/%printer to an unreferenced midrule

value.  Mentioned at
<http://lists.gnu.org/archive/html/bison-patches/2006-09/msg00104.html>.
* src/symtab.c (dummy_symbol_get): Name all dummy symbols initially
like $@n instead of just @n so that the default %destructor/%printer
logic doesn't see them as user-defined symbols.
(symbol_is_dummy): Check for both forms of the name.
* src/reader.c (packgram): Remove the `$' from each midrule symbol
name for which the midrule value is referenced in any action.
* tests/actions.at (Default %printer and %destructor for mid-rule
values): New test.
* tests/regression.at (Rule Line Numbers, Web2c Report): Update output
for change to dummy symbol names.
This commit is contained in:
Joel E. Denny
2006-10-21 04:52:43 +00:00
parent 519d000408
commit f91b162944
5 changed files with 165 additions and 34 deletions

View File

@@ -252,13 +252,13 @@ AT_CHECK([cat input.output], [],
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'
Terminals, with rules where they appear
@@ -276,9 +276,9 @@ $accept (6)
on left: 0
expr (7)
on left: 2 4, on right: 0
@1 (8)
$@1 (8)
on left: 1, on right: 2
@2 (9)
$@2 (9)
on left: 3, on right: 4
@@ -288,19 +288,19 @@ state 0
'a' shift, and go to state 1
$default reduce using rule 3 (@2)
$default reduce using rule 3 ($@2)
expr go to state 2
@2 go to state 3
$@2 go to state 3
state 1
2 expr: 'a' . @1 'b'
2 expr: 'a' . $@1 'b'
$default reduce using rule 1 (@1)
$default reduce using rule 1 ($@1)
@1 go to state 4
$@1 go to state 4
state 2
@@ -312,14 +312,14 @@ state 2
state 3
4 expr: @2 . 'c'
4 expr: $@2 . 'c'
'c' shift, and go to state 6
state 4
2 expr: 'a' @1 . 'b'
2 expr: 'a' $@1 . 'b'
'b' shift, and go to state 7
@@ -333,14 +333,14 @@ state 5
state 6
4 expr: @2 'c' .
4 expr: $@2 'c' .
$default reduce using rule 4 (expr)
state 7
2 expr: 'a' @1 'b' .
2 expr: 'a' $@1 'b' .
$default reduce using rule 2 (expr)
]])
@@ -553,9 +553,9 @@ AT_CHECK([cat input.output], 0,
2 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 ';'
Terminals, with rules where they appear
@@ -578,7 +578,7 @@ CONST_DEC_LIST (9)
on left: 2 3, on right: 1 3
CONST_DEC (10)
on left: 5, on right: 2 3
@1 (11)
$@1 (11)
on left: 4, on right: 5
@@ -586,12 +586,12 @@ state 0
0 $accept: . CONST_DEC_PART $end
$default reduce using rule 4 (@1)
$default reduce using rule 4 ($@1)
CONST_DEC_PART go to state 1
CONST_DEC_LIST go to state 2
CONST_DEC go to state 3
@1 go to state 4
$@1 go to state 4
state 1
@@ -606,11 +606,11 @@ state 2
1 CONST_DEC_PART: CONST_DEC_LIST .
3 CONST_DEC_LIST: CONST_DEC_LIST . CONST_DEC
undef_id_tok reduce using rule 4 (@1)
undef_id_tok reduce using rule 4 ($@1)
$default reduce using rule 1 (CONST_DEC_PART)
CONST_DEC go to state 6
@1 go to state 4
$@1 go to state 4
state 3
@@ -622,7 +622,7 @@ state 3
state 4
5 CONST_DEC: @1 . undef_id_tok '=' const_id_tok ';'
5 CONST_DEC: $@1 . undef_id_tok '=' const_id_tok ';'
undef_id_tok shift, and go to state 7
@@ -643,28 +643,28 @@ state 6
state 7
5 CONST_DEC: @1 undef_id_tok . '=' const_id_tok ';'
5 CONST_DEC: $@1 undef_id_tok . '=' const_id_tok ';'
'=' shift, and go to state 8
state 8
5 CONST_DEC: @1 undef_id_tok '=' . const_id_tok ';'
5 CONST_DEC: $@1 undef_id_tok '=' . const_id_tok ';'
const_id_tok shift, and go to state 9
state 9
5 CONST_DEC: @1 undef_id_tok '=' const_id_tok . ';'
5 CONST_DEC: $@1 undef_id_tok '=' const_id_tok . ';'
';' shift, and go to state 10
state 10
5 CONST_DEC: @1 undef_id_tok '=' const_id_tok ';' .
5 CONST_DEC: $@1 undef_id_tok '=' const_id_tok ';' .
$default reduce using rule 5 (CONST_DEC)
]])