[antlr-interest] getting data from a grammar
Micha
micha-1 at fantasymail.de
Mon May 4 12:21:31 PDT 2009
On Monday 04 May 2009 21:08:50 Brian Nelson wrote:
> The input would be "aa, bb, cc" and I simply want a list of
> ['aa','bb','cc']. I am not trying to process it, just get the list out
> of it, ignoring the commas, in a variable I can use.
>
> prog : rone (COMMA rone)*
> ;
>
> rone : IDENT;
>
> IDENT: 'a'..'z' ('a'..'z')*;
> COMMA: ',';
>
for this I would do (in java):
String idents[] = text.split(",");
then, if needed:
for (String s: idents) {
if (!s.matches("[a..z]([a..z])*")) throw new Argh();
}
cheers
Michael
More information about the antlr-interest
mailing list