Skip to content

brokenbyte/ebnsf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

EBNSF

Extended Backus-Naur Syntax FDiagrams

Create railroad diagrams from EBNF

Usage

Usage: ebnsf [OPTIONS] <INPUT>

Arguments:
  <INPUT>  File to read EBNF spec from

Options:
  -o, --output <OUTPUT>  Where to save the rendered SVG
  -h, --help             Print help

Example

Run ebnsf ./test/bnf.ebnf -o ./doc/bnf.svg to turn

<syntax>         ::= <rule>+
<rule>           ::= <opt_whitespace> "<" <rule_name> ">" <opt_whitespace> "::=" <opt_whitespace> <group> <line_end>
<opt_whitespace> ::= " "*
<expression>     ::= <list> (<opt_whitespace> "|" <opt_whitespace> <expression>)?
<group>          ::= "(" <expression> ")" | <expression>
<line_end>       ::= <opt_whitespace> "\n"+
<list>           ::= <term> | <term> <opt_whitespace> <list>
<term>           ::= <literal> | "<" <rule_name> ">"
<literal>        ::= '"' <text> '"'
<text>           ::= <character>+
<character>      ::= <letter> | <digit>
<letter>         ::= "[A-Za-z]"
<digit>          ::= "[0-9]"
<rule_name>      ::= <letter> <rule_char>*
<rule_char>      ::= <letter> | <digit> | "_"

into bnf syntax diagram

Todo

  • support repitition specifiers and ranges (i.e. [a-z], +, *)
    • ?, +, and * now supported
    • ranges can be specified by cheating and treating them as literals, e.g. "[a-z]". first-class support for ranges without wrapping them in quotes will be added later (but they probably won't be validated).
  • support grouping
    • grouping now supported (with repitition modifiers) using parenthesis
  • support rules spanning multiple lines
  • decide on the full syntax I want to use/support for EBNF. See dwheeler.com, grammarware.net, w3.org, and cl.cam.ac.uk links below.
  • figure out if/how I want to handle bounded repitition
  • figure out if/how I want to handle negation
  • support escape characters
    • supports escaping nested quotes and backslashes
  • decide what comment syntax to use

Credit

Additional reading on EBNF syntax:

About

CLI tool like https://github.com/lukaslueg/railroad_dsl using EBNF instead of a custom DSL

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages