[antlr-interest] (no subject)

Bernardo Elayda belayda at gmail.com
Thu May 31 00:16:18 PDT 2007


<mytext:{t | <t.text>}; separator=", ">
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

The syntax you suggested worked!  Now, I get the text of the tokens
separated by commas.  When I was using:
*
*>* <mytext; separator=", ">
**
*
*I was getting the following output:*
*[@2.2"2='1',<5>,1:2], [@4,4:4='2',<5>,1:4],[@6.6:='3',<5>,1:6]*
*
The syntax you suggested makes sense; You can access any of the attributes
of an array of tokens.  Still, it would be nice if the default behavior
would return an array of token text if the token attribute wasn't explicitly
specified.

thanks again!
* -Bernardo

On May 30, 2007, at 5:41 PM, Bernardo Elayda wrote:

>* Hi,
*>*
*>* I'm using Antlr 3's new stringtemplate combined feature.
*>*
*>* I'm trying to pass a list of tokens to a template, where I want the
*>* token text listed:
*>*
*>* my anltr 3 code:
*>*
*>* program myabc=MYABC mydigits+=MYNUM+ -> array2(mytext={$mydigits}) ;
*>*
*>*
*>* my template which is in a stringtempalte group file:
*>*
*>* array2(mytext) ::= <<
*>* static const u16_t fpgadata2[] = {
*>* <mytext; separator=", ">
*>* }
*>* >>
*>*
*>* The template lists all the items in the 'mydigits' list with a
*>* comma seperated but it's not listing the token text.
*
what is it listing instead?  that should be a list of tokens.  Have
you tried

<mytext:{t | <t.text>}; separator=", ">

Ter

>* I have a Java hack that gets around this.  I would really like a
*>* generic languate neutral solution.  I've looked in the Antlr book
*>* and on the Wiki but I couldn't find something that really applied.
*>*
*>* Suggestions?
*>* thx in advance!
*>* -Bernardo

*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20070531/e7b3fcd2/attachment.html 


More information about the antlr-interest mailing list