[antlr-interest] Generating text from models

Oliver Zeigermann oliver.zeigermann at gmail.com
Thu Dec 4 13:55:45 PST 2008


Hi Mike!

I see Xpand as a combination of a template language and tree walker.
You both specify how to walk the model and which data is emitted in
which template slot. So: Why not combining ANTLR tree grammars with
template output rules? Same thing.

But: How to create the model (=AST)?

Oliver

2008/12/4 Mike Pagel <mike at mpagel.de>:
> Hi Oliver,
>
> you are right, this is what I want to do achieve, but: I was wondering
> whether this could be done the ANTLR way, i.e. through grammars and ST
> templates, instead of using a whole different templating mechanism.
>
> One of the main reasons I am after this is that my platform is actually
> not Java but C#, for which XPAND is not available. The Microsoft
> template engine T4 from their DSL tools is still in a pretty early
> state, so... since there is ANTLR with a C# target and ST#, I was trying
> to see whether you could select model fragments declaratively through a
> grammar and then emit templates from it. Would be pretty cool I think.
>
> Of course, the model is already much like an AST so what you'd need is
> something like a tree grammar to walk the model.
>
> Best,
> Mike
>
> Oliver Zeigermann schrieb:
>> I think what you were looking for is not Xtext, but raher Xpand2:
>>
>> http://www.eclipse.org/gmt/oaw/doc/4.3/html/contents/core_reference.html#xpand_reference_introduction
>>
>> which allows you to generate code from models (there are different
>> types of models you can use). Especially, you can use EMF models based
>> on XMI exported by many UML tools.
>>
>> Xtext instead allows you to define a simple grammar and generates a
>> - meta model,
>> - parser, and
>> - graphical editor based on Eclipse RCP
>>
>> Cheers
>>
>> Oliver
>>
>> 2008/12/4 Arnulf Heller <aheller at gmx.at>:
>>
>>> Xtext is a good example of an open source tool that translates models
>>> into code using ANTLR
>>> http://wiki.eclipse.org/Xtext
>>>
>>> it's part of openArchitectureWare
>>> http://www.openarchitectureware.org/
>>>
>>> which in turn is part of topcased (I think):
>>> http://topcased.gforge.enseeiht.fr/
>>>
>>> At 00:14 04.12.2008, Mike Pagel wrote:
>>>
>>>> Hi there,
>>>>
>>>> first of all: I am pretty new to ANTLR and to this mailing list. I did
>>>> search the archive for information but could not find anything
>>>> addressing my question. If it's in there, just send the link, please...
>>>>
>>>> Now:
>>>>
>>>> I am coming from a modeling (UML-like, graphical DSLs) background, where
>>>> you typically design the abstract syntax of a language in form of a
>>>> meta-model consisting of meta-classes, their attributes and relations
>>>> among each other. I have used a number of code generators before but I
>>>> am wondering whether ANTLR can also generate code from models
>>>> (=meta-model instances). By this I mean by using grammars similar to how
>>>> ASTs are walked in a tree grammar.
>>>>
>>>> Does something like this already exist? That way you could also generate
>>>> code from business objects (POJOs) through reflection...
>>>>
>>>> Any input and direction is welcome. If this is something not
>>>> done/possible so far I might try and explore this route a bit.
>>>>
>>>> Thanks a lot,
>>>> Mike
>>>>
>>>>
>>>> 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