[antlr-interest] newbie request for help

Kenny Leung kenny_leung at pobox.com
Thu Dec 4 22:46:10 PST 2008


Hi All.

I thought I would get my feet wet by writing a parser for Objective-C  
type encodings. I thought it would be pretty easy for such a brief  
"language", but it is turning out to be pretty difficult.

One of the problems lies in parsing something like this:

     {vids=^vids}

which means a struct named "vids", which is composed of void * (^v),  
int, double, and short.

After the "{", I need to interpret vids as a single token, and after  
the "=", I need to interpret the characters as separate tokens.

One of the interesting things I found was that this is legal:

     NUMBER : '0'..'9';

but this is not:

     number : '0'..'9';

I bumped into this because I thought I'd "inline" the rule for the  
name after the "{". Can someone explain this?

Is there a way I can say, "use tokenizer rule A after the "{", but use  
tokenizer rule B after the "=".

AntlrWorks has been great for learning by playing. Thanks for any help!

-Kenny



More information about the antlr-interest mailing list