DrawGrammar: syntax diagrams of the OCaml language

announce

#1

Hello all,

I’m happy to announce that DrawGrammar is now available on OPAM.

DrawGrammar is a tool to draw… railroad diagrams of EBNF grammars.

It can now draw syntax diagrams directly from the .etex files of the OCaml manual, generating images like:

$ draw_grammar --syntax ocaml-etex-ebnf types.etex 
Drawing types.etex (as ocaml-etex-ebnf) to types.etex.png

You can find more examples in the “Examples” tab of the interactive demo.

If the community feels like these diagrams would be a valuable addition to the OCaml manual, I’m willing to help integrating them there.


#2

This is cool but struggles with the same problem that the OCaml manual has: somehow the language is split into a regular part and extensions such that you can’t really know what is where. For example, the constructs below are part of the extension but you would would expect literals to be defined as part of the lexical structure.


#3

Starting from 4.06, the language reference part of the manual will have forwards references to related extensions right below each language construct. I hope that this will help at least a little with discovering extensions.

There is also a slow ongoing work to move relatively stable extension to the main part of the manual.


#4

I have an error with the interactive example :frowning: .


#5

Thank you for the feedback!

I’ve just re-tried all examples and I’ve not been able to reproduce your issue :-/ Which example is not working for you? Without the text of the grammar in your screen-shot, it’s impossible to investigate further. With more information I’ll be happy to help!


#6

Yep, errors exist but only with the Grammar tab
(not with Settings nor Examples)


#7

Can you please provide more details? I’m willing to investigate if someone gives me a detailed (click-by-click?) description of how to reproduce the issue.


#8

Maybe I have understood. Maybe it’s the way I was reporting user errors (lexing and parsing errors during analysis of the grammar). Maybe I was not explicit enough about it being a user error. I’ve pushed a change to make it hopefully clearer.

@spop, @dinosaure, did you modify the “Grammar” field to get the error? Is it possible you introduced a syntax error?

Thank you for your time.


#9

Yes, it’s not an explicit user error, my bad :slight_smile: - I use vimperator and switching between tabs added (by mishandling) a wrong character in the Grammar field …


#10

OK, I’m glad your issue is understood. I’m working right now on my Menhir messages file to provide better parsing error messages.