[antlr-interest] rough idea of exceptions vs no-exceptions backtracking in v3

Terence Parr parrt at cs.usfca.edu
Tue Jan 3 16:46:28 PST 2006


On Jan 3, 2006, at 4:44 PM, Sohail Somani wrote:

> On Tue, 2006-01-03 at 16:21 -0800, Terence Parr wrote:
>> howdy,
>>
>> I am doing some fuzzy parsing in the lexer using v3.  The basic trick
>> of "try to match and if you fail, throw an exception, skip a char and
>> retry" works.  It's pretty slow though it turns out.  The exceptions
>> per char kill you.  I then tried backtracking using the non-exception
>> mechanism in v3 and it's like 5x faster :)
>>
>> Heh heh heh...thanks to all of you that badgered me into trying to
>> build backtracking w/o exceptions. :)
>
> I'm glad you took the time to do this. That being said, its not as if
> this result was at all unexpected :)

Tough crowd! ;)  Actually, this has a HUGE number of exceptions (like  
on each of 80% of the chars in a file).  For a regular parser, not  
sure what the ratio would be... ;)  Big win here though.

Ter


More information about the antlr-interest mailing list