help-bison
[Top][All Lists]
Advanced

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

Re: doubts with shift-reduce and nonterminals


From: Hans Aberg
Subject: Re: doubts with shift-reduce and nonterminals
Date: Tue, 24 Jan 2006 20:35:05 +0100

On 24 Jan 2006, at 16:11, Mili Sandokan wrote:

I know how to set precedence between tokens but i'm asking how to do
this when the  " . " is between two non-terminals.... ¿can I show you
a piece of the output file?

I do not remember the details how it works, and further, the method does not have the capacity of resolving all shift/reduce conflicts.

   81 s_condicional: T_IF '(' expresion ')' . sentencia_o_nada
   82              | T_IF '(' expresion ')' . sentencia_o_nada T_ELSE

In this case, the tokens closest to the '.' are ')' and T_ELSE; so you should have token precedences set on those two. If you rewrite the rule as:
    cond: IF bool_expr THEN expr
    cond: IF bool_expr THEN expr ELSE expr
then the tokens closest to '.', will be, I think THEN and ELSE, and token precedences should be set ointo those.

So it is a very primitive method of resolving shift/resolve conflict, that doe not depend only the grammar, but how it is written in the form of rules.

  Hans Aberg






reply via email to

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