help-bison
[Top][All Lists]
Advanced

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

Re: are there user defined infix operators?


From: Hans Åberg
Subject: Re: are there user defined infix operators?
Date: Thu, 8 Nov 2018 14:48:16 +0100

> On 2 Nov 2018, at 17:53, Uxio Prego <address@hidden> wrote:
> 
> More specifically, I'm curious to know if Bison can modify precedences
> at parsing time according user sentences, now referring as user not the
> programmer who wrote the *.y doc but the programmer writing a program
> parsed by the parser generated from the *.y doc.

You can't but:

You can write general rules say for prefix, infix, and postfix operators, and 
then the actions put them onto to a stack with precedences and another for 
values. Then, when a new operator comes by, let the operators on the stack with 
higher precedences act on the value stack until something with a lower 
precedence appears, and put the new operator onto the stack. Continue until the 
end symbol comes by that has the lowest precedence. Operator associativity is 
handled by viewing left and right hand side precedences as different.





reply via email to

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