[antlr-interest] Syntactic predicate Issue

Massimiliano D maxgbr at hotmail.it
Wed Aug 25 11:15:35 PDT 2010


Hi, i have some problem in generated java code form one rule like this:

grant_statement
    :    'GRANT'
    (    grant_system_privilege
    |    grant_object_privilege
    ) 
    ;

grant_object_privilege
    :    privilege[false] (COMMA privilege[false])* 'ON' on_object_clause    
        grantee_clause ('WITH' 'HIERARCHY' 'OPTION')? ('WITH' 'GRANT' 'OPTION')?    
    ;
    
privilege[boolean isSystemPriv]
    :    {isSystemPriv }? priv_sys
    |    {!isSystemPriv}? priv_obj
    ;

grant_system_privilege
    :    privilege[true] (COMMA privilege[true])*
        grantee_clause ('IDENTIFIED' 'BY' .+)? ('WITH' 'ADMIN' 'OPTION')?
    ;

grantee_clause
    :    'TO' (IDENTIFIER
    |    'PUBLIC'
    )    (COMMA (IDENTIFIER | 'PUBLIC'))*
    ;

whe i try to debug i got this error: cannot find symbol
because in 2 generated classes called DFAXXX the code looks like this:

public int specialStateTransition(int s, IntStream _input) throws NoViableAltException {
            TokenStream input = (TokenStream)_input;
            int _s = s;
            switch ( s ) {
                    case 0 : 
                        int LA97_8 = input.LA(1);

                         
                        int index97_8 = input.index();
                        input.rewind();
                        s = -1;
                        if ( (evalPredicate(isSystemPriv ,"isSystemPriv ")) ) {s = 1;}

                        else if ( (evalPredicate(!isSystemPriv,"!isSystemPriv")) ) {s = 27;}

                         
                        input.seek(index97_8);
                        if ( s>=0 ) return s;
                        break;
                    case 1 : 
                        int LA97_15 = input.LA(1);

                         
                        int index97_15 = input.index();
                        input.rewind();
                        s = -1;
                        if ( (evalPredicate(isSystemPriv ,"isSystemPriv ")) ) {s = 1;}

                        else if ( (evalPredicate(!isSystemPriv,"!isSystemPriv")) ) {s = 27;}

                         
                        input.seek(index97_15);
                        if ( s>=0 ) return s;
                        break;
                    case 2 : 
                       ........................
                       ........................
                       .......................
            }
            if (state.backtracking>0) {state.failed=true; return -1;}
            NoViableAltException nvae =
                new NoViableAltException(getDescription(), 97, _s, input);
            error(nvae);
            throw nvae;
        }
    }

but obviusly the isSystemPriv variable is not defined, am i missing something??

Thanks Max.
 		 	   		  


More information about the antlr-interest mailing list