diff --git a/content/blog/2022/08/railroad-js/index.md b/content/blog/2022/08/railroad-js/index.md new file mode 100644 index 0000000..cdb3432 --- /dev/null +++ b/content/blog/2022/08/railroad-js/index.md @@ -0,0 +1,37 @@ +--- +title: railroad.js +slug: railroad-js +date: 2022-08-20T10:45:53-07:00 +draft: true +--- + +{{< figures/railroad id="sExpressionDiagram" >}} + return rr.Diagram( + rr.Start("simple", "s_expression"), + rr.ZeroOrMore( + rr.Choice(0, + rr.Group(rr.Sequence( + "a ... z", + rr.ZeroOrMore(rr.Choice(0, "a ... z", "1 ... 9")) + ), "atom"), + rr.Sequence( + "(", rr.OneOrMore(rr.NonTerminal("s_expression")), ")" + ), + rr.Sequence( + "(", + rr.NonTerminal("s_expression"), + ".", + rr.NonTerminal("s_expression"), + ")" + ) + ) + ) + ); +{{< /figures/railroad >}} + +I just recently integrated support for Tab Atkins' excellent [`railroad.js`][rrjs]. +It allows you to make diagrams like the one above. These are great for +describing modular architectures, control flow through programs or other complex +systems, and—as above—grammars. + +[rrjs]: http://tabatkins.github.io/railroad-diagrams/