Re: [Pyparsing] better parse error reporting
Brought to you by:
ptmcg
From: Gre7g L. <haf...@ya...> - 2008-04-08 15:40:56
|
--- "W. Martin Borgert" <de...@de...> wrote: > That would be cool! I think, this is something most > pyparsing > users would welcome. How valuable sane error > reporting is, one > notices, if it's missing, such as in LaTeX. Thanks > for any help! Okay, here's a hack to try. It's not real pretty and I haven't thoroughly tested it either, but it's a good starting point, at least. First, apply the following patch to pyparsing.py. Be careful. Your line numbers may vary a bit because I've added the ternary code discussed earlier which may not be in the current release just yet: http://pastie.textmate.org/177251 Then you can test it out with this really stupid parser script: http://pastie.textmate.org/177253 As you can see, all I'm doing is recording how far the parser made it (hopefully I'm doing this at the right spot) and keeping that in a global variable that you can access later. It's a little Kludgey, but as Kludges go, it is pretty minor. HTH, Gre7g __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com |