[antlr-interest] ANTLR 3: Problem with static DFA class generation
Oliver Zeigermann
oliver.zeigermann at gmail.com
Mon Sep 12 03:41:45 PDT 2005
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; } ;
....
It simple makes all DFA code non static to allow full access to the
outer class' (Lexer) fields. The part that creates a single DFA per
decision and lexer like this:
class XMLLexer extends Lexer {
...
private dfa10 = new DFA10();
...
alt10 = dfa10.predict(input);
...
}
is missing, as it requires changes not only to the template.
Anyway, hopefully this is sufficient to make my point clear.
Oliver
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Java.stg.diff
Type: application/octet-stream
Size: 2116 bytes
Desc: not available
Url : http://www.antlr.org/pipermail/antlr-interest/attachments/20050912/8d856ff9/Java.stg-0001.obj
More information about the antlr-interest
mailing list