2015-01-03 20:02:27 +00:00
created: 20150103184022184
2015-01-19 22:21:22 +00:00
modified: 20150119220342000
2015-01-03 20:02:27 +00:00
title: $:/plugins/tiddlywiki/railroad/syntax
2023-03-06 16:12:26 +00:00
2015-01-19 22:21:22 +00:00
The railroad widget uses a special notation to construct the components defined below.
2015-01-03 20:02:27 +00:00
`x` and `y` here stand for any component.
2015-01-06 01:39:24 +00:00
Names (as opposed to quoted strings) are available when a value starts with a letter and contains only letters, digits, underscores, dots and hyphens.
2015-01-03 20:02:27 +00:00
---
; sequence
: <$railroad text=""" ["<-"] {x} ["->"] """/>
2023-03-06 16:12:26 +00:00
2015-01-03 20:02:27 +00:00
* A sequence of components
* The `<-` and `->` delimiters allow you to force a single component to be treated as a sequence. This is occasionally useful for spacing a diagram out
2023-03-06 16:12:26 +00:00
examples
<<<
```
x y z sequence
```
<$railroad text=""" x y z """/>
```
<-x y z-> explicit sequence
```
<$railroad text=""" <- x y z -> """/>
<<<
2015-01-03 20:02:27 +00:00
---
; optional
: <$railroad text=""" "[" [":"] x "]" """/>
* A component that can be omitted
* The colon makes `x` appear straight ahead
2023-03-06 16:12:26 +00:00
examples
<<<
```
[:x] optional, normally included
```
<$railroad text=""" [:x] """/>
```
[x] optional, normally omitted
```
<$railroad text=""" [x] """/>
<<<
2015-01-03 20:02:27 +00:00
---
; repeated
: <$railroad text=""" "{" x [:"+" y] "}" """/>
* A list of one or more `x`
* The `+` suffix adds `y` as a separator between each `x` and the next
2023-03-06 16:12:26 +00:00
examples
<<<
```
{x} one or more
```
<$railroad text=""" {x} """/>
```
{x +","} one or more, comma-separated
```
<$railroad text=""" {x +","} """/>
<<<
2015-01-03 20:02:27 +00:00
---
; optional repeated
: <$railroad text=""" "[{" [":"] x [:"+" y] "}]" """/>
* An optional list of `x`, i.e. a list of zero or more `x`
2023-03-06 16:12:26 +00:00
examples
<<<
```
[{:x}] zero or more, normally included
```
<$railroad text=""" [{:x}] """/>
```
[{:x +","}] zero or more, comma-separated, normally included
```
<$railroad text=""" [{:x +","}] """/>
```
[{x}] zero or more, normally omitted
```
<$railroad text=""" [{x}] """/>
```
[{x +","}] zero or more, comma-separated, normally omitted
```
<$railroad text=""" [{x +","}] """/>
<<<
2015-01-03 20:02:27 +00:00
---
; choice
: <$railroad text=""" "(" {[:":"] x +"|"} ")" """/>
* A set of alternatives
* The colon indicates which branch appears straight ahead. By default, it's the first branch
2023-03-06 16:12:26 +00:00
examples
<<<
```
(x|y|z) alternatives
```
<$railroad text=""" (x|y|z) """/>
```
(x|:y|z) alternatives, normally y
```
<$railroad text=""" (x|:y|z) """/>
<<<
2015-01-03 20:02:27 +00:00
---
; string / terminal
: <$railroad text={{$:/plugins/tiddlywiki/railroad/syntax-string}}/>
* A literal or terminal component
* This follows the normal ~TiddlyWiki rules for quoted strings
2023-03-06 16:12:26 +00:00
examples
<<<
```
"x" terminal
```
<$railroad text=""" "x" """/>
<<<
2015-01-03 20:02:27 +00:00
---
; nonterminal
: <$railroad text=""" (name | "<" string ">") """/>
* A nonterminal component, i.e. the name of another diagram
2023-03-06 16:12:26 +00:00
examples
<<<
```
<"x"> nonterminal
```
<$railroad text=""" <"x"> """/>
<<<
2015-01-03 20:02:27 +00:00
---
; comment
: <$railroad text=""" "/" string "/" """/>
* A comment
2023-03-06 16:12:26 +00:00
examples
<<<
```
/ "comment" / comment
```
<$railroad text=""" / "comment" / """/>
<<<
2015-01-03 20:02:27 +00:00
---
; dummy
: <$railroad text=""" "-" """/>
2015-01-06 01:39:24 +00:00
* The absence of a component
2023-03-06 16:12:26 +00:00
examples
<<<
```
- dummy
```
<$railroad text=""" - """/>
<<<
2015-01-06 01:39:24 +00:00
---
; link
: <$railroad text=""" "[[" x "|" (name|string) "]]" """/>
* A link to the tiddler title or URI given by the string or name
2023-03-06 16:12:26 +00:00
examples
<<<
```
[[x|"tiddler"]] link
```
<$railroad text=""" [[x|"tiddler"]] """/>
<<<
2015-01-06 01:39:24 +00:00
---
; transclusion
: <$railroad text=""" "{{" (name|string) "}}" """/>
* Treats the content of another tiddler as diagram syntax and transcludes it into the current diagram
2015-01-19 22:21:22 +00:00
2023-03-06 16:12:26 +00:00
examples
<<<
```
{{"$:/plugins/tiddlywiki/railroad/example-transclusion"}} transclusion
// "railroad transclusion example" text <- text in the tidlder
```
<$railroad text=""" {{ "$:/plugins/tiddlywiki/railroad/example-transclusion" }} """/>
<<<
2015-01-19 22:21:22 +00:00
---
; arrow pragma
: <$railroad text=""" "\arrow" ("yes" | "no") """/>
* Controls whether repeat paths have an arrow on them
* Can be toggled on and off in mid-diagram, if desired
2023-03-06 16:12:26 +00:00
examples
<<<
```
<$railroad text="""
\arrow yes
[{:x}]
"""/>
```
<$railroad text="""\arrow yes [{:x}] """/>
```
<$railroad text="""
\arrow no
[{:x}]
"""/>
```
<$railroad text="""\arrow no [{:x}] """/>
<<<
2015-01-19 22:21:22 +00:00
---
; debug pragma
: <$railroad text=""" "\debug" """/>
* Causes the diagram to display its parse tree
2023-03-06 16:12:26 +00:00
examples
<<<
```
\debug
x
```
<$railroad text="""\debug x """/>
<<<
2015-01-19 22:21:22 +00:00
---
; start/end pragma
: <$railroad text=""" ("\start" |: "\end") ("none" |: "single" | "double") """/>
* Controls the style of the diagram's startpoint or endpoint
2023-03-06 16:12:26 +00:00
examples
<<<
```
\start none x
```
<$railroad text=""" \start none x """/>
```
\start double
\end double
x
```
<$railroad text=""" \start double
\end double
x
"""/>
<<<