[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: TODO update
From: |
Paul Hilfinger |
Subject: |
Re: TODO update |
Date: |
Thu, 25 Jul 2002 11:22:38 -0700 |
> I fail to see why $default exists here: the two valid lookaheads are $
> and + (as denoted by [$, '+']. So it seems to me that this state has
> no default, and ought to trigger an error *now*, now after reduction.
Consider the following grammar, which does NOT use %glr-parser:
----------------------------------------------------------------------
%%
prog : foo | bar ;
foo : '(' glorp ')' 'X' ;
bar : '(' gleep ')' ;
glorp : 'X' ;
gleep : 'X' ;
%%
----------------------------------------------------------------------
The grammar has a R/R conflict (obviously). The -v output is as
follows (excerpt):
----------------------------------------------------------------------
state 5
5 glorp: 'X' .
6 gleep: 'X' .
')' reduce using rule 5 (glorp)
')' [reduce using rule 6 (gleep)]
$default reduce using rule 5 (glorp)
----------------------------------------------------------------------
As you can see, Bison NORMALLY reports a $default reduction, even if
(as in this case), the only valid next token is ')', already covered
in the preceding two lines.
The $default reduction is actually used, by the way, but not in any
valid program. If your input were
(XX
for example, you'd get the following trace
----------------------------------------------------------------------
Starting parse
Entering state 0
Reading a token: Next token is token '(' ()
Shifting token 40 ('('), Entering state 1
Reading a token: Next token is token 'X' ()
Shifting token 88 ('X'), Entering state 5
Reducing via rule 5 (line 9), 'X' -> glorp <<< NOTE <<<
state stack now 0 1
Entering state 6
Reading a token: Next token is token 'X' ()
Err: parse error
Error: popping nterm glorp ()
Error: state stack now 0 1
Error: popping token '(' ()
Error: state stack now 0
----------------------------------------------------------------------
The marked line shows where the default reduction is used (the next
token is 'X', which is invalid).
Paul
- TODO update, Akim Demaille, 2002/07/09
- Re: TODO update, Paul Hilfinger, 2002/07/21
- Re: TODO update, Akim Demaille, 2002/07/22
- Re: TODO update, Paul Hilfinger, 2002/07/22
- Re: TODO update, Akim Demaille, 2002/07/23
- Re: TODO update, Paul Hilfinger, 2002/07/23
- Re: TODO update, Akim Demaille, 2002/07/24
- Re: TODO update, Paul Hilfinger, 2002/07/24
- Re: TODO update, Akim Demaille, 2002/07/25
- Re: TODO update,
Paul Hilfinger <=
- Re: TODO update, Akim Demaille, 2002/07/26
- Re: TODO update, Paul Hilfinger, 2002/07/28