[antlr-interest] ANTLR 3: Clueless about DFA prediction

Oliver Zeigermann oliver.zeigermann at gmail.com
Tue Sep 20 09:05:26 PDT 2005


I simply do not understand the DFA based predicion for this very
simple lexer grammar:

TEXT : (~'<')+ ;
TAG : (~'>')+ ;

I have attached the generated DFA as a GIF which reads like the TAG
rule is predicated if *anywhere in the future input* there is an '<'
to be found. This certainly was not my intention...

Reading

http://www.antlr.org/blog/antlr3/lookahead.tml

(and actually understand most bits, but not all) and looking at the
NFAs (also attached) for each rule I simply do not understand why the
DFA looks the way it does.

Can anyone explain?

Thanks in advance

Oliver
-------------- next part --------------
A non-text attachment was scrubbed...
Name: XMLLexer_dec-3.gif
Type: image/gif
Size: 3643 bytes
Desc: not available
Url : http://www.antlr.org/pipermail/antlr-interest/attachments/20050920/12703684/XMLLexer_dec-3.gif
-------------- next part --------------
A non-text attachment was scrubbed...
Name: TAG.gif
Type: image/gif
Size: 3857 bytes
Desc: not available
Url : http://www.antlr.org/pipermail/antlr-interest/attachments/20050920/12703684/TAG.gif
-------------- next part --------------
A non-text attachment was scrubbed...
Name: TEXT.gif
Type: image/gif
Size: 3736 bytes
Desc: not available
Url : http://www.antlr.org/pipermail/antlr-interest/attachments/20050920/12703684/TEXT.gif


More information about the antlr-interest mailing list