Skip to content

Generate png diagrams from Extended Backus–Naur Form (EBNF) grammars

License

Notifications You must be signed in to change notification settings

featurist/node-ebnf-diagram

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

#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

About

Generate png diagrams from Extended Backus–Naur Form (EBNF) grammars

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published