|
| 1 | +EBNF2railroad example |
| 2 | + |
| 3 | + |
| 4 | + |
| 5 | + |
| 6 | + |
| 7 | + |
| 8 | +(* |
| 9 | + |
| 10 | + Welcome to EBNF 2 Railroad |
| 11 | + ========================== |
| 12 | + |
| 13 | + In this editor you can try out the command line tool. |
| 14 | + |
| 15 | + Comments will be rendered throught markdown, |
| 16 | + so you can do **markup** in them. |
| 17 | + |
| 18 | + `Ctrl-Shift-C`/`Cmd-Shift-C` will expand the selected |
| 19 | + string in `terminal` elements for each character, |
| 20 | + as a choice element. |
| 21 | + |
| 22 | + ``` |
| 23 | + digit = 1234567890; |
| 24 | + ``` |
| 25 | + |
| 26 | + selecting the numbers and pressing `Ctrl-Shift-C` / |
| 27 | + `Cmd-Shift-C` |
| 28 | + |
| 29 | + will expand this into: |
| 30 | + |
| 31 | + ``` |
| 32 | + digit = "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | "0"; |
| 33 | + ``` |
| 34 | + |
| 35 | + The EBNF syntax is as follows: |
| 36 | + |
| 37 | +*) |
| 38 | + |
| 39 | + |
| 40 | + |
| 41 | +grammar = { rule } ; |
| 42 | +rule = lhs , "=" , rhs , ";" ; |
| 43 | + |
| 44 | +lhs = identifier ; |
| 45 | +rhs = identifier |
| 46 | + | terminal |
| 47 | + | "[" , rhs , "]" |
| 48 | + | "{" , rhs , "}" |
| 49 | + | "(" , rhs , ")" |
| 50 | + | rhs , "|" , rhs |
| 51 | + | rhs , "," , rhs ; |
| 52 | + |
| 53 | +identifier = letter , { letter | digit | "_" } ; |
| 54 | +terminal = "'" , character , { character } , "'" |
| 55 | + | '"' , character , { character } , '"' ; |
| 56 | + |
| 57 | +character = letter | digit | symbol | "_" ; |
| 58 | + |
| 59 | +(* |
| 60 | + Basic components |
| 61 | + ---------------- |
| 62 | + These are low level components, the small building blocks. |
| 63 | +*) |
| 64 | + |
| 65 | + |
| 66 | +letter = "A" | "B" | "C" | "D" | "E" | "F" | "G" |
| 67 | + | "H" | "I" | "J" | "K" | "L" | "M" | "N" |
| 68 | + | "O" | "P" | "Q" | "R" | "S" | "T" | "U" |
| 69 | + | "V" | "W" | "X" | "Y" | "Z" | "a" | "b" |
| 70 | + | "c" | "d" | "e" | "f" | "g" | "h" | "i" |
| 71 | + | "j" | "k" | "l" | "m" | "n" | "o" | "p" |
| 72 | + | "q" | "r" | "s" | "t" | "u" | "v" | "w" |
| 73 | + | "x" | "y" | "z" ; |
| 74 | + |
| 75 | +digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" ; |
| 76 | + |
| 77 | +symbol = "[" | "]" | "{" | "}" | "(" | ")" | "<" | ">" |
| 78 | + | "'" | '"' | "=" | "|" | "." | "," | ";" ; |
| 79 | + |
| 80 | + |
| 81 | + |
0 commit comments