hello,

is it possible to access sub tokens of lexer from a rule ? (sorry for
stupid naming) at the bottom is part of my grammar. i want to re-write
primary rule something like:

primary :       
        a=ABILITY -> ABILITY<ReqNode.A>[$a.scope, $a.id, ($a.INTEGER | 
$a.FLOAT)? ]
        | LPAREN! expression RPAREN!
        ;

of course i can parse ability in ReqNode.A constructor for my needs
but ability is already parsed by lexer so using it seems wiser. but
how ?

i tried to make ability a rule but generated code couldnt parse my
input complaining about no viable alternative. i'm not sure why, and
also i'm not sure if making ability a rule makes sense. ie: it sounds
like a lexical rule rather than parsing rule

thanks,
hakan


primary :       
        ABILITY -> ABILITY <ReqNode.A>
        | LPAREN! expression RPAREN!
        ;
        
        
ABILITY :
        SCOPE WS? COLON WS? ID WS? (COLON WS? (INTEGER | FLOAT))?;      
        
ID      :
        ('a'..'z' | 'A'..'A') ('a'..'z' | 'A'..'A' | DIGIT | '_' )*
        ;

fragment SCOPE
        : /* only query scopes*/
        'b' /* building */
        | 'l' /* cell */
        | 't' /* slot */
        | 'c' /* city */
        | 'u' /* user */
        | 'a' /* any */
        ;

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
-~----------~----~----~----~------~----~------~--~---

Reply via email to