1

i was trying to make a readable file or image for people where show the grammar made in Xtext , i figure out how to export into XML but seem that XML file hasnt got my whole grammar inside . Is there any tool which generates a diagram with the XML file?

Aikas
  • 67
  • 2
  • 7

1 Answers1

1

The Xtext Syntax Graph view should be helpful for you.

You can open this view in Eclipse by clicking Window -> Show view -> Other... -> Xtext -> Xtext Syntax Graph. It will show a graphical representation of the Xtext grammar in the currently selected editor view.

With the save-button the diagram can be exported as a PNG image file.
There is also a blog post (with video demo) about this feature.

screenshot

Thomas Fritsch
  • 9,639
  • 33
  • 37
  • 49
  • thanks, I wonder is it possible to automate this, i.e. generate an PNG for each xtext file in the project? – Metaphox Aug 29 '17 at 13:33
  • @Metaphox I don't know how to do this. But I recommend you ask a new question about this (may be with reference to the question/answer here). Probably the Xtext experts have ideas how to achieve it. – Thomas Fritsch Aug 29 '17 at 13:46
  • 1
    @Metaphox Start by looking into the sources of package [org.eclipse.xtext.xtext.ui.graph](https://github.com/eclipse/xtext-eclipse/tree/master/org.eclipse.xtext.xtext.ui.graph/src/org/eclipse/xtext/xtext/ui/graph) and see which parts you could reuse for your purpose. – Thomas Fritsch Aug 29 '17 at 14:06