help-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Identifying rule responsible for lookahead


From: Hans Aberg
Subject: Re: Identifying rule responsible for lookahead
Date: Tue, 01 Mar 2005 21:35:44 +0100
User-agent: Microsoft-Outlook-Express-Macintosh-Edition/5.0.6

At 12:46 -0800 2005/02/28, Soumitra Kumar wrote:
>Following is a sample grammar. There is one r/r
>conflict.
>
>% cat test.y
>%token YYID YYDOT
>%%
>identifier : hier_id
>        ;
>hier_id : simple_id
>        | hier_id opt_select YYDOT simple_id
>        ;
>opt_select :
>        | opt_select '[' expr ']'
>        ;
>
>simple_id : YYID ;
>expr : hier_id
>        | function_call
>        ;
>function_call : expr YYDOT YYID
>        ;
>% bison -r all -v test.y -g
>test.y: conflicts: 1 reduce/reduce
>
>>From test.output:
>state 10
>
>    3 hier_id: hier_id . opt_select YYDOT simple_id
>    4 opt_select: .  [YYDOT, '[']
>    5           | . opt_select '[' expr ']'
>    7 expr: hier_id .  [YYDOT, ']']
>
>    YYDOT     reduce using rule 4 (opt_select)
>    YYDOT     [reduce using rule 7 (expr)]
>
>YYDOT is in the lookahead set of rule 7 (expr:
>hier_id) because of rule 9 (function_call: expr YYDOT
>YYID).
>
>If nonterminal expr is used is many rules, it gets
>difficult to find out which usage is causing problem.
>
>Basically I want to annotate the rules responsible for
>a lookahead token as follows.
>
>state 10
>
>    3 hier_id: hier_id . opt_select YYDOT simple_id
>    4 opt_select: .  [YYDOT (3), '[' (5)]
>    5           | . opt_select '[' expr ']'
>    7 expr: hier_id .  [YYDOT (9), ']' (5)]
>
>    YYDOT     reduce using rule 4 (opt_select)
>    YYDOT     [reduce using rule 7 (expr)]
>
>I was wondering if there is a way to get this
>information out of bison.

The problem is how to extract the information from the LALR(1) algorithm, if
possible. Do you have any suggestion? (I may think a bit more on the
question.)

It is otherwise not a help-bison issue, but a "featuritis" issue, which
normally should be posted in the bug-bison list.

  Hans Aberg






reply via email to

[Prev in Thread] Current Thread [Next in Thread]