[antlr-interest] Visually display the DFA ANTLR generates

Geoffrey Zhu gzhu at peak6.com
Wed Jun 27 06:46:55 PDT 2007


Does anyone know how to visually display the DFA ANTLR generates?

For example, ANTLR generates the following DFA, but it is just too
difficult for me to figure out what it is doing.


    protected DFA4 dfa4 =3D new DFA4(this);
    static final String DFA4_eotS =3D
        "\2\uffff\1\6\1\uffff\1\5\2\uffff\4\5\1\14\1\uffff";
    static final String DFA4_eofS =3D
        "\15\uffff";
    static final String DFA4_minS =3D
 
"\1\50\1\uffff\2\11\1\145\2\uffff\1\154\1\145\1\143\1\164\1\141\1"+
        "\uffff";
    static final String DFA4_maxS =3D
 
"\1\172\1\uffff\2\172\1\145\2\uffff\1\154\1\145\1\143\1\164\1\172"+
        "\1\uffff";
    static final String DFA4_acceptS =3D
        "\1\uffff\1\1\3\uffff\1\4\1\2\5\uffff\1\3";
    static final String DFA4_specialS =3D
        "\15\uffff}>";
    static final String[] DFA4_transitionS =3D {
            "\1\2\70\uffff\32\1",
            "",
            "\1\3\26\uffff\1\3\100\uffff\22\5\1\4\7\5",
            "\1\3\26\uffff\1\3\100\uffff\22\5\1\4\7\5",
            "\1\7",
            "",
            "",
            "\1\10",
            "\1\11",
            "\1\12",
            "\1\13",
            "\32\5",
            ""
    };

    static final short[] DFA4_eot =3D DFA.unpackEncodedString(DFA4_eotS);
    static final short[] DFA4_eof =3D DFA.unpackEncodedString(DFA4_eofS);
    static final char[] DFA4_min =3D
DFA.unpackEncodedStringToUnsignedChars(DFA4_minS);
    static final char[] DFA4_max =3D
DFA.unpackEncodedStringToUnsignedChars(DFA4_maxS);
    static final short[] DFA4_accept =3D
DFA.unpackEncodedString(DFA4_acceptS);
    static final short[] DFA4_special =3D
DFA.unpackEncodedString(DFA4_specialS);
    static final short[][] DFA4_transition;

    static {
        int numStates =3D DFA4_transitionS.length;
        DFA4_transition =3D new short[numStates][];
        for (int i=3D0; i<numStates; i++) {
            DFA4_transition[i] =3D
DFA.unpackEncodedString(DFA4_transitionS[i]);
        }
    }

    class DFA4 extends DFA {

        public DFA4(BaseRecognizer recognizer) {
            this.recognizer =3D recognizer;
            this.decisionNumber =3D 4;
            this.eot =3D DFA4_eot;
            this.eof =3D DFA4_eof;
            this.min =3D DFA4_min;
            this.max =3D DFA4_max;
            this.accept =3D DFA4_accept;
            this.special =3D DFA4_special;
            this.transition =3D DFA4_transition;
        }
        public String getDescription() {
            return "1:1: Tokens : ( ID | LPAREN | LP_SELECT | LP_OTHER
);";
        }
    }
 

_______________________________________________________=0A=
=0A=
The  information in this email or in any file attached=0A=
hereto is intended only for the personal and confiden-=0A=
tial  use  of  the individual or entity to which it is=0A=
addressed and may contain information that is  propri-=0A=
etary  and  confidential.  If you are not the intended=0A=
recipient of this message you are hereby notified that=0A=
any  review, dissemination, distribution or copying of=0A=
this message is strictly prohibited.  This  communica-=0A=
tion  is  for information purposes only and should not=0A=
be regarded as an offer to sell or as  a  solicitation=0A=
of an offer to buy any financial product. Email trans-=0A=
mission cannot be guaranteed to be  secure  or  error-=0A=
free. P6070214


More information about the antlr-interest mailing list