-
Notifications
You must be signed in to change notification settings - Fork 2
/
grammar.ebnf
32 lines (30 loc) · 1.4 KB
/
grammar.ebnf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
Assign ::= Identifier ":" Value
Assign_Hidden ::= Variable ":" Value
Identifier ::= PrintChar +
Variable ::= "@" Identifier
Bare_String ::= (GraphicChar | ("\" Char)) +
Quoted_String ::= '"' ([^"\] | "\" Char) * '"'
| "'" ([^'\] | "\" Char) * "'"
Comment ::= "#" GraphicChar +
Integer ::= [+-] ? ([1-9] Digit + | [0])
Hex ::= [+-] ? "0" [xX] (Digit | [a-fA-F]) +
Octal ::= [+-] ? "0" [0-7] +
Float ::= [+-]? Digit+ ("." Digit +)? ([eE] [+-] ? Digit +)?
Complex ::= ((Float | Integer) [+-])? (Float | Integer) "i"
Duration ::= [+-] ? (Digit + ("." Digit +) ("ns" | "us" | "µs" | "ms" | "s" | "m" | "h")) +
Boolean ::= "true" | "false"
Numer ::= Integer | Hex | Octal | Float
Object ::= "{" (Identifier ":" Value) + "}"
List ::= "[" Value + "]"
Value ::= String | Number | Boolean | Duration | Variable | Object | List
Heredoc ::= "<<" Identifier "\n" (Char | "\n") + "\n" "Identifier (same as opening identifier)" "\n"
Letter ::= "a Unicode letter, category L"
Mark ::= "a Unicode mark, category M"
Digit ::= [0-9]
Symbol ::= "a Unicode symbol character, category S"
Space ::= "a Unicode space character, category Z, excluding \n"
Punct ::= "a Unicode punctuation glyph, category P, excluding those described as terminal characters"
Terminal ::= "[" | "]" | ";" | ":" | "{" | "}" | "\" | "#" | "\n"
PrintChar ::= Letter | Mark | Number | Symbol | Punct
GraphicChar ::= PrintChar | Space
Char ::= GraphicChar | Terminal