[GiNaC-list] GiNaC::parser parses unary operators in the wrong order
Richard B. Kreckel
kreckel at in.terlu.de
Tue Jun 20 22:39:44 CEST 2023
Dear Vitaly,
Thanks a lot for looking into the parsing issues.
On 6/12/23 17:59, Vitaly Magerya wrote:
> On 20/02/2023, I wrote:
>> Hi, all. When parsing expressions with sign in the exponent, GiNaC's
>> parses confuses the priorities somehow. Here are some examples:
>>
>> 3^2+1 is parsed as (3^2)+1, which is correct;
>> 3^+2+1 is parsed as 3^(+2+1), which is wrong;
>> 3^-2+1 is parsed as 3^(-2+1), which is wrong;
>> 3^+2/3 is parsed as 3^(+2/3), which is wrong;
>> etc.
>
> So after some more testing I found that GiNaC doesn't only
> misparse the exponentiation this way, but multiplication too.
> Things like "3*+2+1" are parsed wrong too. The handling of the
> unary operators is broken if they appear after other operators.
>
> As a separate problem, parsing nested exponentiation, like
> "2^3^4", results in GiNaC throwing an exception, saying that
> "power should have exactly 2 operands", which is false: for
> example ginsh handles "2^3^4" easily and correctly.
>
> So, with some work I was able to fix both of these problems. I'm
> attaching a proposed solution, with tests included. Would it be
> possible to commit this?
I reviewed your patch and the test vectors and they look good. They make
sense. It is apparent that you cared very much for compatibility with
ginsh. I have applied the patch.
> I would additionally like to request a point release after this
> fix; this parsing problem potentially affects our usage of GiNaC,
> and we'd rather stay with a release version than build our own
> release tarballs.
I understand that GiNaC's parsing is important for your project. Yes, we
can do a release soonish.
All my best,
-richy.
--
Richard B. Kreckel
<https://in.terlu.de/~kreckel/>
More information about the GiNaC-list
mailing list