[antlr-interest] Lexer Rules How to
maxgbr at hotmail.it
maxgbr at hotmail.it
Mon Aug 23 14:01:00 PDT 2010
Hi, i'm a newbie of Antrl and i have some trouble with the lexer rule.
I want to create a very semplified Oracle syntax parser to get only few informations out of the sql's and i run into this issue [NoViableAltException]in ANTRLWorks when i try to debug this rules:
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
;
priv_obj
: IDENTIFIER // SELECT
| IDENTIFIER IDENTIFIER // CREATE SESSION
| 'ALL' 'PRIVILEGES'?
LPAREN IDENTIFIER (COMMA IDENTIFIER)* RPAREN
;
priv_sys
: IDENTIFIER+
| 'ALL' 'PRIVILEGES'
;
grant_system_privilege
: privilege[true] (COMMA privilege[true])*
grantee_clause ('IDENTIFIED' 'BY' .+)? ('WITH' 'ADMIN' 'OPTION')?
;
grantee_clause
: 'TO' (IDENTIFIER
| 'PUBLIC'
) (COMMA (IDENTIFIER | 'PUBLIC'))*
;
system_privilege
: IDENTIFIER
;
IDENTIFIER
: LETTER (LETTER | DIGIT | '_' )*
;
with this sql -> GRANT UPDATE , SELECT ON emp_view TO PUBLIC; <- throw NoViableAltException
but with this sql -> GRANT update, SELECTON emp_view TO PUBLIC; <- all goes fine.
i have a token definition for UPDATE like
tokens {
UPDATE = 'UPDATE';
}
but the update token is used in another rule [update_statement], not in this one.
I cannot figure out why the UPDATE token make my grant priv_obj rule to throw that exception.
How can i solve this problem??
Sorry for my bad english..
Thanks Max
More information about the antlr-interest
mailing list