Extending grammar of code generator

8 views
Skip to first unread message

Daniel

unread,
Jun 26, 2014, 7:47:39 AM6/26/14
to spray...@googlegroups.com
Hi all,
in the Spray User Guide there is a chapter about Extending Spray's Code Generator with a plugin:  https://spray.ci.cloudbees.com/job/spray-docs-build/lastSuccessfulBuild/artifact/docs/org.eclipselabs.spray.doc.user/docs/html/SprayUserGuide.html#ExtendingSprayscodegenerator In the chapter there is described how to override templates to extend the code generation.
Is it also possible to extend the grammar (xtext-files) of Spray's Code Generator with an Eclipse plugin?

Regards,
Daniel

Jörg Reichert

unread,
Jun 26, 2014, 10:58:08 AM6/26/14
to spray...@googlegroups.com
Hi Daniel,

no there are no hooks yet in the grammar to introduce custom attributes.

What you can do is to create a new Xtext project with the wizard "Xtext project from existing ecore model" and reference one of the genmodels belonging to the grammars you want to adapt (styles.genmodel, shapes.genmodel or spray.genmodel) and copy the grammar beginning from the first rule into the newly created .xtext file. Add a generate grammar statement so you can add new constructs to the grammar. But that means you have to recreate/copy the intrastructure from the old grammar and grammar UI plug-in. And for triggering the existing generator that only works with the metamodel of the old grammar you may also have to do a model to model transformation to the old grammar/old meta model and for your custom generator you use the new generator.

As an alternative, depending on how you want to extend the existing grammar you may also consider to write a completely new grammar that just references the old grammar, so you can then on model level just e.g. reference in the file written in your new grammar elements from a the file written in the existing grammar to enrich them.

Best regards,
Joerg
--
Sie erhalten diese Nachricht, weil Sie in Google Groups E-Mails von der Gruppe "spray-user" abonniert haben.
Wenn Sie sich von dieser Gruppe abmelden und keine E-Mails mehr von dieser Gruppe erhalten möchten, senden Sie eine E-Mail an spray-users...@googlegroups.com.
Weitere Optionen finden Sie unter https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages