On 08/23/2010 05:01 PM, [email protected] wrote:
>
> 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
What do you expect UPDATE to match in this input? You have specified
(below) that UPDATE is the token UPDATE. If you are expecting it to be
just another IDENTIFIER, then you need to specifically allow it, via a
rule like:
identifier
: IDENTIFIER
| UPDATE
;
And then use identifier (instead of IDENTIFIER) wherever you want UPDATE
to be a valid IDENITIFIER.
BTW, this is a FAQ. Reserved words ve keywords.
> 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
>
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe:
> http://www.antlr.org/mailman/options/antlr-interest/your-email-address
--
Kevin J. Cummings
[email protected]
[email protected]
[email protected]
Registered Linux User #1232 (http://counter.li.org)
List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe:
http://www.antlr.org/mailman/options/antlr-interest/your-email-address
--
You received this message because you are subscribed to the Google Groups
"il-antlr-interest" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/il-antlr-interest?hl=en.