[antlr-interest] This should be simple, but I can't find the right syntax (or is it a bug?)

Jim Idle jimi at temporal-wave.com
Fri Nov 4 09:15:48 PDT 2011


Try this and see if it makes any difference.

<vals: {<it>}; separator="\n">


Also, is the rule borg definitely returning a template?

Jim

> -----Original Message-----
> From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-
> bounces at antlr.org] On Behalf Of Voelkel, Andy
> Sent: Thursday, November 03, 2011 5:59 PM
> To: 'ANTLR interest'
> Subject: [antlr-interest] This should be simple, but I can't find the
> right syntax (or is it a bug?)
>
> Hi,
>
> I'm trying to collect all the StringTemplates created by all instances
> of one rule (borg) into a StringTemplate for a containing rule (prog).
> But I can't seem to find the right syntax:
>
> options {
>         output = template;
>         language = CSharp3;
>       tokenVocab=Tree1;
>         ASTLabelType = CommonTree;
> }
>
> public prog
> : (b+=borg)+ -> template(vals = {$b})
> <<
> { // prog
>   <vals; separator = ",">
> }
> >> ;
>
> The syntax I tried above is one many approaches I've tried - none seem
> to work. Antlr3 runs without error but the code won't compile. I hope
> the intent is clear, as it is a pretty simple example. I've looked back
> and forth in Terence's book trying to find something like this, and in
> the examples, but so far I've struck out. It seems like a very common
> thing to try to do!
>
> One strange thing is that when I look at the generated code, the list
> for b (list_b) is declared as List<CommonTree>. But Terence's books
> says is should be List<StringTemplate> when the output type is
> template. Later in the generated code, when it tries to add to the
> list, it tries to create a List<StringTemplate>, which seems right, but
> causes a compiler error. It almost seems like a bug, but I probably
> just don't understand.
>
> Can anyone help me with this?
>
> - Andy
>
> ________________________________
>
> CONFIDENTIALITY NOTICE: This e-mail transmission, and any documents,
> files or previous e-mail messages attached to it, may contain
> information that is confidential and/or legally privileged. If you are
> not the intended recipient, or a person responsible for delivering it
> to the intended recipient, please DO NOT disclose the contents to
> another person, store or copy the information in any medium, or use any
> of the information contained in or attached to this transmission for
> any purpose. If you have received this transmission in error, please
> immediately notify the sender by reply email or at
> privacy at plantronics.com, and destroy the original transmission and its
> attachments without reading or saving in any manner.
>
> For further information about Plantronics - the Company, its products,
> brands, partners, please visit our website www.plantronics.com.
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-
> email-address


More information about the antlr-interest mailing list