Skip to content

Commit bfb8d2b

Browse files
Update grammar railroad diagram from ChaiScript/ChaiScript
1 parent 130f68c commit bfb8d2b

2 files changed

Lines changed: 137 additions & 26 deletions

File tree

grammar/chaiscript.ebnf

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
1919
/* ---- Top-level ---- */
2020
21-
statements ::= ( def | try | if | while | class | for
22-
| switch | return | break | continue
21+
statements ::= ( def | try | if | while | class | enum
22+
| for | switch | return | break | continue
2323
| equation | block | eol )+
2424

2525
/* ---- Functions ---- */
@@ -57,6 +57,17 @@ class ::= "class" id ( ":" id )? eol* class_block
5757
class_block ::= "{" class_statements* "}"
5858
class_statements ::= def | var_decl | eol
5959

60+
/* ---- Enums ---- */
61+
62+
enum ::= "enum" ( "class" | "struct" ) id ( ":" underlying_type )?
63+
"{" enum_entries? "}"
64+
65+
enum_entries ::= enum_entry ( "," enum_entry )*
66+
67+
enum_entry ::= id ( "=" integer )?
68+
69+
underlying_type ::= id
70+
6071
/* ---- Blocks & flow keywords ---- */
6172

6273
block ::= "{" statements* "}"

0 commit comments

Comments
 (0)