Generate syntax diagram(aka railroad diagram) from EBNF specification
Ruby Shell
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
bin Remove dep Guard Feb 2, 2016
exe Support PNG format Feb 29, 2016
lib Bump version to 2.1.0 Feb 29, 2016
samples Support PNG format Feb 29, 2016
spec Add more RSpec code Feb 21, 2016
.codeclimate.yml Modify RSpec configuration Feb 12, 2016
.gitignore Generate a gem skeleton Jan 4, 2016
.rspec Modify RSpec configuration Feb 11, 2016
.rubocop.yml Modify RSpec configuration Feb 12, 2016
.travis.yml Add Travis CI configuration file Jan 12, 2016
Gemfile
LICENSE.txt Generate a gem skeleton Jan 4, 2016
README.md Update README Feb 29, 2016
Rakefile Add Rubocop Jan 19, 2016
mahoujin.gemspec Update dependency Apr 15, 2016

README.md

Build Status Dependency Status Test Coverage Code Climate Gem Version License

Mahoujin

Generate syntax diagram(aka railroad diagram) from EBNF specification

Requirements

Installation

  • Use Ruby's package manager

    $ gem install mahoujin
    
  • Or from source

    $ git clone https://github.com/0x01f7/mahoujin.git
    $ cd mahoujin
    $ ./bin/setup
    $ ./bin/rake install
    

Usage

Run command:

$ mahoujin SYNTAX.ebnfspec -o SYNTAX.png

Note: the SYNTAX.ebnfspec uses EBNF which is defined in ISO/IEC 14977 to describe it's rules.

Samples - EBNF

SYNTAX.ebnfspec:

           syntax = syntax rule, {syntax rule};
      syntax rule = meta identifier, '=', definitions list, ';';
 definitions list = single definition, {'|', single definition};
single definition = term, {',', term};
             term = factor, ['-', exception];
        exception = factor;
           factor = [integer, '*'], primary;
          primary = optional sequence | repeated sequence
                  | grouped sequence | special sequence
                  | meta identifier | terminal string;
optional sequence = '[', definitions list, ']';
repeated sequence = '{', definitions list, '}';
 grouped sequence = '(', definitions list, ')';
 special sequence = '?', {character - '?'}, '?';
  meta identifier = letter, {letter | decimal digit | ? ASCII space character ?};
  terminal string = "'", character - "'", {character - "'"}, "'"
                  | '"', character - '"', {character - '"'}, '"';
          integer = decimal digit, {decimal digit};
        character = ? any character in ASCII alphabet characters ?;
    decimal digit = ? any character in ASCII number characters ?;

SYNTAX.png:

SYNTAX.png