All Projects → matthijsgroen → ebnf2railroad

matthijsgroen / ebnf2railroad

Licence: MIT license
Create beautiful documentation for EBNF

Programming Languages

javascript
184084 projects - #8 most used programming language
Yacc
648 projects
shell
77523 projects

Projects that are alternatives of or similar to ebnf2railroad

dropincc.java
A small and easy to use parser generator. Specify your grammar in pure java and compile dynamically. Especially suitable for DSL creation in java.
Stars: ✭ 90 (+150%)
Mutual labels:  ebnf
Participle
A parser library for Go
Stars: ✭ 2,302 (+6294.44%)
Mutual labels:  ebnf
Covfefe
A parser for nondeterministic context free languages
Stars: ✭ 49 (+36.11%)
Mutual labels:  ebnf
YaccConstructor
Platform for parser generators and other grammarware research and development. GLL, RNGLR, graph parsing algorithms, and many others are included.
Stars: ✭ 36 (+0%)
Mutual labels:  ebnf
ebnf
EBNF parser and generic parser generator for Ruby.
Stars: ✭ 101 (+180.56%)
Mutual labels:  ebnf
human-parser-generator
A straightforward recursive descent Parser Generator with a focus on "human" code generation and ease of use.
Stars: ✭ 27 (-25%)
Mutual labels:  ebnf
nimly
Lexer Generator and Parser Generator as a Library in Nim.
Stars: ✭ 113 (+213.89%)
Mutual labels:  ebnf
RBNF
This project's lifetime has ended. The successor is https://github.com/thautwarm/frontend-for-free which is WIP. You can check lark-parser project which is a good alt.
Stars: ✭ 39 (+8.33%)
Mutual labels:  ebnf
language-grammars
Syntax highlighting for ABNF/BNF/EBNF, Yacc, and other language-related languages.
Stars: ✭ 14 (-61.11%)
Mutual labels:  ebnf

EBNF 2 RailRoad

npm code style: prettier license

A command line tool to create great documentation including railroad diagrams based on the ISO/IEC 14977 specification

Features

  • Creates optimized visual syntax diagrams based on the EBNF syntax
  • Quick navigation using references of used declarations
  • Nice comment markup using markdown
  • Validates if document is complete and has no duplicate declarations
  • Shows pretty printed text syntax in the document
  • Pretty printing of the sourcefile
  • Table of contents indicating root elements, character sets, common elements and recursion
  • Generation of large overview diagrams for root elements

Installation

npm install -g ebnf2railroad

Usage from command line

Usage: ebnf2railroad [options] <file>

Converts an ISO/IEC 14977 EBNF file to a HTML/Markdown file with SVG railroad diagrams

Options:

  -V, --version          output the version number
  -q, --quiet            suppress output to STDOUT
  -o, --target [target]  output the file to target destination.
  --no-target            skip writing output HTML
  -t, --title [title]    title to use for HTML document
  --lint                 exit with status code 2 if EBNF document has warnings
  --write-style          rewrites the source document with styled text
  --no-optimizations     does not try to optimize the diagrams
  --no-overview-diagram  skip creating overview diagrams for root elements
  --no-diagram-wrap      does not wrap diagrams for width minimization
  --no-text-formatting   does not format the output text version (becomes single line)
  --dump-ast             dump EBNF file AST to target destination for further processing
  --read-ast             input file is in the AST format
  -h, --help             output usage information

Examples

To generate HTML documentation of the EBNF file:

ebnf2railroad --title 'My Title' inputfile.ebnf -o outputfile.html

To only verify the EBNF file:

ebnf2railroad --lint inputfile.ebnf --no-target

To prettify the source EBNF file:

ebnf2railroad --write-style inputfile.ebnf --no-target

Online examples

Check the examples folder for an example input file and the generated result page.

  • EBNF ebnf2railroad examples/ebnf.ebnf --title EBNF View online
  • JSON ebnf2railroad examples/json.ebnf --title JSON View online

Usage as module

const { parseEbnf, createDocumentation } = require("ebnf2railroad");

const ebnf = "definition = 'a', other, { other } | item, 'b';";
const ast = parseEbnf(ebnf); // can throw parse error exceptions
const htmlOutput = createDocumentation(ast);

Licence

The code is licensed under MIT (see LICENSE file).

Contributing

Thanks for your interest in contributing! There are many ways to contribute to this project. Get started here

Acknowledgements

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].