-
Notifications
You must be signed in to change notification settings - Fork 3
/
spec.txt
executable file
·64 lines (54 loc) · 1.71 KB
/
spec.txt
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
pattern -> spaces "(" spaces "?<" spaces name spaces ">" spaces expr spaces ")" spaces
| spaces expr spaces
name -> [a-zA-Z_0-9]+
expr -> "{" spaces "}"
| "{" spaces pair spaces (',' spaces pair)* spaces "}"
| "[" spaces "]"
| "[" spaces "*" spaces "]"
| "[" spaces span spaces "]"
| "[" spaces span spaces "," spaces "*" spaces "]"
| "[" spaces span spaces "," spaces tail
| "[" spaces tail
| "<" spaces ">"
| "<" spaces (pattern spaces (',' spaces pattern)*)? spaces ">" ("/g")?
| "<!" spaces (pattern spaces (',' spaces pattern)*)? spaces "!>" ("/g")?
| "_"
| "true"
| "false"
| "null"
| number
| string
| regex
| "(" spaces "!<" spaces name spaces ">" spaces type spaces ")"
pair -> string spaces ":" spaces pattern
| string spaces ":" spaces "_"
| "_" spaces ":" spaces pattern
span -> pattern (spaces "," spaces pattern)*
tail -> span_find (spaces "," spaces span_find)* spaces ("," spaces "*" spaces)? "]"
span_find -> "*" spaces "," spaces span
number -> integer decimal frac
| integer decimal
| integer frac
| integer
integer -> [+-]? digit+
decimal -> "." digit+
frac -> [+-]? [eE] digit+
regex -> "#" spaces string
string -> "\"" char* "\""
type -> "string"
| "number"
| "boolean"
| "regex"
char -> "\\u" hexa hexa hexa hexa
| "\\n"
| "\\r"
| "\\t"
| "\\b"
| "\\f"
| "\\s"
| "\\\\"
| "\\\""
| !("\"" | "\\") valid_cp
valid_cp -> .
spaces -> space*
space -> [ \n\r\t]