[antlr-interest] returning antlr w/c

ian eyberg ian at telematter.com
Wed Nov 26 12:46:42 PST 2008


Hi, I'm using antlr 3.1.1 and evaluating
it against boost::spirit and I'm having
a pretty hard time coming up with even
simple examples that work.

I have a grammar like so:
--------------------
grammar Blah
options{ language = C; }
r
returns [char *s]
:w1=ID ' ' w2=ID{ $s = "blah"; };
ID: 'a'..'z'+;
------------------------

this will return me a "blah" but I'm having
trouble figuring out howto return the value of
w1 or w2;

I thought it was w1->getText() but that doesn't
seem to work.

preferably I'd just like to pass in a struct
and tack on w1 and w2 to it

I'm using the lexer/parser that this grammar
generates in a c++ program.

can anyone point me to some resources on this?
I've already looked through the examples tarball
from the site and didn't find anything that related
to these specific questions
 
thanks,
-ian


More information about the antlr-interest mailing list