203 # the version number |
203 # the version number |
204 (r'([ ]+)([0-9]+\.[0-9]+)', |
204 (r'([ ]+)([0-9]+\.[0-9]+)', |
205 bygroups(Text, Number), 'ignored-line'), |
205 bygroups(Text, Number), 'ignored-line'), |
206 ], |
206 ], |
207 |
207 |
208 # the %YAG directive |
208 # the %TAG directive |
209 'tag-directive': [ |
209 'tag-directive': [ |
210 # a tag handle and the corresponding prefix |
210 # a tag handle and the corresponding prefix |
211 (r'([ ]+)(!|![\w-]*!)' |
211 (r'([ ]+)(!|![\w-]*!)' |
212 r'([ ]+)(!|!?[\w;/?:@&=+$,.!~*\'()\[\]%-]+)', |
212 r'([ ]+)(!|!?[\w;/?:@&=+$,.!~*\'()\[\]%-]+)', |
213 bygroups(Text, Keyword.Type, Text, Keyword.Type), |
213 bygroups(Text, Keyword.Type, Text, Keyword.Type), |
216 |
216 |
217 # block scalar indicators and indentation spaces |
217 # block scalar indicators and indentation spaces |
218 'indentation': [ |
218 'indentation': [ |
219 # trailing whitespaces are ignored |
219 # trailing whitespaces are ignored |
220 (r'[ ]*$', something(Text), '#pop:2'), |
220 (r'[ ]*$', something(Text), '#pop:2'), |
221 # whitespaces preceeding block collection indicators |
221 # whitespaces preceding block collection indicators |
222 (r'[ ]+(?=[?:-](?:[ ]|$))', save_indent(Text)), |
222 (r'[ ]+(?=[?:-](?:[ ]|$))', save_indent(Text)), |
223 # block collection indicators |
223 # block collection indicators |
224 (r'[?:-](?=[ ]|$)', set_indent(Punctuation.Indicator)), |
224 (r'[?:-](?=[ ]|$)', set_indent(Punctuation.Indicator)), |
225 # the beginning a block line |
225 # the beginning a block line |
226 (r'[ ]*', save_indent(Text), '#pop'), |
226 (r'[ ]*', save_indent(Text), '#pop'), |
230 'block-line': [ |
230 'block-line': [ |
231 # the line end |
231 # the line end |
232 (r'[ ]*(?=#|$)', something(Text), '#pop'), |
232 (r'[ ]*(?=#|$)', something(Text), '#pop'), |
233 # whitespaces separating tokens |
233 # whitespaces separating tokens |
234 (r'[ ]+', Text), |
234 (r'[ ]+', Text), |
|
235 # key with colon |
|
236 (r'([^,:?\[\]{}\n]+)(:)(?=[ ]|$)', |
|
237 bygroups(Name.Tag, set_indent(Punctuation, implicit=True))), |
235 # tags, anchors and aliases, |
238 # tags, anchors and aliases, |
236 include('descriptors'), |
239 include('descriptors'), |
237 # block collections and scalars |
240 # block collections and scalars |
238 include('block-nodes'), |
241 include('block-nodes'), |
239 # flow collections and quoted scalars |
242 # flow collections and quoted scalars |
248 'descriptors': [ |
251 'descriptors': [ |
249 # a full-form tag |
252 # a full-form tag |
250 (r'!<[\w#;/?:@&=+$,.!~*\'()\[\]%-]+>', Keyword.Type), |
253 (r'!<[\w#;/?:@&=+$,.!~*\'()\[\]%-]+>', Keyword.Type), |
251 # a tag in the form '!', '!suffix' or '!handle!suffix' |
254 # a tag in the form '!', '!suffix' or '!handle!suffix' |
252 (r'!(?:[\w-]+!)?' |
255 (r'!(?:[\w-]+!)?' |
253 r'[\w#;/?:@&=+$,.!~*\'()\[\]%-]+', Keyword.Type), |
256 r'[\w#;/?:@&=+$,.!~*\'()\[\]%-]*', Keyword.Type), |
254 # an anchor |
257 # an anchor |
255 (r'&[\w-]+', Name.Label), |
258 (r'&[\w-]+', Name.Label), |
256 # an alias |
259 # an alias |
257 (r'\*[\w-]+', Name.Variable), |
260 (r'\*[\w-]+', Name.Variable), |
258 ], |
261 ], |
306 (r'\]', Punctuation.Indicator, '#pop'), |
309 (r'\]', Punctuation.Indicator, '#pop'), |
307 ], |
310 ], |
308 |
311 |
309 # a flow mapping indicated by '{' and '}' |
312 # a flow mapping indicated by '{' and '}' |
310 'flow-mapping': [ |
313 'flow-mapping': [ |
|
314 # key with colon |
|
315 (r'([^,:?\[\]{}\n]+)(:)(?=[ ]|$)', |
|
316 bygroups(Name.Tag, Punctuation)), |
311 # include flow collection rules |
317 # include flow collection rules |
312 include('flow-collection'), |
318 include('flow-collection'), |
313 # the closing indicator |
319 # the closing indicator |
314 (r'\}', Punctuation.Indicator, '#pop'), |
320 (r'\}', Punctuation.Indicator, '#pop'), |
315 ], |
321 ], |