On Tue, Apr 08, 2008 at 08:40:05AM -0700, Gre7g Luterman wrote:
> 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.
This patch is really helpful, many thanks!
First, the performance penalty is very low, about 1% for me.
Second, the position of the error is now located much more
accurate. Not 100% exact in my tests, but I can live with that.
Third, with the numeric position, one can calculate the line
number in a larger input file and print out the suspicious
line(s). A convenience function for this would be nice in
pyparsing, but maybe this is too application specific.
> 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:
The patch is so small, that I applied it manually, not with the
patch tool. No problem.
That said, I suggest that this should be a standard feature of
pyparsing. Many users would welcome it, I'm sure.