-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtoml.ungram
64 lines (56 loc) · 2.12 KB
/
toml.ungram
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// TOML Un-Grammar.
//
// This grammar specifies the structure of TOML's concrete syntax tree.
// It does not specify parsing rules (ambiguities, precedence, etc are out of scope).
// Tokens are processed -- contextual keywords are recognised, compound operators glued.
//
// Legend:
//
// // -- comment
// Name = -- non-terminal definition
// 'ident' -- token (terminal)
// A B -- sequence
// A | B -- alternation
// A* -- zero or more repetition
// (A (',' A)* ','?) -- repetition of node A separated by ',' and allowing a trailing comma
// (A (',' A)*) -- repetition of node A separated by ',' without a trailing comma
// A? -- zero or one repetition
// (A) -- same as A
// label:A -- suggested name for field of AST node
BareKey = '@bare_key'
BasicString = '@basic_string'
MultiLineBasicString = '@multi_line_basic_string'
LiteralString = '@literal_string'
MultiLineLiteralString = '@multi_line_literal_string'
IntegerBin = '@integer_bin'
IntegerOct = '@integer_oct'
IntegerDec = '@integer_dec'
IntegerHex = '@integer_hex'
Float = '@float'
Boolean = '@boolean'
OffsetDateTime = '@offset_date_time'
LocalDateTime = '@local_date_time'
LocalDate = '@local_date'
LocalTime = '@local_time'
// NOTE: Comma may be followed by a comment, so it is treated as a Node.
Comma = ','
Key = BareKey | BasicString | LiteralString
Keys = Key ('.' Key)*
Array = '[' values: (Value (',' Value)* ','?) ']'
InlineTable = '{' key_values: (KeyValue (',' KeyValue)* ','?) '}'
Value =
BasicString | MultiLineBasicString | LiteralString | MultiLineLiteralString
| IntegerBin | IntegerOct | IntegerDec | IntegerHex
| Float
| Boolean
| OffsetDateTime | LocalDateTime | LocalDate | LocalTime
| Array
| InlineTable
KeyValue = Keys '=' Value
Table = '[' header: Keys ']' KeyValue*
ArrayOfTables = '[[' header: Keys ']]' KeyValue*
Root = RootItem*
RootItem =
KeyValue
| Table
| ArrayOfTables