On 19 Nov 2013, at 09:50, Florent Teichteil wrote:
> One question though: why do the precedence levels of operators '!' and
> '=' defined at the beginning of my grammar don't apply in this case?
> Moreover, I thought that ambiguous associativity was more likely to
> create shift/reduce conflicts
Le 18 nov. 2013 à 22:17, Florent Teichteil a
écrit :
> Hi all,
>
> I am new to bison and would need your kind help to understand why the
> following (stupid) simple grammar is ambiguous:
Actually your question is why the conflict remains.
> %left '!'
> %left '='
>
> %%
>
> start : bool_exp
You'll have to learn to decipher the grammar output file. Perhaps the
problem is the rule
num_expr : bool_expr
You are welcome to send me the output file as a mail attachment off his
list.
On 11/19/2013 11:40 AM, Florent Teichteil wrote:
>> ! is a prefix operator; = is infix.
>
> Sorry, but I
> ! is a prefix operator; = is infix.
Sorry, but I read bison's documentation regarding infix operators and
precedence levels, and I still don't understand your short explanation.
Here is another simple grammar with only infix operators that has conflicts:
%left '&'
%left '='
%left '+'
%%
start
! is a prefix operator; = is infix.
On 11/19/2013 09:50 AM, Florent Teichteil wrote:
> Thanks John!
> One question though: why do the precedence levels of operators '!' and
> '=' defined at the beginning of my grammar don't apply in this case?
> Moreover, I thought that ambiguous associativity was
Thanks John!
One question though: why do the precedence levels of operators '!' and
'=' defined at the beginning of my grammar don't apply in this case?
Moreover, I thought that ambiguous associativity was more likely to
create shift/reduce conflicts rather than reduce/reduce conflicts,
wasn't it?
>bool_expr : '!' bool_expr
> | num_expr '=' num_expr
> | 'b'
> ;
>
>num_expr : bool_expr
> | 'n'
> ;
Yes, this is ambiguous.
If your input is "!b=n", it can't tell which of these you mean:
! ( b = n )
(!b) = n
R's,
John
__
Hi all,
I am new to bison and would need your kind help to understand why the
following (stupid) simple grammar is ambiguous:
%left '!'
%left '='
%%
start : bool_expr ;
bool_expr : '!' bool_expr
| num_expr '=' num_expr
| 'b'
;
num_expr : bool_expr
| 'n'