--- Gre7g Luterman <hafeliel@...> wrote:
<snipped>
> Here's a short example program illustrating this:
>
> http://pastie.textmate.org/167541
Here's a more refined version of what I had in mind:
http://pastie.textmate.org/167851
This version converts EVERYTHING to objects (even
literals). Then, if the parse fails, it reparses the
last item successfully parsed, skips over any
whitespace or comments, and then finds the next
interesting bit of text.
This allows me to report...
Parse error: did not expect 'else' on line 10 (column
5)
Ideally, I'd like the parser to report that it was
hoping to find a ";" in the assignment statement, but
that would require hacking into PyParsing since I
can't guarantee the parent object has been
instantiated yet (this won't happen until all of the
required bits parse successfully).
Regardless, it's better than reporting an error on the
" 7" (the last thing parsed successfully) and far more
desirable than reporting an error on the "for"
statement, since that couldn't be parsed entirely.
Does anyone have any thoughts on this? I'll gladly
stick with what I have since it works, but if there's
a better way, I'd love to talk about it.
Thanks,
Gre7g
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
|