Perseverance paid off.
I got it.
First get the antlr string.
Then use chars to 8 but (ascii) string out of the string structure.
On Thu, 2010-12-16 at 17:00 -0800, Jeffrey Newman wrote:
> Hi,
> I'm still trying to bring up my first test parser with the C runtime.
> I'm using Qt, so I have translate from C to C++ and Qt's runtime.
>
> I have most of working, except I have not been able to get the ID
> string.
>
> Here is the grammar:
>
> grammar T;
>
> options {
> language = C;
> }
>
> @header {
> #include "../parserBindings.h"
> }
>
> @members {
> char buffer[256];
> }
>
> r : 'call' ID ';' {
> sprintf(buffer, "Invoked with: \%s", $ID.text);
> debug(buffer);
> } ;
>
> ID: 'a'..'z'+ ;
> WS: (' ' | '\n' | '\r')+ {$channel=HIDDEN;};
>
> The generated code in TParser looks like.
>
> sprintf(buffer, "Invoked with: %s", (ID1->getText(ID1)));
> debug(buffer);
>
> where debug is a simple function in my C to C++ bindings.
>
> So, how do I get a string from the grammar?
> Please direct me to an example in C.
>
>
> thanks
>
> Jeffrey
>
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe:
> http://www.antlr.org/mailman/options/antlr-interest/your-email-address
List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe:
http://www.antlr.org/mailman/options/antlr-interest/your-email-address
--
You received this message because you are subscribed to the Google Groups
"il-antlr-interest" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/il-antlr-interest?hl=en.