[antlr-interest] ANTLR 3: Problem with static DFA class generation

Terence Parr parrt at cs.usfca.edu
Thu Sep 15 18:33:26 PDT 2005


On Sep 12, 2005, at 3:41 AM, Oliver Zeigermann wrote:

> The attached patch for Java.stg (org/antlr/codegen/templates/) will
> make the below lexer fragment work:
>
> lexer grammar XMLLexer;
> {
>    boolean tagMode = false;
> }
>
> TAG_START_OPEN : { !tagMode }? '<' { tagMode = true; } ;
> TAG_END_OPEN : { !tagMode }? "</" { tagMode = true; } ;

Your example appears right and I can't remember why I left as  
static.  I will try your trick out and run all my unit tests to see  
what happens.

I'd like the jury to note, however, that to change everything all you  
had to do was alter the templates.  No code.  Hooray!  The dream is  
alive ;)

> class XMLLexer extends Lexer {
>
> ...
>
> private dfa10 = new DFA10();
>
> ...
>
> alt10 = dfa10.predict(input);

Boy, that sure looks fine...driving me crazy wondering what I was  
thinking before!

Ter
--
CS Professor & Grad Director, University of San Francisco
Creator, ANTLR Parser Generator, http://www.antlr.org
Cofounder, http://www.jguru.com



More information about the antlr-interest mailing list