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
Hi,
> Le 21 sept. 2022 à 23:31, Lukas Arsalan a écrit :
>
> exp:
>"-" "num"{ $$ = -*new Float($2); std::cout << "NUMinv" << $$
> << std::endl; }
> | "num"{ $$ = new Float($1); std::cout << "num" << $$ <<
> std::endl; }
> | "-" exp { $$ = -*$2; std
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