A library to create syntax ("railroad") diagrams as Scalable Vector Graphics (SVG).
Live demo (code) Some examples using a small DSL of it's own.
Railroad diagrams are a way to represent context-free grammar. Every diagram has exactly one starting- and end-point; everything that belongs to the described language is represented by one of the possible paths between those points.
Using this library, diagrams are created using primitives which implement RailroadNode
. Primitives are combined into more complex structures by wrapping simple elements into more complex ones.
use *;
let mut seq = default;
seq.push
.push
.push
.push;
let mut dia = new;
dia.add_element;
println!;