help-bison
[Top][All Lists]
Advanced

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

Re: how to solve this reduce/reduce conflict?


From: Lukas Arsalan
Subject: Re: how to solve this reduce/reduce conflict?
Date: Thu, 22 Sep 2022 19:02:38 +0000 (UTC)

On 2022-09-22T15:54:31UTC Hans Åberg <haberg-1@telia.com> wrote:
 > Context switches are best avoided unless absolutely necessary, in my 
 > experience.
> So if one designs ones own language, it might be good to try to avoid them
> by a change in the grammar.
>
OK... I know that there are no signed numbers usually... But I wanted to try to 
change that...
So for _me_ in "-2" the minus is a sign... And in "- 2" the minus is a unary 
inversion operator... And in "1-2"  the minus is a subtraction operator (or an 
abbreviation for "1+-2" respectively (where the minus is a sign again))...
This can all be done quite elegantly with this context trick in the ll-file...

> It might be confusing with -2^4 meaning (-2)^4, because in 1 - 2^4, it should 
> be 1 - (2^4),
> and 1 -2^4 would be an error if two number cannot follow each other.
>
"1 -2^4" is no error in my program... it results in "-15".
It even says, that "- 2^4" is "-16", while "-2^4" is "16". 🥳

Do u think there will be any unwanted side effects?

-arne


reply via email to

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