Partially done railroad.js post
This commit is contained in:
parent
a7ef5d696b
commit
e1bf32f8e2
1 changed files with 37 additions and 0 deletions
37
content/blog/2022/08/railroad-js/index.md
Normal file
37
content/blog/2022/08/railroad-js/index.md
Normal file
|
@ -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/
|
Loading…
Add table
Add a link
Reference in a new issue