-
Notifications
You must be signed in to change notification settings - Fork 0
/
grammar.lark
75 lines (46 loc) · 1.35 KB
/
grammar.lark
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
65
66
67
68
69
70
71
72
73
74
75
document : stream
| value
stream : "#." (value "#." value)*
value : tagged
| atom
tagged : name [attrs] atom
| "(" name attr* ")"
attrs : "(" meta_item* ")"
attr : name "=" atom
atom : object
| array
| date_time
| symbol
| number
| string
| bool
| "null"
object : "{" pair* "}"
pair : name ":" value
array : "[" value* "]"
bool : "true" | "false"
symbol : "$" name
number : NUMBER_LITERAL
| HEX_LITERAL
| OCT_LITERAL
| BIN_LITERAL
date_time : date
| TIME_FORMAT
date : DATE_FORMAT [ ("_" | "T") TIME_FORMAT TIME_OFFSET]
string : STRING_LITERAL
| BLOB_LITERAL
name : VARIABLE
| QUOTED_VARIABLE
VARIABLE : /[^\"`$:;{}\[\]=\(\)\t\r\n ,0-9]{1}[^\"`$:;{}\[\]=\(\)\t\r\n ,]*/
QUOTED_VARIABLE : /"(?:[^\\"]|\\(?:[bfnrtv"\\/]))*"/
STRING_LITERAL : /"(?:[^\\"]|\\(?:[bfnrtv"\\/]|x[0-9a-fA-F]|u[0-9a-fA-F]{4}|U[0-9a-fA-F]))*"/
BLOB_LITERAL : /`(?:[^\\`\u\U]|\\(?:[bfnrtv`\\/]|x[0-9a-fA-F]))*`/
NUMBER_LITERAL : /-?(0|[1-9]\d*)(\.\d+)?([eE][+-]?\d+)?/
HEX_LITERAL : /0x[0-9a-fA-F]{1}([0-9a-fA-F]{1}|_[0-9a-fA-F]{1})*/
OCT_LITERAL : /0o[0-8]{1}([0-8]{1}|_[0-8]{1})*/
BIN_LITERAL : /0b[01]{1}([01]{1}|_[01]{1})*/
DATE_FORMAT : /\d{4}-\d{2}-\d{2}/
TIME_FORMAT : /\d{2}:\d{2}:\d{2}(\.\d+)?/
TIME_OFFSET : /Z|[+-]\d{2}:\d{2}/
WHITESPACE : /[ \t\n\r,]+/
COMMENT : /;.*/