[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: parser : which library ?
- From: Wesley Smith <wesley.hoke@...>
- Date: Mon, 30 May 2011 21:54:34 -0700
> To get line numbers with lpeg I just make a backcapture to count the
> line number, and a pattern for line ending:
Another approach is to use a match-time capture on a pattern that only
gets triggered when there's a parsing error and then use the character
index that's passed in to calculate the line number. Since there's a
possibility of line-spanning tokens like with multi-line strings or
comments, seems this might be a more robust technique. Also it saves
the cost of counting line numbers (which is admittedly trivial) until
there's actually a need.
wes