[antlr-interest] stringtemplate & tree walkers

alexander antlr at systemstart.net
Wed Jul 8 07:50:21 PDT 2009


sorry to bother again ...

i downloaded antlr's sources and a
grep -r "output \?= \?template" `find -name *.g*`

to find any grammars with output=template results in one reference, 
which is commented out:
./tool/src/main/antlr/org/antlr/grammar/v3/ActionTranslator.g:  // 
output=template;  TODO: can we make tokens return templates somehow?

Terence Parr schrieb:
> also codegen.g
do you mean
tool/src/main/antlr2/org/antlr/grammar/v2/codegen.g ?

there is no output using the -> operator :(

however, i was able to get things started(jihaaa).

now i'm looking for a nice solution for something like this:
somerule
     : a=something (b=maybe)?
         -> sometemplate(a={$a.st}, b={$b.st})
     ;
here the b is optional, if it's not there b.st will raise a npe.

should i surround this with if-then? or is there a simpler solution?

thanks in advance.

alexander

> On Jul 6, 2009, at 3:22 PM, Terence Parr wrote:
> 
>> well, sure. :)  Here's a better pointer: grep for
>> StringTemplateGroup.  Should be in key places and in
>> CodeGenerator.java :)
>> Ter
>> On Jul 6, 2009, at 4:47 AM, alexander wrote:
>>
>>> hi.
>>>
>>>> On Jun 16, 2009, at 9:59 AM, Arnulf Heller wrote:
>>>
>>>>> hi there,
>>>>>
>>>>> are there any complex examples of tree walkers emitting
>>>>> stringtemplates?
>>>
>>>> The source of antlr itself :)
>>>
>>>> Ter
>>>
>>> can you give a more detailed location for this? my lazyness prevents
>>> me
>>> from reading *all* the sources of antlr ;)
>>>
>>> i want to emit an xml-dialect from a tree-walker/grammar and i can't
>>> find a good start.
>>>
>>> thanks in advance
>>>
>>> alexander
>>>
>>>
>>> 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
> 
> 



More information about the antlr-interest mailing list