-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjsony.pgx
104 lines (86 loc) · 1.39 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
%grammar jsony
%version 0.0.1
jsony:
| seq
| map
| top_seq
| top_map
| list
node:
| map
| seq
| scalar
map:
/- '{' -/
pair*
/- '}' -/
pair:
string
/- ':'? -/
node
/- ','? -/
seq:
/- LSQUARE -/
node* %% /- ','? -/
/- RSQUARE -/
top_seq: top_seq_entry+
top_seq_entry:
/- '-' SPACE+ /
(
node* %% / (: SPACE* ',' SPACE* EOL - | SPACE+ ) /
( comment | EOL )
)
top_map:
(string /- ':' -/ node -)+
list: node* %% /- ','? -/
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
)/
# vim: sw=2: