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.svg --style Json

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.svg:

SYNTAX.svg