[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[gmt-dev] JavaCC for textual DSLs and integration with code generator

Hi again,

some more technical content ... :-)

I (as well as Arno (see CC), who introduced me to the idea)
have been experimenting with using JavaCC to generate
parsers for textual DSLs. Now this is nothing special yet,
parser generators that create ASTs from text have been around
for a while....

However, we have integrated the parsed AST with the
b+m code generator. Both use Java objects to represent
the AST of the parsed model (UML or textual DSL). It is
is therefore easily possible to use the same template language
to generate code from a textual DSL as can be used to
generate code from UML. The "transition" from UML
to the AST is seamless.

Useful examples of this combination include
a) definition of the "implementation" of operations in
    a DSL and generating executable code for a platform
b) declaratively defining the characteristics of a UML
    model element using some DSL (as opposed to using
    weird tagged values).

Practically, we have added the DSL text to the documentation
of the UML model element. We parse this text during the
runtime of the code generator using the parser generated by
JavaCC. We can then either use the parsed AST to control
code generation itself, or use the template language to generate
"implementation code" from the DSL.

Let me know what you think!!

Markus

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Markus Völter
mailto:voelter@xxxxxxx

voelter - ingenieurbüro für softwaretechnologie
Ziegelaecker 11, 89520 Heidenheim, Germany
Tel. +49 (0) 73 21 / 97 33 44

http://www.voelter.de
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -