On Wed, 2008-10-22 at 20:39 +0530, Sharath MS wrote:

> Hi,
> 
> I'm using antlr-3.1b2 with Python as my target language along with
> stringtemplate. I'm trying to translate the following text:
> 
> a1,aa2,aa3,b1
> 
> to
> 
> a1 | aa2 | aa3 | b1
> 
> basically replacing the commas with pipes.
> 
> However, the output that I'm getting is something like this:
> 
> [EMAIL PROTECTED],0:1=u'a1',<4>,1:0] | [EMAIL PROTECTED],3:5=u'aa2',<4>,1:3] |
> [EMAIL PROTECTED],7:9=u'aa3',<4>,1:7] | [EMAIL 
> PROTECTED],11:12=u'b1',<4>,1:11]



THis looks like a text serialization of the entire token..

> 
> Seems that the list being passed to the template contains more than
> just the text. Also, I'm using the rewrite option  and a
> TokenRewriteStream as i need to add to an existing grammar. Any help
> in translating this text in this setup, would be greatly appreciated.
> Thanks!
> 
> Here is the .g, .stg and .py files for your reference:
> 
> --------------------------------------------------
> 
> Foo.g:
> 
> grammar Foo;
> options {
>   language=Python;
>   output=template;
>   rewrite = true;
> }
> 
> prog: stat+;
> 
> stat:
> p+=SYM (',' p+=SYM )*
>         -> printfoo(symbols={$p})


Try $p.text


Jim

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

List: http://www.antlr.org:8080/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org:8080/mailman/options/antlr-interest/your-email-address

Reply via email to