[antlr-interest] Fwd: How to interpret the text DFA

Eric researcher0x00 at gmail.com
Thu Nov 10 11:08:24 PST 2011


---------- Forwarded message ----------
From: Eric <researcher0x00 at gmail.com>
Date: Thu, Nov 10, 2011 at 2:04 PM
Subject: Re: [antlr-interest] How to interpret the text DFA
To: yushang <yusunn at gmail.com>




On Thu, Nov 10, 2011 at 12:50 PM, yushang <yusunn at gmail.com> wrote:

> Hi , everyone,
> I'm testing the following grammar
>
> INT
>    :    ('0'..'9')+
>    ;
> FLOAT
>    :    ('0'..'9')* '.' INT
>    ;
> and get the follwing DFAs
> DFA d=1
> .s0-'0'..'9'->:s2=>1
> .s0-<EOT>->:s1=>2
>
> DFA d=2
> .s0-'.'->:s2=>2
> .s0-'0'..'9'->:s1=>1
>
> DFA d=3
> .s0-'.'->:s3=>2
> .s0-'0'..'9'->.s1
> .s1-'.'->:s3=>2
> .s1-'0'..'9'->.s1
> .s1-<EOT>->:s2=>1
> from the lexer code , I can just assemble the last one (d=3) what's purpose
> of the former 2? Many thanks.
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe:
> http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>

If you use ANTLRWorks on your grammar you will see that by using menu
Grammar -> Show Show Tokens DFA you will get DFA d=3.

Then using the menu Grammar -> Highlight Decision DFA you will see two
boxes in the grammar.
If you then click on one of the boxes you should get a triangle icon, click
on the triangle icon, and select Show Decision DFA.
You should now see the one of the other diagrams.

Your unknown DFAs are decision points a.k.a. prediction DFAs.

Eric








See:
http://www.antlr.org/wiki/display/CS652/LL+Parsing+and+recursive+descent+design+pattern


More information about the antlr-interest mailing list