help-bison
[Top][All Lists]
Advanced

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

Identifying rule responsible for lookahead


From: Soumitra Kumar
Subject: Identifying rule responsible for lookahead
Date: Mon, 28 Feb 2005 12:46:52 -0800 (PST)

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.

Please help me.
-Soumitra.



                
__________________________________ 
Do you Yahoo!? 
Yahoo! Mail - Helps protect you from nasty viruses. 
http://promotions.yahoo.com/new_mail




reply via email to

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