| Karim BELABAS on Sun, 15 Dec 2002 13:35:14 +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, Ilya Zakharevich wrote:
> On Sat, Dec 14, 2002 at 09:15:47PM +0100, Karim BELABAS wrote:
> > 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.
>
> Why? Just check that analyseur is at the end of the string...
That requires either creating a modified copy of lisseq0 or adding a flag to
lisseq0 [check analyseur at end]. Because when lisseq returns, 'analyseur' is
restored... And of course, I can't check all the time because of the 'blah);'
example above.
It would just be yet another hack on top of a huge list. I'd rather wait till
the parser is replaced.
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/