how to solve this reduce/reduce conflict?

2022-09-21 Thread Lukas Arsalan
Usually -2^2 is considered to be -4, because: the minus is interpreted as a unary operator with lower precedence, than ^ (power)... E.g.: http://www.isthe.com/chongo/tech/comp/calc/ _but_: I would like to have a parser, [1] that binds the sign of a number stronger than a ^ (power), and [2] that

Re: how to solve this reduce/reduce conflict?

2022-09-21 Thread Lukas Arsalan
Hi, At 2022-09-22T07:08:55CEST Akim Demaille wrote: > This snippet is clearly ambiguous, since it allows two different parses of > -1, which -Wcex nicely showed. > yes. right. > If I were you, I would handle this in the scanner.  IOW, the scanner should > be extended to support signed literals

Re: how to solve this reduce/reduce conflict?

2022-09-22 Thread Lukas Arsalan
On 2022-09-22T07:57:45UTC Hans Åberg wrote: > On 22 Sep 2022, at 08:30, Lukas Arsalan wrote: >> [1] -1 --> "num" >> [2] 1-2 --> "num" "-" "num" >> [3] (-1^-2) --> "(" "num" "^" "num&

Re: how to solve this reduce/reduce conflict?

2022-09-22 Thread Lukas Arsalan
On 2022-09-22T15:54:31UTC Hans Åberg 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...