ThirdParty/Pygments/pygments/lexers/webmisc.py

changeset 4697
c2e9bf425554
parent 4172
4f20dba37ab6
child 5713
6762afd9f963
equal deleted inserted replaced
4696:bf4d19a7cade 4697:c2e9bf425554
3 pygments.lexers.webmisc 3 pygments.lexers.webmisc
4 ~~~~~~~~~~~~~~~~~~~~~~~ 4 ~~~~~~~~~~~~~~~~~~~~~~~
5 5
6 Lexers for misc. web stuff. 6 Lexers for misc. web stuff.
7 7
8 :copyright: Copyright 2006-2014 by the Pygments team, see AUTHORS. 8 :copyright: Copyright 2006-2015 by the Pygments team, see AUTHORS.
9 :license: BSD, see LICENSE for details. 9 :license: BSD, see LICENSE for details.
10 """ 10 """
11 11
12 import re 12 import re
13 13
189 yield match.start(), Punctuation, match.group(3) 189 yield match.start(), Punctuation, match.group(3)
190 ctx.stack = ['root'] 190 ctx.stack = ['root']
191 lexer.xquery_parse_state.append('operator') 191 lexer.xquery_parse_state.append('operator')
192 ctx.pos = match.end() 192 ctx.pos = match.end()
193 193
194 def pushstate_operator_map_callback(lexer, match, ctx):
195 yield match.start(), Keyword, match.group(1)
196 yield match.start(), Text, match.group(2)
197 yield match.start(), Punctuation, match.group(3)
198 ctx.stack = ['root']
199 lexer.xquery_parse_state.append('operator')
200 ctx.pos = match.end()
201
194 def pushstate_operator_root_validate(lexer, match, ctx): 202 def pushstate_operator_root_validate(lexer, match, ctx):
195 yield match.start(), Keyword, match.group(1) 203 yield match.start(), Keyword, match.group(1)
196 yield match.start(), Text, match.group(2) 204 yield match.start(), Text, match.group(2)
197 yield match.start(), Punctuation, match.group(3) 205 yield match.start(), Punctuation, match.group(3)
198 ctx.stack = ['root'] 206 ctx.stack = ['root']
331 (r'\(:', Comment, 'comment'), 339 (r'\(:', Comment, 'comment'),
332 340
333 (r'(\{)', pushstate_root_callback), 341 (r'(\{)', pushstate_root_callback),
334 (r'then|else|external|at|div|except', Keyword, 'root'), 342 (r'then|else|external|at|div|except', Keyword, 'root'),
335 (r'order by', Keyword, 'root'), 343 (r'order by', Keyword, 'root'),
344 (r'group by', Keyword, 'root'),
336 (r'is|mod|order\s+by|stable\s+order\s+by', Keyword, 'root'), 345 (r'is|mod|order\s+by|stable\s+order\s+by', Keyword, 'root'),
337 (r'and|or', Operator.Word, 'root'), 346 (r'and|or', Operator.Word, 'root'),
338 (r'(eq|ge|gt|le|lt|ne|idiv|intersect|in)(?=\b)', 347 (r'(eq|ge|gt|le|lt|ne|idiv|intersect|in)(?=\b)',
339 Operator.Word, 'root'), 348 Operator.Word, 'root'),
340 (r'return|satisfies|to|union|where|preserve\s+strip', 349 (r'return|satisfies|to|union|where|count|preserve\s+strip',
341 Keyword, 'root'), 350 Keyword, 'root'),
342 (r'(>=|>>|>|<=|<<|<|-|\*|!=|\+|\|\||\||:=|=)', 351 (r'(>=|>>|>|<=|<<|<|-|\*|!=|\+|\|\||\||:=|=|!)',
343 operator_root_callback), 352 operator_root_callback),
344 (r'(::|;|\[|//|/|,)', 353 (r'(::|:|;|\[|//|/|,)',
345 punctuation_root_callback), 354 punctuation_root_callback),
346 (r'(castable|cast)(\s+)(as)\b', 355 (r'(castable|cast)(\s+)(as)\b',
347 bygroups(Keyword, Text, Keyword), 'singletype'), 356 bygroups(Keyword, Text, Keyword), 'singletype'),
348 (r'(instance)(\s+)(of)\b', 357 (r'(instance)(\s+)(of)\b',
349 bygroups(Keyword, Text, Keyword), 'itemtype'), 358 bygroups(Keyword, Text, Keyword), 'itemtype'),
350 (r'(treat)(\s+)(as)\b', 359 (r'(treat)(\s+)(as)\b',
351 bygroups(Keyword, Text, Keyword), 'itemtype'), 360 bygroups(Keyword, Text, Keyword), 'itemtype'),
361 (r'(case)(\s+)(' + stringdouble + ')', bygroups(Keyword, Text, String.Double), 'itemtype'),
362 (r'(case)(\s+)(' + stringsingle + ')', bygroups(Keyword, Text, String.Single), 'itemtype'),
352 (r'(case|as)\b', Keyword, 'itemtype'), 363 (r'(case|as)\b', Keyword, 'itemtype'),
353 (r'(\))(\s*)(as)', 364 (r'(\))(\s*)(as)',
354 bygroups(Punctuation, Text, Keyword), 'itemtype'), 365 bygroups(Punctuation, Text, Keyword), 'itemtype'),
355 (r'\$', Name.Variable, 'varname'), 366 (r'\$', Name.Variable, 'varname'),
356 (r'(for|let)(\s+)(\$)', 367 (r'(for|let|previous|next)(\s+)(\$)',
357 bygroups(Keyword, Text, Name.Variable), 'varname'), 368 bygroups(Keyword, Text, Name.Variable), 'varname'),
369 (r'(for)(\s+)(tumbling|sliding)(\s+)(window)(\s+)(\$)',
370 bygroups(Keyword, Text, Keyword, Text, Keyword, Text, Name.Variable), 'varname'),
358 # (r'\)|\?|\]', Punctuation, '#push'), 371 # (r'\)|\?|\]', Punctuation, '#push'),
359 (r'\)|\?|\]', Punctuation), 372 (r'\)|\?|\]', Punctuation),
360 (r'(empty)(\s+)(greatest|least)', bygroups(Keyword, Text, Keyword)), 373 (r'(empty)(\s+)(greatest|least)', bygroups(Keyword, Text, Keyword)),
361 (r'ascending|descending|default', Keyword, '#push'), 374 (r'ascending|descending|default', Keyword, '#push'),
375 (r'(allowing)(\s+)(empty)', bygroups(Keyword, Text, Keyword)),
362 (r'external', Keyword), 376 (r'external', Keyword),
377 (r'(start|when|end)', Keyword, 'root'),
378 (r'(only)(\s+)(end)', bygroups(Keyword, Text, Keyword), 'root'),
363 (r'collation', Keyword, 'uritooperator'), 379 (r'collation', Keyword, 'uritooperator'),
380
381 # eXist specific XQUF
382 (r'(into|following|preceding|with)', Keyword, 'root'),
383
384 # support for current context on rhs of Simple Map Operator
385 (r'\.', Operator),
386
364 # finally catch all string literals and stay in operator state 387 # finally catch all string literals and stay in operator state
365 (stringdouble, String.Double), 388 (stringdouble, String.Double),
366 (stringsingle, String.Single), 389 (stringsingle, String.Single),
367 390
368 (r'(catch)(\s*)', bygroups(Keyword, Text), 'root'), 391 (r'(catch)(\s*)', bygroups(Keyword, Text), 'root'),
392 (r'namespace', Keyword, 'namespacedecl'), 415 (r'namespace', Keyword, 'namespacedecl'),
393 (r'(default)(\s+)(element)', bygroups(Keyword, Text, Keyword)), 416 (r'(default)(\s+)(element)', bygroups(Keyword, Text, Keyword)),
394 (r'preserve|no-preserve', Keyword), 417 (r'preserve|no-preserve', Keyword),
395 (r',', Punctuation), 418 (r',', Punctuation),
396 ], 419 ],
420 'annotationname':[
421 (r'\(:', Comment, 'comment'),
422 (qname, Name.Decorator),
423 (r'(\()(' + stringdouble + ')', bygroups(Punctuation, String.Double)),
424 (r'(\()(' + stringsingle + ')', bygroups(Punctuation, String.Single)),
425 (r'(\,)(\s+)(' + stringdouble + ')', bygroups(Punctuation, Text, String.Double)),
426 (r'(\,)(\s+)(' + stringsingle + ')', bygroups(Punctuation, Text, String.Single)),
427 (r'\)', Punctuation),
428 (r'(\s+)(\%)', bygroups(Text, Name.Decorator), 'annotationname'),
429 (r'(\s+)(variable)(\s+)(\$)', bygroups(Text, Keyword.Declaration, Text, Name.Variable), 'varname'),
430 (r'(\s+)(function)(\s+)', bygroups(Text, Keyword.Declaration, Text), 'root')
431 ],
397 'varname': [ 432 'varname': [
398 (r'\(:', Comment, 'comment'), 433 (r'\(:', Comment, 'comment'),
399 (qname, Name.Variable, 'operator'), 434 (r'(' + qname + ')(\()?', bygroups(Name, Punctuation), 'operator'),
400 ], 435 ],
401 'singletype': [ 436 'singletype': [
437 include('whitespace'),
402 (r'\(:', Comment, 'comment'), 438 (r'\(:', Comment, 'comment'),
403 (ncname + r'(:\*)', Name.Variable, 'operator'), 439 (ncname + r'(:\*)', Name.Variable, 'operator'),
404 (qname, Name.Variable, 'operator'), 440 (qname, Name.Variable, 'operator'),
405 ], 441 ],
406 'itemtype': [ 442 'itemtype': [
407 include('whitespace'), 443 include('whitespace'),
408 (r'\(:', Comment, 'comment'), 444 (r'\(:', Comment, 'comment'),
409 (r'\$', Punctuation, 'varname'), 445 (r'\$', Name.Variable, 'varname'),
410 (r'(void)(\s*)(\()(\s*)(\))', 446 (r'(void)(\s*)(\()(\s*)(\))',
411 bygroups(Keyword, Text, Punctuation, Text, Punctuation), 'operator'), 447 bygroups(Keyword, Text, Punctuation, Text, Punctuation), 'operator'),
412 (r'(element|attribute|schema-element|schema-attribute|comment|text|' 448 (r'(element|attribute|schema-element|schema-attribute|comment|text|'
413 r'node|binary|document-node|empty-sequence)(\s*)(\()', 449 r'node|binary|document-node|empty-sequence)(\s*)(\()',
414 pushstate_occurrenceindicator_kindtest_callback), 450 pushstate_occurrenceindicator_kindtest_callback),
417 bygroups(Keyword, Text, Punctuation), 453 bygroups(Keyword, Text, Punctuation),
418 ('occurrenceindicator', 'kindtestforpi')), 454 ('occurrenceindicator', 'kindtestforpi')),
419 (r'(item)(\s*)(\()(\s*)(\))(?=[*+?])', 455 (r'(item)(\s*)(\()(\s*)(\))(?=[*+?])',
420 bygroups(Keyword, Text, Punctuation, Text, Punctuation), 456 bygroups(Keyword, Text, Punctuation, Text, Punctuation),
421 'occurrenceindicator'), 457 'occurrenceindicator'),
422 (r'\(\#', Punctuation, 'pragma'), 458 (r'(\(\#)(\s*)', bygroups(Punctuation, Text), 'pragma'),
423 (r';', Punctuation, '#pop'), 459 (r';', Punctuation, '#pop'),
424 (r'then|else', Keyword, '#pop'), 460 (r'then|else', Keyword, '#pop'),
425 (r'(at)(\s+)(' + stringdouble + ')', 461 (r'(at)(\s+)(' + stringdouble + ')',
426 bygroups(Keyword, Text, String.Double), 'namespacedecl'), 462 bygroups(Keyword, Text, String.Double), 'namespacedecl'),
427 (r'(at)(\s+)(' + stringsingle + ')', 463 (r'(at)(\s+)(' + stringsingle + ')',
428 bygroups(Keyword, Text, String.Single), 'namespacedecl'), 464 bygroups(Keyword, Text, String.Single), 'namespacedecl'),
429 (r'except|intersect|in|is|return|satisfies|to|union|where', 465 (r'except|intersect|in|is|return|satisfies|to|union|where|count',
430 Keyword, 'root'), 466 Keyword, 'root'),
431 (r'and|div|eq|ge|gt|le|lt|ne|idiv|mod|or', Operator.Word, 'root'), 467 (r'and|div|eq|ge|gt|le|lt|ne|idiv|mod|or', Operator.Word, 'root'),
432 (r':=|=|,|>=|>>|>|\[|\(|<=|<<|<|-|!=|\|\||\|', Operator, 'root'), 468 (r':=|=|,|>=|>>|>|\[|\(|<=|<<|<|-|!=|\|\||\|', Operator, 'root'),
433 (r'external|at', Keyword, 'root'), 469 (r'external|at', Keyword, 'root'),
434 (r'(stable)(\s+)(order)(\s+)(by)', 470 (r'(stable)(\s+)(order)(\s+)(by)',
435 bygroups(Keyword, Text, Keyword, Text, Keyword), 'root'), 471 bygroups(Keyword, Text, Keyword, Text, Keyword), 'root'),
436 (r'(castable|cast)(\s+)(as)', 472 (r'(castable|cast)(\s+)(as)',
437 bygroups(Keyword, Text, Keyword), 'singletype'), 473 bygroups(Keyword, Text, Keyword), 'singletype'),
438 (r'(treat)(\s+)(as)', bygroups(Keyword, Text, Keyword)), 474 (r'(treat)(\s+)(as)', bygroups(Keyword, Text, Keyword)),
439 (r'(instance)(\s+)(of)', bygroups(Keyword, Text, Keyword)), 475 (r'(instance)(\s+)(of)', bygroups(Keyword, Text, Keyword)),
476 (r'(case)(\s+)(' + stringdouble + ')', bygroups(Keyword, Text, String.Double), 'itemtype'),
477 (r'(case)(\s+)(' + stringsingle + ')', bygroups(Keyword, Text, String.Single), 'itemtype'),
440 (r'case|as', Keyword, 'itemtype'), 478 (r'case|as', Keyword, 'itemtype'),
441 (r'(\))(\s*)(as)', bygroups(Operator, Text, Keyword), 'itemtype'), 479 (r'(\))(\s*)(as)', bygroups(Operator, Text, Keyword), 'itemtype'),
442 (ncname + r':\*', Keyword.Type, 'operator'), 480 (ncname + r':\*', Keyword.Type, 'operator'),
481 (r'(function|map|array)(\()', bygroups(Keyword.Type, Punctuation)),
443 (qname, Keyword.Type, 'occurrenceindicator'), 482 (qname, Keyword.Type, 'occurrenceindicator'),
444 ], 483 ],
445 'kindtest': [ 484 'kindtest': [
446 (r'\(:', Comment, 'comment'), 485 (r'\(:', Comment, 'comment'),
447 (r'\{', Punctuation, 'root'), 486 (r'\{', Punctuation, 'root'),
528 include('whitespace'), 567 include('whitespace'),
529 (r'(>)', popstate_tag_callback), 568 (r'(>)', popstate_tag_callback),
530 (qname, Name.Tag), 569 (qname, Name.Tag),
531 ], 570 ],
532 'xmlspace_decl': [ 571 'xmlspace_decl': [
572 include('whitespace'),
533 (r'\(:', Comment, 'comment'), 573 (r'\(:', Comment, 'comment'),
534 (r'preserve|strip', Keyword, '#pop'), 574 (r'preserve|strip', Keyword, '#pop'),
535 ], 575 ],
536 'declareordering': [ 576 'declareordering': [
537 (r'\(:', Comment, 'comment'), 577 (r'\(:', Comment, 'comment'),
587 (r'(\.\d+)[eE][+-]?\d+', Number.Float, 'operator'), 627 (r'(\.\d+)[eE][+-]?\d+', Number.Float, 'operator'),
588 (r'(\.\d+|\d+\.\d*)', Number.Float, 'operator'), 628 (r'(\.\d+|\d+\.\d*)', Number.Float, 'operator'),
589 (r'(\d+)', Number.Integer, 'operator'), 629 (r'(\d+)', Number.Integer, 'operator'),
590 (r'(\.\.|\.|\))', Punctuation, 'operator'), 630 (r'(\.\.|\.|\))', Punctuation, 'operator'),
591 (r'(declare)(\s+)(construction)', 631 (r'(declare)(\s+)(construction)',
592 bygroups(Keyword, Text, Keyword), 'operator'), 632 bygroups(Keyword.Declaration, Text, Keyword.Declaration), 'operator'),
593 (r'(declare)(\s+)(default)(\s+)(order)', 633 (r'(declare)(\s+)(default)(\s+)(order)',
594 bygroups(Keyword, Text, Keyword, Text, Keyword), 'operator'), 634 bygroups(Keyword.Declaration, Text, Keyword.Declaration, Text, Keyword.Declaration), 'operator'),
635 (r'(declare)(\s+)(context)(\s+)(item)',
636 bygroups(Keyword.Declaration, Text, Keyword.Declaration, Text, Keyword.Declaration), 'operator'),
595 (ncname + ':\*', Name, 'operator'), 637 (ncname + ':\*', Name, 'operator'),
596 ('\*:'+ncname, Name.Tag, 'operator'), 638 ('\*:'+ncname, Name.Tag, 'operator'),
597 ('\*', Name.Tag, 'operator'), 639 ('\*', Name.Tag, 'operator'),
598 (stringdouble, String.Double, 'operator'), 640 (stringdouble, String.Double, 'operator'),
599 (stringsingle, String.Single, 'operator'), 641 (stringsingle, String.Single, 'operator'),
600 642
601 (r'(\})', popstate_callback), 643 (r'(\}|\])', popstate_callback),
602 644
603 # NAMESPACE DECL 645 # NAMESPACE DECL
604 (r'(declare)(\s+)(default)(\s+)(collation)', 646 (r'(declare)(\s+)(default)(\s+)(collation)',
605 bygroups(Keyword, Text, Keyword, Text, Keyword)), 647 bygroups(Keyword.Declaration, Text, Keyword.Declaration, Text, Keyword.Declaration)),
606 (r'(module|declare)(\s+)(namespace)', 648 (r'(module|declare)(\s+)(namespace)',
607 bygroups(Keyword, Text, Keyword), 'namespacedecl'), 649 bygroups(Keyword.Declaration, Text, Keyword.Declaration), 'namespacedecl'),
608 (r'(declare)(\s+)(base-uri)', 650 (r'(declare)(\s+)(base-uri)',
609 bygroups(Keyword, Text, Keyword), 'namespacedecl'), 651 bygroups(Keyword.Declaration, Text, Keyword.Declaration), 'namespacedecl'),
610 652
611 # NAMESPACE KEYWORD 653 # NAMESPACE KEYWORD
612 (r'(declare)(\s+)(default)(\s+)(element|function)', 654 (r'(declare)(\s+)(default)(\s+)(element|function)',
613 bygroups(Keyword, Text, Keyword, Text, Keyword), 'namespacekeyword'), 655 bygroups(Keyword.Declaration, Text, Keyword.Declaration, Text, Keyword.Declaration), 'namespacekeyword'),
614 (r'(import)(\s+)(schema|module)', 656 (r'(import)(\s+)(schema|module)',
615 bygroups(Keyword.Pseudo, Text, Keyword.Pseudo), 'namespacekeyword'), 657 bygroups(Keyword.Pseudo, Text, Keyword.Pseudo), 'namespacekeyword'),
616 (r'(declare)(\s+)(copy-namespaces)', 658 (r'(declare)(\s+)(copy-namespaces)',
617 bygroups(Keyword, Text, Keyword), 'namespacekeyword'), 659 bygroups(Keyword.Declaration, Text, Keyword.Declaration), 'namespacekeyword'),
618 660
619 # VARNAMEs 661 # VARNAMEs
620 (r'(for|let|some|every)(\s+)(\$)', 662 (r'(for|let|some|every)(\s+)(\$)',
621 bygroups(Keyword, Text, Name.Variable), 'varname'), 663 bygroups(Keyword, Text, Name.Variable), 'varname'),
664 (r'(for)(\s+)(tumbling|sliding)(\s+)(window)(\s+)(\$)',
665 bygroups(Keyword, Text, Keyword, Text, Keyword, Text, Name.Variable), 'varname'),
622 (r'\$', Name.Variable, 'varname'), 666 (r'\$', Name.Variable, 'varname'),
623 (r'(declare)(\s+)(variable)(\s+)(\$)', 667 (r'(declare)(\s+)(variable)(\s+)(\$)',
624 bygroups(Keyword, Text, Keyword, Text, Name.Variable), 'varname'), 668 bygroups(Keyword.Declaration, Text, Keyword.Declaration, Text, Name.Variable), 'varname'),
669
670 # ANNOTATED GLOBAL VARIABLES AND FUNCTIONS
671 (r'(declare)(\s+)(\%)', bygroups(Keyword.Declaration, Text, Name.Decorator), 'annotationname'),
625 672
626 # ITEMTYPE 673 # ITEMTYPE
627 (r'(\))(\s+)(as)', bygroups(Operator, Text, Keyword), 'itemtype'), 674 (r'(\))(\s+)(as)', bygroups(Operator, Text, Keyword), 'itemtype'),
628 675
629 (r'(element|attribute|schema-element|schema-attribute|comment|' 676 (r'(element|attribute|schema-element|schema-attribute|comment|'
641 688
642 # (r'</', Name.Tag, 'end_tag'), 689 # (r'</', Name.Tag, 'end_tag'),
643 (r'(<)', pushstate_operator_starttag_callback), 690 (r'(<)', pushstate_operator_starttag_callback),
644 691
645 (r'(declare)(\s+)(boundary-space)', 692 (r'(declare)(\s+)(boundary-space)',
646 bygroups(Keyword, Text, Keyword), 'xmlspace_decl'), 693 bygroups(Keyword.Declaration, Text, Keyword.Declaration), 'xmlspace_decl'),
647 694
648 (r'(validate)(\s+)(lax|strict)', 695 (r'(validate)(\s+)(lax|strict)',
649 pushstate_operator_root_validate_withmode), 696 pushstate_operator_root_validate_withmode),
650 (r'(validate)(\s*)(\{)', pushstate_operator_root_validate), 697 (r'(validate)(\s*)(\{)', pushstate_operator_root_validate),
651 (r'(typeswitch)(\s*)(\()', bygroups(Keyword, Text, Punctuation)), 698 (r'(typeswitch)(\s*)(\()', bygroups(Keyword, Text, Punctuation)),
652 (r'(element|attribute)(\s*)(\{)', 699 (r'(switch)(\s*)(\()', bygroups(Keyword, Text, Punctuation)),
700 (r'(element|attribute|namespace)(\s*)(\{)',
653 pushstate_operator_root_construct_callback), 701 pushstate_operator_root_construct_callback),
654 702
655 (r'(document|text|processing-instruction|comment)(\s*)(\{)', 703 (r'(document|text|processing-instruction|comment)(\s*)(\{)',
656 pushstate_operator_root_construct_callback), 704 pushstate_operator_root_construct_callback),
657 # ATTRIBUTE 705 # ATTRIBUTE
659 bygroups(Keyword, Text), 'attribute_qname'), 707 bygroups(Keyword, Text), 'attribute_qname'),
660 # ELEMENT 708 # ELEMENT
661 (r'(element)(\s+)(?=' + qname + r')', 709 (r'(element)(\s+)(?=' + qname + r')',
662 bygroups(Keyword, Text), 'element_qname'), 710 bygroups(Keyword, Text), 'element_qname'),
663 # PROCESSING_INSTRUCTION 711 # PROCESSING_INSTRUCTION
664 (r'(processing-instruction)(\s+)(' + ncname + r')(\s*)(\{)', 712 (r'(processing-instruction|namespace)(\s+)(' + ncname + r')(\s*)(\{)',
665 bygroups(Keyword, Text, Name.Variable, Text, Punctuation), 713 bygroups(Keyword, Text, Name.Variable, Text, Punctuation),
666 'operator'), 714 'operator'),
667 715
668 (r'(declare|define)(\s+)(function)', 716 (r'(declare|define)(\s+)(function)',
669 bygroups(Keyword, Text, Keyword)), 717 bygroups(Keyword.Declaration, Text, Keyword.Declaration)),
670 718
671 (r'(\{)', pushstate_operator_root_callback), 719 (r'(\{|\[)', pushstate_operator_root_callback),
672 720
673 (r'(unordered|ordered)(\s*)(\{)', 721 (r'(unordered|ordered)(\s*)(\{)',
674 pushstate_operator_order_callback), 722 pushstate_operator_order_callback),
675 723
724 (r'(map|array)(\s*)(\{)',
725 pushstate_operator_map_callback),
726
676 (r'(declare)(\s+)(ordering)', 727 (r'(declare)(\s+)(ordering)',
677 bygroups(Keyword, Text, Keyword), 'declareordering'), 728 bygroups(Keyword.Declaration, Text, Keyword.Declaration), 'declareordering'),
678 729
679 (r'(xquery)(\s+)(version)', 730 (r'(xquery)(\s+)(version)',
680 bygroups(Keyword.Pseudo, Text, Keyword.Pseudo), 'xqueryversion'), 731 bygroups(Keyword.Pseudo, Text, Keyword.Pseudo), 'xqueryversion'),
681 732
682 (r'(\(#)', Punctuation, 'pragma'), 733 (r'(\(#)(\s*)', bygroups(Punctuation, Text), 'pragma'),
683 734
684 # sometimes return can occur in root state 735 # sometimes return can occur in root state
685 (r'return', Keyword), 736 (r'return', Keyword),
686 737
687 (r'(declare)(\s+)(option)', bygroups(Keyword, Text, Keyword), 738 (r'(declare)(\s+)(option)', bygroups(Keyword.Declaration, Text, Keyword.Declaration),
688 'option'), 739 'option'),
689 740
690 # URI LITERALS - single and double quoted 741 # URI LITERALS - single and double quoted
691 (r'(at)(\s+)('+stringdouble+')', String.Double, 'namespacedecl'), 742 (r'(at)(\s+)('+stringdouble+')', String.Double, 'namespacedecl'),
692 (r'(at)(\s+)('+stringsingle+')', String.Single, 'namespacedecl'), 743 (r'(at)(\s+)('+stringsingle+')', String.Single, 'namespacedecl'),
698 749
699 (r'(if)(\s*)(\()', bygroups(Keyword, Text, Punctuation)), 750 (r'(if)(\s*)(\()', bygroups(Keyword, Text, Punctuation)),
700 751
701 (r'then|else', Keyword), 752 (r'then|else', Keyword),
702 753
703 # ML specific 754 # eXist specific XQUF
755 (r'(update)(\s*)(insert|delete|replace|value|rename)', bygroups(Keyword, Text, Keyword)),
756 (r'(into|following|preceding|with)', Keyword),
757
758 # Marklogic specific
704 (r'(try)(\s*)', bygroups(Keyword, Text), 'root'), 759 (r'(try)(\s*)', bygroups(Keyword, Text), 'root'),
705 (r'(catch)(\s*)(\()(\$)', 760 (r'(catch)(\s*)(\()(\$)',
706 bygroups(Keyword, Text, Punctuation, Name.Variable), 'varname'), 761 bygroups(Keyword, Text, Punctuation, Name.Variable), 'varname'),
707 762
708 (r'(@'+qname+')', Name.Attribute), 763
709 (r'(@'+ncname+')', Name.Attribute), 764 (r'(@'+qname+')', Name.Attribute, 'operator'),
710 (r'@\*:'+ncname, Name.Attribute), 765 (r'(@'+ncname+')', Name.Attribute, 'operator'),
711 (r'(@)', Name.Attribute), 766 (r'@\*:'+ncname, Name.Attribute, 'operator'),
767 (r'@\*', Name.Attribute, 'operator'),
768 (r'(@)', Name.Attribute, 'operator'),
712 769
713 (r'//|/|\+|-|;|,|\(|\)', Punctuation), 770 (r'//|/|\+|-|;|,|\(|\)', Punctuation),
714 771
715 # STANDALONE QNAMES 772 # STANDALONE QNAMES
716 (qname + r'(?=\s*\{)', Name.Tag, 'qname_braren'), 773 (qname + r'(?=\s*\{)', Name.Tag, 'qname_braren'),
717 (qname + r'(?=\s*\([^:])', Name.Function, 'qname_braren'), 774 (qname + r'(?=\s*\([^:])', Name.Function, 'qname_braren'),
775 (r'(' + qname + ')(#)([0-9]+)', bygroups(Name.Function, Keyword.Type, Number.Integer)),
718 (qname, Name.Tag, 'operator'), 776 (qname, Name.Tag, 'operator'),
719 ] 777 ]
720 } 778 }
721 779
722 780
729 787
730 # QML is based on javascript, so much of this is taken from the 788 # QML is based on javascript, so much of this is taken from the
731 # JavascriptLexer above. 789 # JavascriptLexer above.
732 790
733 name = 'QML' 791 name = 'QML'
734 aliases = ['qml'] 792 aliases = ['qml', 'qbs']
735 filenames = ['*.qml'] 793 filenames = ['*.qml', '*.qbs']
736 mimetypes = ['application/x-qml'] 794 mimetypes = ['application/x-qml', 'application/x-qt.qbs+qml']
737 795
738 # pasted from JavascriptLexer, with some additions 796 # pasted from JavascriptLexer, with some additions
739 flags = re.DOTALL | re.MULTILINE 797 flags = re.DOTALL | re.MULTILINE
740 798
741 tokens = { 799 tokens = {
796 class CirruLexer(RegexLexer): 854 class CirruLexer(RegexLexer):
797 """ 855 """
798 Syntax rules of Cirru can be found at: 856 Syntax rules of Cirru can be found at:
799 http://cirru.org/ 857 http://cirru.org/
800 858
801 * using ``()`` to markup blocks, but limited in the same line 859 * using ``()`` for expressions, but restricted in a same line
802 * using ``""`` to markup strings, allow ``\`` to escape 860 * using ``""`` for strings, with ``\`` for escaping chars
803 * using ``$`` as a shorthand for ``()`` till indentation end or ``)`` 861 * using ``$`` as folding operator
804 * using indentations for create nesting 862 * using ``,`` as unfolding operator
863 * using indentations for nested blocks
805 864
806 .. versionadded:: 2.0 865 .. versionadded:: 2.0
807 """ 866 """
808 867
809 name = 'Cirru' 868 name = 'Cirru'
820 ], 879 ],
821 'escape': [ 880 'escape': [
822 (r'.', String.Escape, '#pop'), 881 (r'.', String.Escape, '#pop'),
823 ], 882 ],
824 'function': [ 883 'function': [
884 (r'\,', Operator, '#pop'),
825 (r'[^\s"()]+', Name.Function, '#pop'), 885 (r'[^\s"()]+', Name.Function, '#pop'),
826 (r'\)', Operator, '#pop'), 886 (r'\)', Operator, '#pop'),
827 (r'(?=\n)', Text, '#pop'), 887 (r'(?=\n)', Text, '#pop'),
828 (r'\(', Operator, '#push'), 888 (r'\(', Operator, '#push'),
829 (r'"', String, ('#pop', 'string')), 889 (r'"', String, ('#pop', 'string')),
830 (r'[ ]+', Text.Whitespace), 890 (r'[ ]+', Text.Whitespace),
831 (r'\,', Operator, '#pop'),
832 ], 891 ],
833 'line': [ 892 'line': [
834 (r'\$', Operator, 'function'), 893 (r'(?<!\w)\$(?!\w)', Operator, 'function'),
835 (r'\(', Operator, 'function'), 894 (r'\(', Operator, 'function'),
836 (r'\)', Operator), 895 (r'\)', Operator),
837 (r'\n', Text, '#pop'), 896 (r'\n', Text, '#pop'),
838 (r'"', String, 'string'), 897 (r'"', String, 'string'),
839 (r'[ ]+', Text.Whitespace), 898 (r'[ ]+', Text.Whitespace),

eric ide

mercurial