forked from ingydotnet/jsony-pm
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathjsony.pgx
88 lines (71 loc) · 1.68 KB
/
jsony.pgx
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
76
77
78
79
80
81
82
83
84
85
86
87
88
%grammar jsony
%version 0.0.1
jsony:
seq | map | top_seq | top_map | list
node: map | seq | scalar
map:
~LCURLY~
pair*
~RCURLY~
pair: string /~<COLON>?~/ node /~<COMMA>?~/
seq:
~LSQUARE~
node* %% /~<COMMA>?~/
~RSQUARE~
top_seq: top_seq_entry+
top_seq_entry:
/~ <DASH> <SPACE>+ /
(
node* %% / (: <SPACE>* <COMMA> <SPACE>* <EOL> ~ | <SPACE>+ ) /
( <comment> | <EOL> )
)
top_map:
(string /~<COLON>~/ node ~)+
list: node* %% /~<COMMA>?~/
scalar: double | single | bare
string: scalar
# Interpretation of http://www.json.org/
double: /
<DOUBLE>
(
(:
<BACK> (: # Backslash escapes
[
<DOUBLE> # Double Quote
<BACK> # Back Slash
<SLASH> # Foreward Slash
b # Back Space
f # Form Feed
n # New Line
r # Carriage Return
t # Horizontal Tab
]
|
u <HEX>{4} # Unicode octet pair
)
|
[^ <DOUBLE> <CONTROLS> ] # Anything else
)*
)
<DOUBLE>
/
# TODO: Support '' as escape for single quote
single: /
<SINGLE>
([^ <SINGLE> ]*)
<SINGLE>
/
bare: /( [^ <excludes> ]* [^ <excludes> <COLON> ] )/
excludes: /
<WS>
<LCURLY><RCURLY>
<LSQUARE><RSQUARE>
<SINGLE><DOUBLE>
<COMMA>
/
ws: /(: <WS> | <comment> )/
comment: /(:
<HASH> <SPACE> <ANY>* <EOL> |
<HASH> <EOL> |
<SPACE>* <EOL>
)/