Numeric methods again

Martin von Loewis loewis at informatik.hu-berlin.de
Wed Jul 25 13:55:27 EDT 2001


"Magnus Lie Hetland" <mlh at idi.ntnu.no> writes:

> in front of the reference dot... For a simple parser
> it might be difficult to know whether 5. was a float
> or the beginning of a reference, but with a bit of
> lookahead that can't be too hard? 

If you want to allow "5.foo", you certainly also need to allow
"5. foo", as you can also write "a. foo". So it requires arbitrary
look-ahead.

> Is there any way that 5._ is not the beginning of a reference to a
> numeric method?

No, I don't think this is possible.

> Can a number ever be directly followed by an identifier?

Yes, certainly: "5.e17" could be either 5*10**17, or the e17 attribute
of 5.

> Is the parser to weak to parse this stuff?

Definitely yes, although it might be possible to improve it. I'm sure
contributions are welcome.

Regards,
Martin




More information about the Python-list mailing list