[antlr-interest] Translating recurring input with python target and stringtemplate
Jim Idle
jimi at temporal-wave.com
Wed Oct 22 11:11:14 PDT 2008
On Wed, 2008-10-22 at 23:07 +0530, Sharath wrote:
> Jim Idle wrote:
> > On Wed, 2008-10-22 at 20:39 +0530, Sharath MS wrote:
> >> Hi,
> >> prog: stat+;
> >>
> >> stat:
> >> p+=SYM (',' p+=SYM )*
> >> -> printfoo(symbols={$p})
> >>
> >
> > Try $p.text
> >
> >
> > Jim
> Hi Jim,
>
> I tried $p.text and on running the python script, this was the result:
> AttributeError: 'list' object has no attribute 'text'.
Doh - I answered too quickly. You are passing a List to the string
template, so in the string template you need to iterate the collection
and get the text attribute of each member, using the separator you want.
Jim
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20081022/6d1f8134/attachment.html
More information about the antlr-interest
mailing list