[antlr-interest] stringtemplate & tree walkers
Terence Parr
parrt at cs.usfca.edu
Wed Jul 8 13:32:47 PDT 2009
oh crap. ANTLR v3 uses antlr v2 for codegen.g. crud. ok, Here's one
that i'm puttinginto book. source is free at publisher's site so i
can push out; description is only in book though ;) This is totally
not cleaned up yet but it should give you some hints. It walks a C
subset AST and spits it back out as C.
Ter
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ast-st.tar
Type: application/x-tar
Size: 87557 bytes
Desc: not available
Url : http://www.antlr.org/pipermail/antlr-interest/attachments/20090708/277ac312/attachment.tar
-------------- next part --------------
On Jul 8, 2009, at 7:50 AM, alexander wrote:
> 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
>>
>>
>
>
> 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