[antlr-interest] getting data from a grammar
Brian Nelson
brian at neuesoftware.com
Mon May 4 12:48:37 PDT 2009
This was a small example of a much larger problem. This isn't this
simple case only, I am processing CSS files and trying to object-ize the
entire file (rules, declarations, media blocks, etc)
On 5/4/09 12:21 PM, Micha wrote:
> 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
>
>
--
Brian Nelson
Software Engineer, Neue Software
e. brian at neuesoftware.com
c. +1 408 373 8310
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20090504/e173d96b/attachment.html
More information about the antlr-interest
mailing list