[antlr-interest] Error in predicate logic

Dr. Hartmut Kocher hwk.cortex-brainware at t-online.de
Wed Feb 14 15:18:52 PST 2007


And BTW: It doesn't compile either as LA3_3 is never set in the code below.

Hartmut

.

 

The code excerpt shows that for 'aab' the result is simply set without
checking the predicate first. 'aab' does not check for a following digit,
but accepts any character.

 

Note this only happens if the tokens are a subset of each other, e.g. 'aa"
and 'aab', which also starts with 'aa'. 

 

// Simple.g:28:5: ( ( AA DIGIT )=> AA | ( AAB DIGIT )=> AAB |
('a'..'z'|'A'..'Z') ( ('a'..'z'|'A'..'Z'|'_'|'0'..'9'))+ )

            int alt3=3;

            int LA3_0 = input.LA(1);

            if ( (LA3_0=='a') ) {

                int LA3_1 = input.LA(2);

                if ( (LA3_1=='a') ) {

                    if ( (LA3_3=='b') ) {

                        alt3=2;        // a predicate function should be
called here!!!

                    }

                    else if ( (synpred1()) ) {

                        alt3=1;

                    }

                    else if ( (true) ) {

                        alt3=3;

                    }

 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20070215/381f96df/attachment-0001.html 


More information about the antlr-interest mailing list