help-bison
[Top][All Lists]
Advanced

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

Re: Operator precedence with empty operator


From: Пётр Прохоренков
Subject: Re: Operator precedence with empty operator
Date: Wed, 24 Mar 2010 00:32:10 +0300

Thanks for the quick reply!

Hugs code hepled. (That is weird how they never use bison precedence
annotations and just use multiple levels of non-terminals.)

-- Regards, Petr.


2010/3/23 Hans Aberg <address@hidden>

> On 23 Mar 2010, at 20:32, Пётр Прохоренков wrote:
>
>  I'm trying to write a grammar file for parsing expressions. The main part
>> goes as following:
>>
>> %left '-' '+';
>> expr: expr '+' expr
>>   | expr '-' expr
>> // Other operators...
>>   | expr expr
>>   | const
>>   | id
>>   ;
>>
>> "expr expr" here is function application, former expr is the function and
>> latter expression is an argument (as in Haskell).
>>
>
> You check the .y file of Hugs <http://haskell.org/hugs/>.
>
>
>  I don't understand what is wrong with %prec as documentation says it
>> assigns
>> precedence to rule.
>>
>
> If you look into the .output file for the parsing position "." in the state
> of the conflicting rules, then it uses the precedences of the two token
> immediately before and after that dot (one token from each). If there are
> not two such tokens available, because they way the rules have been written,
> the method fails.
>
>  Hans
>
>


reply via email to

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