How to parse over a Python expr?

Erik Max Francis max at alcyone.com
Fri Aug 30 19:41:56 EDT 2002


Stefan Franke wrote:

> I had a quick glance at the empy source. Am I going right that
> Parser.scanComplex() does that thing?

That's correct.

> That function looks if
> it could be fooled by triple-quoted strings, e.g. this one:
> ''' here's ')]" an evil "string '''
> 
> (Excuse my ignorance if this is handled elsewhere..)

Hmm, you're right.  I didn't take into account the corner case where a
triple-quoted string contains single-quoted strings.  Thanks for
catching that.  (Fortunately, it's a rare occurrence that has certainly
never happened in the field -- you'd have to do a triple-quoted string,
then a single quoted one, _then_ an unbalanced close parenthesis.)

> However, it shouldn't be a big deal to handle this case
> correctly.

Right.

> My question was more aiming at if not Python itself
> could be used for the parsing work..

I figured, but I thought I'd mention the quick-and-dirty way out first.

-- 
 Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/
 __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE
/  \ There is nothing so subject to the inconstancy of fortune as war.
\__/ Miguel de Cervantes
    Church / http://www.alcyone.com/pyos/church/
 A lambda calculus explorer in Python.



More information about the Python-list mailing list