Generate png diagrams from Extended Backus–Naur Form (EBNF) grammars
JavaScript CoffeeScript
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
src
test
.gitignore
CREDITS
LICENCE
README.md
package.json

README.md

#EBNF Diagram

node-ebnf-diagram uses js taken from Mark Portier's EBNFDiagram jQuery plugin

This is hooked up to node-canvas to draw EBNF diagrams in node without needing the DOM.

##Installation

$ npm install ebnf-diagram

If not previously installed, you will want to install the cairo graphics library version >= 1.8.6 first using the package manager available to you, or building from source.

##Usage

ebnfDiagram = require 'ebnf-diagram'

If your ebnf is in a file:

ebnfDiagram.fromFile('./gherkin.ebnf', './gherkin.png',2000,6000)

If you already have the text:

ebnfDiagram.fromText('''"EBNF defined in itself" {

	syntax     = [ title ] "{" { production } "}" [ comment ].
	production = identifier "=" expression ( "." | ";" ) .
	expression = term { "|" term } .
	term       = factor { factor } .
	factor     = identifier
	| literal
	| "[" expression "]"
	| "(" expression ")"
	| "{" expression "}" .
	identifier = character { character } .
	title      = literal .
	comment    = literal .
	literal    = "'" character { character } "'"
	| '"' character { character } '"' .


} "EBNF is a cool syntax for describing syntaxes."
''', './ebnf.png',1000,1000)

Generates:

EBNF in EBNF