cdiggins / myna-parser

Myna Parsing Library
https://cdiggins.github.io/myna-parser
MIT License
79 stars 16 forks source link

Create railroad diagrams #8

Open cdiggins opened 7 years ago

cdiggins commented 7 years ago

https://github.com/dundalek/GrammKit

Hypercubed commented 6 years ago

Any thoughts on how to achieve this? Would you go through an intermediate definition?

cdiggins commented 6 years ago

@Hypercubed , sorry I missed your comment. I can generate both AST Schemas and PEG geometry definitions from a Heron grammar. An example output is here https://github.com/cdiggins/heron-language/blob/master/spec.md generated by the tool: https://github.com/cdiggins/heron-language/blob/master/tools/gen-spec.js

cdiggins commented 6 years ago

So I think that grammKit, just needs something like the PEG grammar definitions but cleaned up a bit.

Hypercubed commented 6 years ago

If I understand correctly the outputs in the heron-language repo are PEG format, while GrammKit takes PEGjs, Ohm, or EBNF. Unless you know a decent way to convert Myna grammar (or PEG) to PEGjs it might be better to process the rules directly into the intermediate format GrammKit uses (basically the output of PEGjs#parse).

This is my attempt so far: https://github.com/Hypercubed/f-flat_node/blob/master/bin/gen-spec.js#L22

It works, but not great... I'm still not sure the correct "translations" of some rules.