-
Notifications
You must be signed in to change notification settings - Fork 4
/
pegex.pgx.yaml
212 lines (212 loc) · 6.05 KB
/
pegex.pgx.yaml
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
---
+grammar: pegex
+include: pegex-atoms
+toprule: grammar
+version: 0.2.0
ERROR_all_group:
.all:
- .ref: ERROR_rule_part
- +min: 0
-flat: 1
.all:
- .ref: _
- .ref: ERROR_rule_part
ERROR_any_group:
.all:
- .ref: ERROR_all_group
- +min: 1
-flat: 1
.all:
- .rgx: (?:\s|\#.*(?:\n|\z))*\|(?:\s|\#.*(?:\n|\z))*
- .ref: ERROR_all_group
ERROR_bracketed_group:
.any:
- .all:
- .rgx: (?![\-\.])(?=[^\w\(\)</\~\|`\s]\()
- .err: Illegal group rule modifier (can only use .)
- .all:
- .rgx: ([\-\.]?)\((?:\s|\#.*(?:\n|\z))*
- .ref: rule_group
- .any:
- .all:
- +asr: 1
.ref: doc_ending
- .err: Runaway rule group; no ending parens at EOF
- .all:
- .rgx: (?=(?:\s|\#.*(?:\n|\z))*\)[^\w\(\)</\~\|`\s\*\+\?!=\+\-\.:;])
- .err: Illegal character in group rule quantifier
ERROR_error_message:
.any:
- .all:
- .rgx: (?=`[^`\r\n]*[\r\n][^`]*`)
- .err: Multi-line error messages not allowed!
- .all:
- .rgx: (?=`[^`]*(?:\s|\#.*(?:\n|\z))*\z)
- .err: Runaway error message; no ending grave at EOF
ERROR_meta_definition:
.all:
- .rgx: (?=%\w+)
- .err: Illegal meta rule
ERROR_regular_expression:
.all:
- .rgx: (?=/([^/]*)(?:\s|\#.*(?:\n|\z))*\z)
- .err: Runaway regular expression; no ending slash at EOF
ERROR_rule_definition:
.all:
- .ref: ERROR_rule_start
- .ref: ERROR_rule_group
- .any:
- .ref: ending
- .err: Rule ending syntax error
ERROR_rule_group:
.any:
- .ref: ERROR_any_group
- .ref: ERROR_all_group
ERROR_rule_item:
.any:
- .ref: rule_item
- .ref: ERROR_rule_reference
- .ref: ERROR_regular_expression
- .ref: ERROR_bracketed_group
- .ref: ERROR_error_message
ERROR_rule_part:
.all:
- .ref: ERROR_rule_item
- +max: 1
+min: 0
-flat: 1
.all:
- .rgx: (?:\s|\#.*(?:\n|\z))+(%{1,2})(?:\s|\#.*(?:\n|\z))+
- .ref: ERROR_rule_item
ERROR_rule_reference:
.any:
- .all:
- .rgx: (?=[!=\+\-\.]?<(?:[a-zA-Z][a-zA-Z0-9]*(?:[\-_][a-zA-Z0-9]+)*|\-+|_+)(?=[^\w\-])(?!\>))
- .err: Missing > in rule reference
- .all:
- .rgx: (?=[!=\+\-\.]?(?:[a-zA-Z][a-zA-Z0-9]*(?:[\-_][a-zA-Z0-9]+)*|\-+|_+)(?=[^\w\-])\>)
- .err: Missing < in rule reference
- .all:
- .rgx: (?=[!=\+\-\.]?(?:(?:[a-zA-Z][a-zA-Z0-9]*(?:[\-_][a-zA-Z0-9]+)*|\-+|_+)(?=[^\w\-])|<(?:[a-zA-Z][a-zA-Z0-9]*(?:[\-_][a-zA-Z0-9]+)*|\-+|_+)(?=[^\w\-])\>)[^\w\(\)</\~\|`\s\*\+\?!=\+\-\.:;])
- .err: Illegal character in rule quantifier
- .all:
- .rgx: (?=[!=\+\-\.]?(?:[a-zA-Z][a-zA-Z0-9]*(?:[\-_][a-zA-Z0-9]+)*|\-+|_+)(?=[^\w\-])\-)
- .err: Unprotected rule name with numeric quantifier; please use <rule>#-# syntax!
- .all:
- +asr: -1
.ref: rule_modifier
- .rgx: (?=[^\w\(\)</\~\|`\s](?:(?:[a-zA-Z][a-zA-Z0-9]*(?:[\-_][a-zA-Z0-9]+)*|\-+|_+)(?=[^\w\-])|<(?:[a-zA-Z][a-zA-Z0-9]*(?:[\-_][a-zA-Z0-9]+)*|\-+|_+)(?=[^\w\-])\>)(?:[\*\+\?]|[0-9]+(?:\-[0-9]+|\+)?)?(?![\ \t]*:))
- .err: Illegal rule modifier (must be [=!.-+]?)
ERROR_rule_start:
.any:
- .rgx: ((?:[a-zA-Z][a-zA-Z0-9]*(?:[\-_][a-zA-Z0-9]+)*|\-+|_+)(?=[^\w\-]))[\ \t]*:(?:\s|\#.*(?:\n|\z))*
- .err: Rule header syntax error
_:
.rgx: (?:\s|\#.*(?:\n|\z))*
__:
.rgx: (?:\s|\#.*(?:\n|\z))+
all_group:
.all:
- .ref: rule_part
- +min: 0
.all:
- .ref: _
- .ref: rule_part
any_group:
.all:
- .rgx: (?:\s|\#.*(?:\n|\z))*\|?(?:\s|\#.*(?:\n|\z))*
- .ref: all_group
- +min: 0
.all:
- .rgx: (?:\s|\#.*(?:\n|\z))*\|(?:\s|\#.*(?:\n|\z))*
- .ref: all_group
bracketed_group:
.all:
- .rgx: ([\-\.]?)\((?:\s|\#.*(?:\n|\z))*
- .ref: rule_group
- .rgx: (?:\s|\#.*(?:\n|\z))*\)((?:[\*\+\?]|[0-9]+(?:\-[0-9]+|\+)?)?)
doc_ending:
.rgx: (?:\s|\#.*(?:\n|\z))*\z
ending:
.rgx: (?:\s|\#.*(?:\n|\z))*(?:\n(?:\s|\#.*(?:\n|\z))*;?(?:\s|\#.*(?:\n|\z))*|\#.*(?:\n|\z)(?:\s|\#.*(?:\n|\z))*;?(?:\s|\#.*(?:\n|\z))*|;(?:\s|\#.*(?:\n|\z))*|\z)
error_message:
.rgx: '`([^`\r\n]*)`'
grammar:
.all:
- .ref: meta_section
- .ref: rule_section
- .any:
- .ref: doc_ending
- .ref: ERROR_rule_definition
meta_definition:
.rgx: '%(grammar|extends|include|version)[\ \t]+[\ \t]*([^;\n]*?)[\ \t]*(?:\s|\#.*(?:\n|\z))*(?:\n(?:\s|\#.*(?:\n|\z))*;?(?:\s|\#.*(?:\n|\z))*|\#.*(?:\n|\z)(?:\s|\#.*(?:\n|\z))*;?(?:\s|\#.*(?:\n|\z))*|;(?:\s|\#.*(?:\n|\z))*|\z)'
meta_section:
+min: 0
.any:
- .ref: meta_definition
- .ref: __
- .ref: ERROR_meta_definition
quoted_regex:
.rgx: '''([^'']*)'''
regex_raw:
.rgx: (\(\??<|(?:[^\s/'<])+)
regex_rule_reference:
.rgx: (?:(?:\s|\#.*(?:\n|\z))+((?:[a-zA-Z][a-zA-Z0-9]*(?:[\-_][a-zA-Z0-9]+)*|\-+|_+)(?=[^\w\-]))|(?:<((?:[a-zA-Z][a-zA-Z0-9]*(?:[\-_][a-zA-Z0-9]+)*|\-+|_+)(?=[^\w\-]))\>))(?![\ \t]*:)
regular_expression:
.all:
- .rgx: ([\-\.]?)
- .rgx: /
- +max: 1
.ref: whitespace_start
- +min: 0
.any:
- .ref: whitespace_must
- .ref: whitespace_maybe
- .ref: quoted_regex
- .ref: regex_rule_reference
- .ref: __
- .ref: regex_raw
- .rgx: /
rule_definition:
.all:
- .ref: rule_start
- .ref: rule_group
- .ref: ending
rule_group:
.ref: any_group
rule_item:
.any:
- .ref: bracketed_group
- .ref: whitespace_token
- .ref: rule_reference
- .ref: quoted_regex
- .ref: regular_expression
- .ref: error_message
rule_modifier:
.rgx: '[!=\+\-\.]'
rule_part:
.all:
- .ref: rule_item
- +max: 1
+min: 0
-flat: 1
.all:
- .rgx: (?:\s|\#.*(?:\n|\z))+(%{1,2})(?:\s|\#.*(?:\n|\z))+
- .ref: rule_item
rule_reference:
.rgx: ([!=\+\-\.]?)(?:((?:[a-zA-Z][a-zA-Z0-9]*(?:[\-_][a-zA-Z0-9]+)*|\-+|_+)(?=[^\w\-]))|(?:<((?:[a-zA-Z][a-zA-Z0-9]*(?:[\-_][a-zA-Z0-9]+)*|\-+|_+)(?=[^\w\-]))\>))((?:[\*\+\?]|[0-9]+(?:\-[0-9]+|\+)?)?)(?![\ \t]*:)
rule_section:
+min: 0
.any:
- .ref: rule_definition
- .ref: __
rule_start:
.rgx: ((?:[a-zA-Z][a-zA-Z0-9]*(?:[\-_][a-zA-Z0-9]+)*|\-+|_+)(?=[^\w\-]))[\ \t]*:(?:\s|\#.*(?:\n|\z))*
whitespace_maybe:
.rgx: (?:\s|\#.*(?:\n|\z))*\-(?=[\ /\r\n])
whitespace_must:
.rgx: (?:\s|\#.*(?:\n|\z))+(?:\+|\-\-)(?=[\ /\r\n])
whitespace_start:
.rgx: ([\+\-])(?![\-\~])
whitespace_token:
.rgx: ((?:\+|\-|\-\-|\~|\~\~))(?=(?:\s|\#.*(?:\n|\z))+)