| Karim BELABAS on Sat, 14 Dec 2002 21:15:47 +0100 (MET) | 
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
| Re: gp: eval(Str("A"(-1)"B")) | 
On Sat, 14 Dec 2002, Michael Somos wrote:
>     For my own information I would like to know why the difference:
>
> ? eval(Str("A"(1)"B"))
> %1 = A1B
> ? eval(Str("A"(-1)"B"))
> %2 = A - 1
I see no problem with eval("A1B") --> A1B
eval("A-1B") should trigger a syntax error, namely
  ***   unused characters: A-1B
                              ^-
Unfortunately, 'eval' simply calls 'flisseq', which reads as many characters
as will constitute a valid 'seq' and returns the result. This is needed for
things like
  for (i=1,n,blah); \\ lisseq is called with argument  "blah);"
In order to trigger the expected error with the current parser, I would have
to move eval() to anal.c and have it include a copy of lisseq0. Don't really
want to do it. Other solution: parse eval's argument before calling the
interpreter (which will reparse it) --> slowdown; not good.
A decent solution is to switch to GP2C's parser. Later...
Cheers,
    Karim.
-- 
Karim Belabas                    Tel: (+33) (0)1 69 15 57 48
Dép. de Mathématiques, Bât. 425  Fax: (+33) (0)1 69 15 60 19
Université Paris-Sud             Email: Karim.Belabas@math.u-psud.fr
F-91405 Orsay (France)           http://www.math.u-psud.fr/~belabas/
--
PARI/GP Home Page: http://www.parigp-home.de/