[antlr-interest] how to all the matched in java

Indhu Bharathi indhu.b at s7software.com
Sat Mar 21 00:32:23 PDT 2009


grammar Test;

expr : (ID {System.out.println( $ID.text );} )*
;

ID : 'a'..'z'+
;

WS : (' ' | '\t' | '\n')+ {$channel = HIDDEN;}
;


- Indhu


william yuan wrote:
> Hi ,
> problem like this ,
> i ve defined a grammar like this
> expr: ID*;
> ID:('a'..'z')*;
> and my input is
> ABC DEF
> so how can i get IDs which match to ABC and DEF both?
> i know use
> expr:ID*
> { System.out.println($ID.text)}
> to get the value which matched by ID ,but it only can get the value
> DEF ,which is the last matched ,
>
> i wanna get ALL the matched ? so ... that 's my problem ,
> Thanks
> William Vian
> ------------------------------------------------------------------------
>
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>   



More information about the antlr-interest mailing list