jacquev6 / DrawGrammar

Draw railroad diagrams of EBNF grammars. In browser and on command line
http://jacquev6.github.io/DrawGrammar
56 stars 6 forks source link

Affichage définition composant #2

Closed Fourchaux closed 6 years ago

Fourchaux commented 6 years ago

Petite question:

dans les diagrammes, au lieu du nom d'un composant (ex: 'digit'), peut-on choisir d'afficher sa définition originale (ex: '0' ... '9') ?

jacquev6 commented 6 years ago

Translation for non-French speakers:

Small question:

In diagrams, instead of the name of a component (i.e.: 'digit'), can we display its original definition (i.e.: '0' ... '9')?

This seems like a good idea. I've not implemented anything like this, though. It would require either some sort of configuration to choose which components to inline or some sort of annotation in the grammar.

jacquev6 commented 6 years ago

I'm working on it right now. I'm probably going to add a --inline rule_name command line option and check boxes in the demo.

jacquev6 commented 6 years ago

This was a good idea! Inlining some definitions sometimes produces diagrams easier to read. Thanks!

Interactive demo: there is a new section in the "Settings" tab.

Command line: if you want to try it before I publish it to OPAM, you can:

opam pin add General https://github.com/jacquev6/General.git
opam pin add DrawGrammar https://github.com/jacquev6/DrawGrammar.git

Please let me know if you find anything strange.

Fourchaux commented 6 years ago

( NOTE : $ opam install DrawGrammar is working. )

(With opam v2.0.0~beta3 - OCaml 4.05.0+flambda - Linux x86_64)

opam pin add General : OK

opam pin add DrawGrammar : ERROR. Damn ....

... =-=- Processing actions -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= [ERROR] The compilation of DrawGrammar failed at "sh -c cd src; ocamlbuild -use-ocamlfind -no-plugin -menhir \"menhir --table\" draw_grammar.native".

=== ERROR while compiling DrawGrammar.0.1.0 ==================================

command sh -c cd src; ocamlbuild -use-ocamlfind -no-plugin -menhir "menhir --table" draw_grammar.native

path ~/.opam/4.05.0+flambda/.opam-switch/build/DrawGrammar.0.1.0

exit-code 10

env-file ~/.opam/log/DrawGrammar-3063-d2c37b.env

output-file ~/.opam/log/DrawGrammar-3063-d2c37b.out

output

[...]

ocamlfind ocamlc -c -safe-string -strict-formats -strict-sequence -package menhirLib -package cairo2 -package js_of_ocaml.ppx -package js_of_ocaml -package JsOfOCairo -package General -w @A-4-44-48 -o Parse.cmo Parse.ml

ocamlfind ocamlc -c -safe-string -strict-formats -strict-sequence -package menhirLib -package cairo2 -package js_of_ocaml.ppx -package js_of_ocaml -package JsOfOCairo -package General -w @A-4-44-48 -o draw_grammar.cmo draw_grammar.ml

ocamlfind ocamldep -package menhirLib -package cairo2 -package js_of_ocaml.ppx -package js_of_ocaml -package JsOfOCairo -package General -modules Grammar.ml > Grammar.ml.depends

ocamlfind ocamlopt -c -safe-string -strict-formats -strict-sequence -package menhirLib -package cairo2 -package js_of_ocaml.ppx -package js_of_ocaml -package JsOfOCairo -package General -w @A-4-44-48 -o Grammar.cmx Grammar.ml

+ ocamlfind ocamlopt -c -safe-string -strict-formats -strict-sequence -package menhirLib -package cairo2 -package js_of_ocaml.ppx -package js_of_ocaml -package JsOfOCairo -package General -w @A-4-44-48 -o Grammar.cmx Grammar.ml

File "none", line 1:

Warning 58: no cmx file was found in path for module Foundations, and its interface was not compiled with -opaque

File "none", line 1:

Warning 58: no cmx file was found in path for module Testing, and its interface was not compiled with -opaque

File "Grammar.ml", line 1:

Error: Some fatal warnings were triggered (2 occurrences)

Command exited with code 2.

=-=- Error report -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ┌─ The following actions failed │ λ build DrawGrammar 0.1.0 └─ ╶─ No changes have been performed

jacquev6 commented 6 years ago

I've reproduced your issue easily on 4.05.0+flambda. Thanks for the detailed report.

I've temporarily reverted a743751d (in 4df26145). Compiling to .byte instead of .native doesn't require .cmx files. I'll investigate deeper why it works on 4.05.0 and not on 4.05.0+flambda.

You can

opam pin remove DrawGrammar
opam pin add DrawGrammar https://github.com/jacquev6/DrawGrammar.git