[antlr-interest] Parsing a file

Sam Harwell sharwell at pixelminegames.com
Wed Nov 12 11:25:54 PST 2008


If you send me your grammar (directly to just me if you don't want it to
go to the list), I can probably (highly likely) let you know how to
significantly reduce the generation time. I'd only use it for profiling
the code generation process to improve this situation for future users
of the Antlr tool.

Sam

-----Original Message-----
From: antlr-interest-bounces at antlr.org
[mailto:antlr-interest-bounces at antlr.org] On Behalf Of Yuri Tijerino
Sent: Wednesday, November 12, 2008 12:56 PM
To: Gavin Lambert
Cc: antlr-interest at antlr.org
Subject: Re: [antlr-interest] Parsing a file

Thanks Gavin,

Unfortunately my grammar is about 6500 lines long and already takes 
about 1 minute to generate the lexer and parser with backtracking turned

on.  So as soon as I add the wildcard to the main loop, I get all kinds 
of  "createLookaheadDFA(Unknown Source): could not even do K=1 for 
decision..." errors during generation.

Yuri

Gavin Lambert wrote:
> At 06:49 13/11/2008, Yuri Tijerino wrote:
> >> What I really want is change the default behavior and throw
> >> away the tokens that cause the exception and continue
> >> parsing the input after those tokens as if it was a new
> >> input.  Is this even possible?
> [...]
> >Isn't this in a way what the Lexer does when trying to find
> >tokens based on EBNF rules?  How do I duplicate that behavior
> >in the parser rules so that it won't stop trying to match the
> >rest of the input when a rule partially matches something and
> >it can't recover automagically?
>
> You could try turning backtracking on, and have as your final alt 
> something that consumes a single token and then tries the standard 
> recognition again.  Something like this:
>
> start
>   :  ( somethingvalid |  somethingelse | . )* EOF
>   ;
>
>

List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe:
http://www.antlr.org/mailman/options/antlr-interest/your-email-addr
ess



More information about the antlr-interest mailing list