[antlr-interest] newbie request for help
Kenny Leung
kenny_leung at pobox.com
Fri Dec 5 07:10:12 PST 2008
On Dec 5, 2008, at 3:30 AM, Gavin Lambert wrote:
> At 19:46 5/12/2008, Kenny Leung wrote:
> >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.
>
> Nope, you don't :) Just treat it as one bigger token at the lexer
> level, and then split it up at the parser level when creating the
> AST or output. Much simpler.
That feels rather hacky and unsatisfying. I wanted to used antlr so I
wouldn't feel hacky and unsatisfying. Anyway, I don't think that would
work, since the left part is a normal C identifier, which would look
something like
('a'..'z'|'A'..'Z'|'_')('a'..'z'|'A'..'Z'|'0'..'9'|'_')*;
and the right part is composed of characters in the set
c, i, s, l, q, C, I, S, L, Q, f, d, B, v, *, @, #, : ?
Thanks!
-Kenny
More information about the antlr-interest
mailing list