Ilya Zakharevich on Sat, 14 Dec 2002 16:38:36 -0800


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: gp: eval(Str("A"(-1)"B"))


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...

Ilya