1358 (r'[ \t]+', Text), |
1538 (r'[ \t]+', Text), |
1359 (r'[^\s]+', String), |
1539 (r'[^\s]+', String), |
1360 (r'\n', Text, 'root'), |
1540 (r'\n', Text, 'root'), |
1361 ], |
1541 ], |
1362 |
1542 |
1363 'for': [ |
|
1364 (r'(from|to|through)', Operator.Word), |
|
1365 include('script'), |
|
1366 ], |
|
1367 |
|
1368 'old-style-attr': [ |
1543 'old-style-attr': [ |
1369 (r'[^\s:="\[]+', Name.Attribute), |
1544 (r'[^\s:="\[]+', Name.Attribute), |
1370 (r'#{', String.Interpol, 'interpolation'), |
1545 (r'#{', String.Interpol, 'interpolation'), |
1371 (r'[ \t]*=', Operator, 'script'), |
1546 (r'[ \t]*=', Operator, 'value'), |
1372 (r'', Text, 'value'), |
1547 (r'', Text, 'value'), |
1373 ], |
1548 ], |
1374 |
1549 |
1375 'new-style-attr': [ |
1550 'new-style-attr': [ |
1376 (r'[^\s:="\[]+', Name.Attribute), |
1551 (r'[^\s:="\[]+', Name.Attribute), |
1377 (r'#{', String.Interpol, 'interpolation'), |
1552 (r'#{', String.Interpol, 'interpolation'), |
1378 (r'[ \t]*=', Operator, 'script'), |
1553 (r'[ \t]*[=:]', Operator, 'value'), |
1379 (r':', Name.Attribute, 'value'), |
|
1380 ], |
|
1381 |
|
1382 'value': [ |
|
1383 (r'[ \t]+', Text), |
|
1384 (r'url\(', String.Other, 'string-url'), |
|
1385 (r'(azimuth|background-attachment|background-color|' |
|
1386 r'background-image|background-position|background-repeat|' |
|
1387 r'background|border-bottom-color|border-bottom-style|' |
|
1388 r'border-bottom-width|border-left-color|border-left-style|' |
|
1389 r'border-left-width|border-right|border-right-color|' |
|
1390 r'border-right-style|border-right-width|border-top-color|' |
|
1391 r'border-top-style|border-top-width|border-bottom|' |
|
1392 r'border-collapse|border-left|border-width|border-color|' |
|
1393 r'border-spacing|border-style|border-top|border|caption-side|' |
|
1394 r'clear|clip|color|content|counter-increment|counter-reset|' |
|
1395 r'cue-after|cue-before|cue|cursor|direction|display|' |
|
1396 r'elevation|empty-cells|float|font-family|font-size|' |
|
1397 r'font-size-adjust|font-stretch|font-style|font-variant|' |
|
1398 r'font-weight|font|height|letter-spacing|line-height|' |
|
1399 r'list-style-type|list-style-image|list-style-position|' |
|
1400 r'list-style|margin-bottom|margin-left|margin-right|' |
|
1401 r'margin-top|margin|marker-offset|marks|max-height|max-width|' |
|
1402 r'min-height|min-width|opacity|orphans|outline|outline-color|' |
|
1403 r'outline-style|outline-width|overflow|padding-bottom|' |
|
1404 r'padding-left|padding-right|padding-top|padding|page|' |
|
1405 r'page-break-after|page-break-before|page-break-inside|' |
|
1406 r'pause-after|pause-before|pause|pitch|pitch-range|' |
|
1407 r'play-during|position|quotes|richness|right|size|' |
|
1408 r'speak-header|speak-numeral|speak-punctuation|speak|' |
|
1409 r'speech-rate|stress|table-layout|text-align|text-decoration|' |
|
1410 r'text-indent|text-shadow|text-transform|top|unicode-bidi|' |
|
1411 r'vertical-align|visibility|voice-family|volume|white-space|' |
|
1412 r'widows|width|word-spacing|z-index|bottom|left|' |
|
1413 r'above|absolute|always|armenian|aural|auto|avoid|baseline|' |
|
1414 r'behind|below|bidi-override|blink|block|bold|bolder|both|' |
|
1415 r'capitalize|center-left|center-right|center|circle|' |
|
1416 r'cjk-ideographic|close-quote|collapse|condensed|continuous|' |
|
1417 r'crop|crosshair|cross|cursive|dashed|decimal-leading-zero|' |
|
1418 r'decimal|default|digits|disc|dotted|double|e-resize|embed|' |
|
1419 r'extra-condensed|extra-expanded|expanded|fantasy|far-left|' |
|
1420 r'far-right|faster|fast|fixed|georgian|groove|hebrew|help|' |
|
1421 r'hidden|hide|higher|high|hiragana-iroha|hiragana|icon|' |
|
1422 r'inherit|inline-table|inline|inset|inside|invert|italic|' |
|
1423 r'justify|katakana-iroha|katakana|landscape|larger|large|' |
|
1424 r'left-side|leftwards|level|lighter|line-through|list-item|' |
|
1425 r'loud|lower-alpha|lower-greek|lower-roman|lowercase|ltr|' |
|
1426 r'lower|low|medium|message-box|middle|mix|monospace|' |
|
1427 r'n-resize|narrower|ne-resize|no-close-quote|no-open-quote|' |
|
1428 r'no-repeat|none|normal|nowrap|nw-resize|oblique|once|' |
|
1429 r'open-quote|outset|outside|overline|pointer|portrait|px|' |
|
1430 r'relative|repeat-x|repeat-y|repeat|rgb|ridge|right-side|' |
|
1431 r'rightwards|s-resize|sans-serif|scroll|se-resize|' |
|
1432 r'semi-condensed|semi-expanded|separate|serif|show|silent|' |
|
1433 r'slow|slower|small-caps|small-caption|smaller|soft|solid|' |
|
1434 r'spell-out|square|static|status-bar|super|sw-resize|' |
|
1435 r'table-caption|table-cell|table-column|table-column-group|' |
|
1436 r'table-footer-group|table-header-group|table-row|' |
|
1437 r'table-row-group|text|text-bottom|text-top|thick|thin|' |
|
1438 r'transparent|ultra-condensed|ultra-expanded|underline|' |
|
1439 r'upper-alpha|upper-latin|upper-roman|uppercase|url|' |
|
1440 r'visible|w-resize|wait|wider|x-fast|x-high|x-large|x-loud|' |
|
1441 r'x-low|x-small|x-soft|xx-large|xx-small|yes)\b', Name.Constant), |
|
1442 (r'(indigo|gold|firebrick|indianred|yellow|darkolivegreen|' |
|
1443 r'darkseagreen|mediumvioletred|mediumorchid|chartreuse|' |
|
1444 r'mediumslateblue|black|springgreen|crimson|lightsalmon|brown|' |
|
1445 r'turquoise|olivedrab|cyan|silver|skyblue|gray|darkturquoise|' |
|
1446 r'goldenrod|darkgreen|darkviolet|darkgray|lightpink|teal|' |
|
1447 r'darkmagenta|lightgoldenrodyellow|lavender|yellowgreen|thistle|' |
|
1448 r'violet|navy|orchid|blue|ghostwhite|honeydew|cornflowerblue|' |
|
1449 r'darkblue|darkkhaki|mediumpurple|cornsilk|red|bisque|slategray|' |
|
1450 r'darkcyan|khaki|wheat|deepskyblue|darkred|steelblue|aliceblue|' |
|
1451 r'gainsboro|mediumturquoise|floralwhite|coral|purple|lightgrey|' |
|
1452 r'lightcyan|darksalmon|beige|azure|lightsteelblue|oldlace|' |
|
1453 r'greenyellow|royalblue|lightseagreen|mistyrose|sienna|' |
|
1454 r'lightcoral|orangered|navajowhite|lime|palegreen|burlywood|' |
|
1455 r'seashell|mediumspringgreen|fuchsia|papayawhip|blanchedalmond|' |
|
1456 r'peru|aquamarine|white|darkslategray|ivory|dodgerblue|' |
|
1457 r'lemonchiffon|chocolate|orange|forestgreen|slateblue|olive|' |
|
1458 r'mintcream|antiquewhite|darkorange|cadetblue|moccasin|' |
|
1459 r'limegreen|saddlebrown|darkslateblue|lightskyblue|deeppink|' |
|
1460 r'plum|aqua|darkgoldenrod|maroon|sandybrown|magenta|tan|' |
|
1461 r'rosybrown|pink|lightblue|palevioletred|mediumseagreen|' |
|
1462 r'dimgray|powderblue|seagreen|snow|mediumblue|midnightblue|' |
|
1463 r'paleturquoise|palegoldenrod|whitesmoke|darkorchid|salmon|' |
|
1464 r'lightslategray|lawngreen|lightgreen|tomato|hotpink|' |
|
1465 r'lightyellow|lavenderblush|linen|mediumaquamarine|green|' |
|
1466 r'blueviolet|peachpuff)\b', Name.Entity), |
|
1467 (r'\!important', Name.Exception), |
|
1468 (r'/\*', Comment, 'inline-comment'), |
|
1469 (r'\#[a-z0-9]{1,6}', Number.Hex), |
|
1470 (r'(-?\d+)(\%|[a-z]+)?', bygroups(Number.Integer, Keyword.Type)), |
|
1471 (r'(-?\d*\.\d+)(\%|[a-z]+)?', bygroups(Number.Float, Keyword.Type)), |
|
1472 (r'#{', String.Interpol, 'interpolation'), |
|
1473 (r'[~\^\*!&%<>\|+=@:,./?-]+', Operator), |
|
1474 (r'[\[\]();]+', Punctuation), |
|
1475 (r'"', String.Double, 'string-double'), |
|
1476 (r"'", String.Single, 'string-single'), |
|
1477 (r'[a-z][\w-]*', Name), |
|
1478 (r'\n', Text, 'root'), |
|
1479 ], |
|
1480 |
|
1481 'script': [ |
|
1482 (r'[ \t]+', Text), |
|
1483 (r'![\w_]+', Name.Variable), |
|
1484 (r'[+\-*/%=(),!><]', Operator), |
|
1485 (r'"', String.Double, 'string-double'), |
|
1486 (r"'", String.Single, 'string-single'), |
|
1487 (r'\#[a-z0-9]{1,6}', Number.Hex), |
|
1488 (r'(-?\d+)(\%|[a-z]+)?', bygroups(Number.Integer, Keyword.Type)), |
|
1489 (r'(-?\d*\.\d+)(\%|[a-z]+)?', bygroups(Number.Float, Keyword.Type)), |
|
1490 (r'(black|silver|gray|white|maroon|red|purple|fuchsia|green|' |
|
1491 r'lime|olive|yellow|navy|blue|teal|aqua)\b', Name.Builtin), |
|
1492 (r'(true|false)', Name.Pseudo), |
|
1493 (r'(and|or|not)', Operator.Word), |
|
1494 (r'(\\.|[^\s\\+*\/%(),=!])+(?=[ \t]*\()', Name.Function), |
|
1495 (r'(\\.|[^\s\\+*\/%(),=!])+', Name), |
|
1496 (r'\n', Text, 'root'), |
|
1497 ], |
|
1498 |
|
1499 'interpolation': [ |
|
1500 (r'\}', String.Interpol, '#pop'), |
|
1501 include('script'), |
|
1502 ], |
|
1503 |
|
1504 'selector': [ |
|
1505 (r'[ \t]+', Text), |
|
1506 (r'\:', Name.Decorator, 'pseudo-class'), |
|
1507 (r'\.', Name.Class, 'class'), |
|
1508 (r'\#', Name.Namespace, 'id'), |
|
1509 (r'[a-zA-Z0-9_-]+', Name.Tag), |
|
1510 (r'#\{', String.Interpol, 'interpolation'), |
|
1511 (r'&', Keyword), |
|
1512 (r'[~\^\*!&\[\]\(\)<>\|+=@:;,./?-]', Operator), |
|
1513 (r'"', String.Double, 'string-double'), |
|
1514 (r"'", String.Single, 'string-single'), |
|
1515 (r'\n', Text, 'root'), |
|
1516 ], |
|
1517 |
|
1518 'string-double': [ |
|
1519 (r'(\\.|#(?=[^\n{])|[^\n"#])+', String.Double), |
|
1520 (r'#\{', String.Interpol, 'interpolation'), |
|
1521 (r'"', String.Double, '#pop'), |
|
1522 ], |
|
1523 |
|
1524 'string-single': [ |
|
1525 (r"(\\.|#(?=[^\n{])|[^\n'#])+", String.Double), |
|
1526 (r'#\{', String.Interpol, 'interpolation'), |
|
1527 (r"'", String.Double, '#pop'), |
|
1528 ], |
|
1529 |
|
1530 'string-url': [ |
|
1531 (r'(\\#|#(?=[^\n{])|[^\n#)])+', String.Other), |
|
1532 (r'#\{', String.Interpol, 'interpolation'), |
|
1533 (r'\)', String.Other, '#pop'), |
|
1534 ], |
1554 ], |
1535 |
1555 |
1536 'inline-comment': [ |
1556 'inline-comment': [ |
1537 (r"(\\#|#(?=[^\n{])|\*(?=[^\n/])|[^\n#*])+", Comment), |
1557 (r"(\\#|#(?=[^\n{])|\*(?=[^\n/])|[^\n#*])+", Comment.Multiline), |
1538 (r'#\{', String.Interpol, 'interpolation'), |
1558 (r'#\{', String.Interpol, 'interpolation'), |
1539 (r"\*/", Comment, '#pop'), |
1559 (r"\*/", Comment, '#pop'), |
1540 ], |
1560 ], |
1541 |
1561 } |
1542 'pseudo-class': [ |
1562 for group, common in common_sass_tokens.items(): |
1543 (r'[\w-]+', Name.Decorator), |
1563 tokens[group] = copy.copy(common) |
|
1564 tokens['value'].append((r'\n', Text, 'root')) |
|
1565 tokens['selector'].append((r'\n', Text, 'root')) |
|
1566 |
|
1567 |
|
1568 class ScssLexer(RegexLexer): |
|
1569 """ |
|
1570 For SCSS stylesheets. |
|
1571 """ |
|
1572 |
|
1573 name = 'SCSS' |
|
1574 aliases = ['scss'] |
|
1575 filenames = ['*.scss'] |
|
1576 mimetypes = ['text/x-scss'] |
|
1577 |
|
1578 flags = re.IGNORECASE | re.DOTALL |
|
1579 tokens = { |
|
1580 'root': [ |
|
1581 (r'\s+', Text), |
|
1582 (r'//.*?\n', Comment.Single), |
|
1583 (r'/\*.*?\*/', Comment.Multiline), |
|
1584 (r'@import', Keyword, 'value'), |
|
1585 (r'@for', Keyword, 'for'), |
|
1586 (r'@(debug|warn|if|while)', Keyword, 'value'), |
|
1587 (r'(@mixin)( [\w-]+)', bygroups(Keyword, Name.Function), 'value'), |
|
1588 (r'(@include)( [\w-]+)', bygroups(Keyword, Name.Decorator), 'value'), |
|
1589 (r'@extend', Keyword, 'selector'), |
|
1590 (r'@[a-z0-9_-]+', Keyword, 'selector'), |
|
1591 (r'(\$[\w-]\w*)([ \t]*:)', bygroups(Name.Variable, Operator), 'value'), |
|
1592 (r'(?=[^;{}][;}])', Name.Attribute, 'attr'), |
|
1593 (r'(?=[^;{}:]+:[^a-z])', Name.Attribute, 'attr'), |
|
1594 (r'', Text, 'selector'), |
|
1595 ], |
|
1596 |
|
1597 'attr': [ |
|
1598 (r'[^\s:="\[]+', Name.Attribute), |
|
1599 (r'#{', String.Interpol, 'interpolation'), |
|
1600 (r'[ \t]*:', Operator, 'value'), |
|
1601 ], |
|
1602 |
|
1603 'inline-comment': [ |
|
1604 (r"(\\#|#(?=[^{])|\*(?=[^/])|[^#*])+", Comment.Multiline), |
1544 (r'#\{', String.Interpol, 'interpolation'), |
1605 (r'#\{', String.Interpol, 'interpolation'), |
1545 (r'', Text, '#pop'), |
1606 (r"\*/", Comment, '#pop'), |
1546 ], |
|
1547 |
|
1548 'class': [ |
|
1549 (r'[\w-]+', Name.Class), |
|
1550 (r'#\{', String.Interpol, 'interpolation'), |
|
1551 (r'', Text, '#pop'), |
|
1552 ], |
|
1553 |
|
1554 'id': [ |
|
1555 (r'[\w-]+', Name.Namespace), |
|
1556 (r'#\{', String.Interpol, 'interpolation'), |
|
1557 (r'', Text, '#pop'), |
|
1558 ], |
1607 ], |
1559 } |
1608 } |
|
1609 for group, common in common_sass_tokens.items(): |
|
1610 tokens[group] = copy.copy(common) |
|
1611 tokens['value'].extend([(r'\n', Text), (r'[;{}]', Punctuation, 'root')]) |
|
1612 tokens['selector'].extend([(r'\n', Text), (r'[;{}]', Punctuation, 'root')]) |
1560 |
1613 |
1561 |
1614 |
1562 class CoffeeScriptLexer(RegexLexer): |
1615 class CoffeeScriptLexer(RegexLexer): |
1563 """ |
1616 """ |
1564 For `CoffeeScript`_ source code. |
1617 For `CoffeeScript`_ source code. |
1565 |
1618 |
1566 .. _CoffeeScript: http://jashkenas.github.com/coffee-script/ |
1619 .. _CoffeeScript: http://coffeescript.org |
1567 |
1620 |
1568 *New in Pygments 1.3.* |
1621 *New in Pygments 1.3.* |
1569 """ |
1622 """ |
1570 |
1623 |
1571 name = 'CoffeeScript' |
1624 name = 'CoffeeScript' |
1590 ('\n', Text, '#pop'), |
1643 ('\n', Text, '#pop'), |
1591 ], |
1644 ], |
1592 'root': [ |
1645 'root': [ |
1593 (r'^(?=\s|/|<!--)', Text, 'slashstartsregex'), |
1646 (r'^(?=\s|/|<!--)', Text, 'slashstartsregex'), |
1594 include('commentsandwhitespace'), |
1647 include('commentsandwhitespace'), |
1595 (r'\+\+|--|~|&&|\band\b|\bor\b|\bis\b|\bisnt\b|\bnot\b|\?|:|' |
1648 (r'\+\+|--|~|&&|\band\b|\bor\b|\bis\b|\bisnt\b|\bnot\b|\?|:|=|' |
1596 r'\|\||\\(?=\n)|(<<|>>>?|==?|!=?|[-<>+*`%&\|\^/])=?', |
1649 r'\|\||\\(?=\n)|(<<|>>>?|==?|!=?|[-<>+*`%&\|\^/])=?', |
1597 Operator, 'slashstartsregex'), |
1650 Operator, 'slashstartsregex'), |
|
1651 (r'\([^()]*\)\s*->', Name.Function), |
1598 (r'[{(\[;,]', Punctuation, 'slashstartsregex'), |
1652 (r'[{(\[;,]', Punctuation, 'slashstartsregex'), |
1599 (r'[})\].]', Punctuation), |
1653 (r'[})\].]', Punctuation), |
1600 (r'(for|in|of|while|break|return|continue|switch|when|then|if|else|' |
1654 (r'(for|in|of|while|break|return|continue|switch|when|then|if|else|' |
1601 r'throw|try|catch|finally|new|delete|typeof|instanceof|super|' |
1655 r'throw|try|catch|finally|new|delete|typeof|instanceof|super|' |
1602 r'extends|this)\b', Keyword, 'slashstartsregex'), |
1656 r'extends|this|class|by)\b', Keyword, 'slashstartsregex'), |
1603 (r'(true|false|yes|no|on|off|null|NaN|Infinity|undefined)\b', |
1657 (r'(true|false|yes|no|on|off|null|NaN|Infinity|undefined)\b', |
1604 Keyword.Constant), |
1658 Keyword.Constant), |
1605 (r'(Array|Boolean|Date|Error|Function|Math|netscape|' |
1659 (r'(Array|Boolean|Date|Error|Function|Math|netscape|' |
1606 r'Number|Object|Packages|RegExp|String|sun|decodeURI|' |
1660 r'Number|Object|Packages|RegExp|String|sun|decodeURI|' |
1607 r'decodeURIComponent|encodeURI|encodeURIComponent|' |
1661 r'decodeURIComponent|encodeURI|encodeURIComponent|' |
1608 r'Error|eval|isFinite|isNaN|parseFloat|parseInt|document|this|' |
1662 r'eval|isFinite|isNaN|parseFloat|parseInt|document|window)\b', |
1609 r'window)\b', Name.Builtin), |
1663 Name.Builtin), |
1610 (r'[$a-zA-Z_][a-zA-Z0-9_\.:]*:\s', Name.Variable, |
1664 (r'[$a-zA-Z_][a-zA-Z0-9_\.:]*\s*[:=]\s', Name.Variable, |
1611 'slashstartsregex'), |
1665 'slashstartsregex'), |
1612 (r'[$a-zA-Z_][a-zA-Z0-9_]*', Name.Other), |
1666 (r'@[$a-zA-Z_][a-zA-Z0-9_\.:]*\s*[:=]\s', Name.Variable.Instance, |
|
1667 'slashstartsregex'), |
|
1668 (r'@?[$a-zA-Z_][a-zA-Z0-9_]*', Name.Other, 'slashstartsregex'), |
1613 (r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float), |
1669 (r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float), |
1614 (r'0x[0-9a-fA-F]+', Number.Hex), |
1670 (r'0x[0-9a-fA-F]+', Number.Hex), |
1615 (r'[0-9]+', Number.Integer), |
1671 (r'[0-9]+', Number.Integer), |
1616 (r'"(\\\\|\\"|[^"])*"', String.Double), |
1672 (r'"(\\\\|\\"|[^"])*"', String.Double), |
1617 (r"'(\\\\|\\'|[^'])*'", String.Single), |
1673 (r"'(\\\\|\\'|[^'])*'", String.Single), |
1618 ] |
1674 ] |
1619 } |
1675 } |
|
1676 |
|
1677 class DuelLexer(RegexLexer): |
|
1678 """ |
|
1679 Lexer for Duel Views Engine (formerly JBST) markup with JavaScript code blocks. |
|
1680 See http://duelengine.org/. |
|
1681 See http://jsonml.org/jbst/. |
|
1682 |
|
1683 *New in Pygments 1.4.* |
|
1684 """ |
|
1685 |
|
1686 name = 'Duel' |
|
1687 aliases = ['duel', 'Duel Engine', 'Duel View', 'JBST', 'jbst', 'JsonML+BST'] |
|
1688 filenames = ['*.duel','*.jbst'] |
|
1689 mimetypes = ['text/x-duel','text/x-jbst'] |
|
1690 |
|
1691 flags = re.DOTALL |
|
1692 |
|
1693 tokens = { |
|
1694 'root': [ |
|
1695 (r'(<%[@=#!:]?)(.*?)(%>)', |
|
1696 bygroups(Name.Tag, using(JavascriptLexer), Name.Tag)), |
|
1697 (r'(<%\$)(.*?)(:)(.*?)(%>)', |
|
1698 bygroups(Name.Tag, Name.Function, Punctuation, String, Name.Tag)), |
|
1699 (r'(<%--)(.*?)(--%>)', |
|
1700 bygroups(Name.Tag, Comment.Multiline, Name.Tag)), |
|
1701 (r'(<script.*?>)(.*?)(</script>)', |
|
1702 bygroups(using(HtmlLexer), |
|
1703 using(JavascriptLexer), using(HtmlLexer))), |
|
1704 (r'(.+?)(?=<)', using(HtmlLexer)), |
|
1705 (r'.+', using(HtmlLexer)), |
|
1706 ], |
|
1707 } |
|
1708 |
|
1709 |
|
1710 class ScamlLexer(ExtendedRegexLexer): |
|
1711 """ |
|
1712 For `Scaml markup <http://scalate.fusesource.org/>`_. Scaml is Haml for Scala. |
|
1713 |
|
1714 *New in Pygments 1.4.* |
|
1715 """ |
|
1716 |
|
1717 name = 'Scaml' |
|
1718 aliases = ['scaml', 'SCAML'] |
|
1719 filenames = ['*.scaml'] |
|
1720 mimetypes = ['text/x-scaml'] |
|
1721 |
|
1722 flags = re.IGNORECASE |
|
1723 # Scaml does not yet support the " |\n" notation to |
|
1724 # wrap long lines. Once it does, use the custom faux |
|
1725 # dot instead. |
|
1726 # _dot = r'(?: \|\n(?=.* \|)|.)' |
|
1727 _dot = r'.' |
|
1728 |
|
1729 tokens = { |
|
1730 'root': [ |
|
1731 (r'[ \t]*\n', Text), |
|
1732 (r'[ \t]*', _indentation), |
|
1733 ], |
|
1734 |
|
1735 'css': [ |
|
1736 (r'\.[a-z0-9_:-]+', Name.Class, 'tag'), |
|
1737 (r'\#[a-z0-9_:-]+', Name.Function, 'tag'), |
|
1738 ], |
|
1739 |
|
1740 'eval-or-plain': [ |
|
1741 (r'[&!]?==', Punctuation, 'plain'), |
|
1742 (r'([&!]?[=~])(' + _dot + '*\n)', |
|
1743 bygroups(Punctuation, using(ScalaLexer)), |
|
1744 'root'), |
|
1745 (r'', Text, 'plain'), |
|
1746 ], |
|
1747 |
|
1748 'content': [ |
|
1749 include('css'), |
|
1750 (r'%[a-z0-9_:-]+', Name.Tag, 'tag'), |
|
1751 (r'!!!' + _dot + '*\n', Name.Namespace, '#pop'), |
|
1752 (r'(/)(\[' + _dot + '*?\])(' + _dot + '*\n)', |
|
1753 bygroups(Comment, Comment.Special, Comment), |
|
1754 '#pop'), |
|
1755 (r'/' + _dot + '*\n', _starts_block(Comment, 'html-comment-block'), |
|
1756 '#pop'), |
|
1757 (r'-#' + _dot + '*\n', _starts_block(Comment.Preproc, |
|
1758 'scaml-comment-block'), '#pop'), |
|
1759 (r'(-@\s*)(import)?(' + _dot + '*\n)', |
|
1760 bygroups(Punctuation, Keyword, using(ScalaLexer)), |
|
1761 '#pop'), |
|
1762 (r'(-)(' + _dot + '*\n)', |
|
1763 bygroups(Punctuation, using(ScalaLexer)), |
|
1764 '#pop'), |
|
1765 (r':' + _dot + '*\n', _starts_block(Name.Decorator, 'filter-block'), |
|
1766 '#pop'), |
|
1767 include('eval-or-plain'), |
|
1768 ], |
|
1769 |
|
1770 'tag': [ |
|
1771 include('css'), |
|
1772 (r'\{(,\n|' + _dot + ')*?\}', using(ScalaLexer)), |
|
1773 (r'\[' + _dot + '*?\]', using(ScalaLexer)), |
|
1774 (r'\(', Text, 'html-attributes'), |
|
1775 (r'/[ \t]*\n', Punctuation, '#pop:2'), |
|
1776 (r'[<>]{1,2}(?=[ \t=])', Punctuation), |
|
1777 include('eval-or-plain'), |
|
1778 ], |
|
1779 |
|
1780 'plain': [ |
|
1781 (r'([^#\n]|#[^{\n]|(\\\\)*\\#\{)+', Text), |
|
1782 (r'(#\{)(' + _dot + '*?)(\})', |
|
1783 bygroups(String.Interpol, using(ScalaLexer), String.Interpol)), |
|
1784 (r'\n', Text, 'root'), |
|
1785 ], |
|
1786 |
|
1787 'html-attributes': [ |
|
1788 (r'\s+', Text), |
|
1789 (r'[a-z0-9_:-]+[ \t]*=', Name.Attribute, 'html-attribute-value'), |
|
1790 (r'[a-z0-9_:-]+', Name.Attribute), |
|
1791 (r'\)', Text, '#pop'), |
|
1792 ], |
|
1793 |
|
1794 'html-attribute-value': [ |
|
1795 (r'[ \t]+', Text), |
|
1796 (r'[a-z0-9_]+', Name.Variable, '#pop'), |
|
1797 (r'@[a-z0-9_]+', Name.Variable.Instance, '#pop'), |
|
1798 (r'\$[a-z0-9_]+', Name.Variable.Global, '#pop'), |
|
1799 (r"'(\\\\|\\'|[^'\n])*'", String, '#pop'), |
|
1800 (r'"(\\\\|\\"|[^"\n])*"', String, '#pop'), |
|
1801 ], |
|
1802 |
|
1803 'html-comment-block': [ |
|
1804 (_dot + '+', Comment), |
|
1805 (r'\n', Text, 'root'), |
|
1806 ], |
|
1807 |
|
1808 'scaml-comment-block': [ |
|
1809 (_dot + '+', Comment.Preproc), |
|
1810 (r'\n', Text, 'root'), |
|
1811 ], |
|
1812 |
|
1813 'filter-block': [ |
|
1814 (r'([^#\n]|#[^{\n]|(\\\\)*\\#\{)+', Name.Decorator), |
|
1815 (r'(#\{)(' + _dot + '*?)(\})', |
|
1816 bygroups(String.Interpol, using(ScalaLexer), String.Interpol)), |
|
1817 (r'\n', Text, 'root'), |
|
1818 ], |
|
1819 } |
|
1820 |
|
1821 |
|
1822 class JadeLexer(ExtendedRegexLexer): |
|
1823 """ |
|
1824 For Jade markup. |
|
1825 Jade is a variant of Scaml, see: |
|
1826 http://scalate.fusesource.org/documentation/scaml-reference.html |
|
1827 |
|
1828 *New in Pygments 1.4.* |
|
1829 """ |
|
1830 |
|
1831 name = 'Jade' |
|
1832 aliases = ['jade', 'JADE'] |
|
1833 filenames = ['*.jade'] |
|
1834 mimetypes = ['text/x-jade'] |
|
1835 |
|
1836 flags = re.IGNORECASE |
|
1837 _dot = r'.' |
|
1838 |
|
1839 tokens = { |
|
1840 'root': [ |
|
1841 (r'[ \t]*\n', Text), |
|
1842 (r'[ \t]*', _indentation), |
|
1843 ], |
|
1844 |
|
1845 'css': [ |
|
1846 (r'\.[a-z0-9_:-]+', Name.Class, 'tag'), |
|
1847 (r'\#[a-z0-9_:-]+', Name.Function, 'tag'), |
|
1848 ], |
|
1849 |
|
1850 'eval-or-plain': [ |
|
1851 (r'[&!]?==', Punctuation, 'plain'), |
|
1852 (r'([&!]?[=~])(' + _dot + '*\n)', |
|
1853 bygroups(Punctuation, using(ScalaLexer)), 'root'), |
|
1854 (r'', Text, 'plain'), |
|
1855 ], |
|
1856 |
|
1857 'content': [ |
|
1858 include('css'), |
|
1859 (r'!!!' + _dot + '*\n', Name.Namespace, '#pop'), |
|
1860 (r'(/)(\[' + _dot + '*?\])(' + _dot + '*\n)', |
|
1861 bygroups(Comment, Comment.Special, Comment), |
|
1862 '#pop'), |
|
1863 (r'/' + _dot + '*\n', _starts_block(Comment, 'html-comment-block'), |
|
1864 '#pop'), |
|
1865 (r'-#' + _dot + '*\n', _starts_block(Comment.Preproc, |
|
1866 'scaml-comment-block'), '#pop'), |
|
1867 (r'(-@\s*)(import)?(' + _dot + '*\n)', |
|
1868 bygroups(Punctuation, Keyword, using(ScalaLexer)), |
|
1869 '#pop'), |
|
1870 (r'(-)(' + _dot + '*\n)', |
|
1871 bygroups(Punctuation, using(ScalaLexer)), |
|
1872 '#pop'), |
|
1873 (r':' + _dot + '*\n', _starts_block(Name.Decorator, 'filter-block'), |
|
1874 '#pop'), |
|
1875 (r'[a-z0-9_:-]+', Name.Tag, 'tag'), |
|
1876 (r'|', Text, 'eval-or-plain'), |
|
1877 ], |
|
1878 |
|
1879 'tag': [ |
|
1880 include('css'), |
|
1881 (r'\{(,\n|' + _dot + ')*?\}', using(ScalaLexer)), |
|
1882 (r'\[' + _dot + '*?\]', using(ScalaLexer)), |
|
1883 (r'\(', Text, 'html-attributes'), |
|
1884 (r'/[ \t]*\n', Punctuation, '#pop:2'), |
|
1885 (r'[<>]{1,2}(?=[ \t=])', Punctuation), |
|
1886 include('eval-or-plain'), |
|
1887 ], |
|
1888 |
|
1889 'plain': [ |
|
1890 (r'([^#\n]|#[^{\n]|(\\\\)*\\#\{)+', Text), |
|
1891 (r'(#\{)(' + _dot + '*?)(\})', |
|
1892 bygroups(String.Interpol, using(ScalaLexer), String.Interpol)), |
|
1893 (r'\n', Text, 'root'), |
|
1894 ], |
|
1895 |
|
1896 'html-attributes': [ |
|
1897 (r'\s+', Text), |
|
1898 (r'[a-z0-9_:-]+[ \t]*=', Name.Attribute, 'html-attribute-value'), |
|
1899 (r'[a-z0-9_:-]+', Name.Attribute), |
|
1900 (r'\)', Text, '#pop'), |
|
1901 ], |
|
1902 |
|
1903 'html-attribute-value': [ |
|
1904 (r'[ \t]+', Text), |
|
1905 (r'[a-z0-9_]+', Name.Variable, '#pop'), |
|
1906 (r'@[a-z0-9_]+', Name.Variable.Instance, '#pop'), |
|
1907 (r'\$[a-z0-9_]+', Name.Variable.Global, '#pop'), |
|
1908 (r"'(\\\\|\\'|[^'\n])*'", String, '#pop'), |
|
1909 (r'"(\\\\|\\"|[^"\n])*"', String, '#pop'), |
|
1910 ], |
|
1911 |
|
1912 'html-comment-block': [ |
|
1913 (_dot + '+', Comment), |
|
1914 (r'\n', Text, 'root'), |
|
1915 ], |
|
1916 |
|
1917 'scaml-comment-block': [ |
|
1918 (_dot + '+', Comment.Preproc), |
|
1919 (r'\n', Text, 'root'), |
|
1920 ], |
|
1921 |
|
1922 'filter-block': [ |
|
1923 (r'([^#\n]|#[^{\n]|(\\\\)*\\#\{)+', Name.Decorator), |
|
1924 (r'(#\{)(' + _dot + '*?)(\})', |
|
1925 bygroups(String.Interpol, using(ScalaLexer), String.Interpol)), |
|
1926 (r'\n', Text, 'root'), |
|
1927 ], |
|
1928 } |
|
1929 |
|
1930 |
|
1931 class XQueryLexer(ExtendedRegexLexer): |
|
1932 """ |
|
1933 An XQuery lexer, parsing a stream and outputting the tokens needed to |
|
1934 highlight xquery code. |
|
1935 |
|
1936 *New in Pygments 1.4.* |
|
1937 """ |
|
1938 name = 'XQuery' |
|
1939 aliases = ['xquery', 'xqy'] |
|
1940 filenames = ['*.xqy', '*.xquery'] |
|
1941 mimetypes = ['text/xquery', 'application/xquery'] |
|
1942 |
|
1943 xquery_parse_state = [] |
|
1944 |
|
1945 # FIX UNICODE LATER |
|
1946 #ncnamestartchar = ( |
|
1947 # ur"[A-Z]|_|[a-z]|[\u00C0-\u00D6]|[\u00D8-\u00F6]|[\u00F8-\u02FF]|" |
|
1948 # ur"[\u0370-\u037D]|[\u037F-\u1FFF]|[\u200C-\u200D]|[\u2070-\u218F]|" |
|
1949 # ur"[\u2C00-\u2FEF]|[\u3001-\uD7FF]|[\uF900-\uFDCF]|[\uFDF0-\uFFFD]|" |
|
1950 # ur"[\u10000-\uEFFFF]" |
|
1951 #) |
|
1952 ncnamestartchar = r"[A-Z]|_|[a-z]" |
|
1953 # FIX UNICODE LATER |
|
1954 #ncnamechar = ncnamestartchar + (ur"|-|\.|[0-9]|\u00B7|[\u0300-\u036F]|" |
|
1955 # ur"[\u203F-\u2040]") |
|
1956 ncnamechar = ncnamestartchar + r"|-|\.|[0-9]" |
|
1957 ncname = "((%s)+(%s)*)" % (ncnamestartchar, ncnamechar) |
|
1958 pitarget_namestartchar = r"[A-KN-WY-Z]|_|:|[a-kn-wy-z]" |
|
1959 pitarget_namechar = pitarget_namestartchar + r"|-|\.|[0-9]" |
|
1960 pitarget = "(%s)+(%s)*" % (pitarget_namestartchar, pitarget_namechar) |
|
1961 prefixedname = "%s:%s" % (ncname, ncname) |
|
1962 unprefixedname = ncname |
|
1963 qname = "((%s)|(%s))" %(prefixedname, unprefixedname) |
|
1964 |
|
1965 entityref = r'&(lt|gt|amp|quot|apos|nbsp);' |
|
1966 charref = r'&#[0-9]+;|&#x[0-9a-fA-F]+;' |
|
1967 |
|
1968 stringdouble = r'("((' + entityref + r')|(' + charref + r')|("")|([^&"]))*")' |
|
1969 stringsingle = r"('((" + entityref + r")|(" + charref + r")|('')|([^&']))*')" |
|
1970 |
|
1971 # FIX UNICODE LATER |
|
1972 #elementcontentchar = (ur'\t|\r|\n|[\u0020-\u0025]|[\u0028-\u003b]|' |
|
1973 # ur'[\u003d-\u007a]|\u007c|[\u007e-\u007F]') |
|
1974 elementcontentchar = r'[A-Za-z]|\s|\d|[!"#$%\(\)\*\+,\-\./\:;=\?\@\[\\\]^_\'`\|~]' |
|
1975 #quotattrcontentchar = (ur'\t|\r|\n|[\u0020-\u0021]|[\u0023-\u0025]|' |
|
1976 # ur'[\u0027-\u003b]|[\u003d-\u007a]|\u007c|[\u007e-\u007F]') |
|
1977 quotattrcontentchar = r'[A-Za-z]|\s|\d|[!#$%\(\)\*\+,\-\./\:;=\?\@\[\\\]^_\'`\|~]' |
|
1978 #aposattrcontentchar = (ur'\t|\r|\n|[\u0020-\u0025]|[\u0028-\u003b]|' |
|
1979 # ur'[\u003d-\u007a]|\u007c|[\u007e-\u007F]') |
|
1980 aposattrcontentchar = r'[A-Za-z]|\s|\d|[!"#$%\(\)\*\+,\-\./\:;=\?\@\[\\\]^_`\|~]' |
|
1981 |
|
1982 |
|
1983 # CHAR elements - fix the above elementcontentchar, quotattrcontentchar, |
|
1984 # aposattrcontentchar |
|
1985 #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF] |
|
1986 |
|
1987 flags = re.DOTALL | re.MULTILINE | re.UNICODE |
|
1988 |
|
1989 def operator_root_callback(lexer, match, ctx): |
|
1990 yield match.start(), Operator, match.group(1) |
|
1991 # transition to root always - don't pop off stack |
|
1992 ctx.stack = ['root'] |
|
1993 ctx.pos = match.end() |
|
1994 |
|
1995 def popstate_tag_callback(lexer, match, ctx): |
|
1996 yield match.start(), Name.Tag, match.group(1) |
|
1997 ctx.stack.append(lexer.xquery_parse_state.pop()) |
|
1998 ctx.pos = match.end() |
|
1999 |
|
2000 def popstate_xmlcomment_callback(lexer, match, ctx): |
|
2001 yield match.start(), String.Doc, match.group(1) |
|
2002 ctx.stack.append(lexer.xquery_parse_state.pop()) |
|
2003 ctx.pos = match.end() |
|
2004 |
|
2005 def popstate_kindtest_callback(lexer, match, ctx): |
|
2006 yield match.start(), Punctuation, match.group(1) |
|
2007 next_state = lexer.xquery_parse_state.pop() |
|
2008 if next_state == 'occurrenceindicator': |
|
2009 if re.match("[?*+]+", match.group(2)): |
|
2010 yield match.start(), Punctuation, match.group(2) |
|
2011 ctx.stack.append('operator') |
|
2012 ctx.pos = match.end() |
|
2013 else: |
|
2014 ctx.stack.append('operator') |
|
2015 ctx.pos = match.end(1) |
|
2016 else: |
|
2017 ctx.stack.append(next_state) |
|
2018 ctx.pos = match.end(1) |
|
2019 |
|
2020 def popstate_callback(lexer, match, ctx): |
|
2021 yield match.start(), Punctuation, match.group(1) |
|
2022 # if we have run out of our state stack, pop whatever is on the pygments |
|
2023 # state stack |
|
2024 if len(lexer.xquery_parse_state) == 0: |
|
2025 ctx.stack.pop() |
|
2026 elif len(ctx.stack) > 1: |
|
2027 ctx.stack.append(lexer.xquery_parse_state.pop()) |
|
2028 else: |
|
2029 # i don't know if i'll need this, but in case, default back to root |
|
2030 ctx.stack = ['root'] |
|
2031 ctx.pos = match.end() |
|
2032 |
|
2033 def pushstate_element_content_starttag_callback(lexer, match, ctx): |
|
2034 yield match.start(), Name.Tag, match.group(1) |
|
2035 lexer.xquery_parse_state.append('element_content') |
|
2036 ctx.stack.append('start_tag') |
|
2037 ctx.pos = match.end() |
|
2038 |
|
2039 def pushstate_cdata_section_callback(lexer, match, ctx): |
|
2040 yield match.start(), String.Doc, match.group(1) |
|
2041 ctx.stack.append('cdata_section') |
|
2042 lexer.xquery_parse_state.append(ctx.state.pop) |
|
2043 ctx.pos = match.end() |
|
2044 |
|
2045 def pushstate_starttag_callback(lexer, match, ctx): |
|
2046 yield match.start(), Name.Tag, match.group(1) |
|
2047 lexer.xquery_parse_state.append(ctx.state.pop) |
|
2048 ctx.stack.append('start_tag') |
|
2049 ctx.pos = match.end() |
|
2050 |
|
2051 def pushstate_operator_order_callback(lexer, match, ctx): |
|
2052 yield match.start(), Keyword, match.group(1) |
|
2053 yield match.start(), Text, match.group(2) |
|
2054 yield match.start(), Punctuation, match.group(3) |
|
2055 ctx.stack = ['root'] |
|
2056 lexer.xquery_parse_state.append('operator') |
|
2057 ctx.pos = match.end() |
|
2058 |
|
2059 def pushstate_operator_root_validate(lexer, match, ctx): |
|
2060 yield match.start(), Keyword, match.group(1) |
|
2061 yield match.start(), Text, match.group(2) |
|
2062 yield match.start(), Punctuation, match.group(3) |
|
2063 ctx.stack = ['root'] |
|
2064 lexer.xquery_parse_state.append('operator') |
|
2065 ctx.pos = match.end() |
|
2066 |
|
2067 def pushstate_operator_root_validate_withmode(lexer, match, ctx): |
|
2068 yield match.start(), Keyword, match.group(1) |
|
2069 yield match.start(), Text, match.group(2) |
|
2070 yield match.start(), Keyword, match.group(3) |
|
2071 ctx.stack = ['root'] |
|
2072 lexer.xquery_parse_state.append('operator') |
|
2073 ctx.pos = match.end() |
|
2074 |
|
2075 def pushstate_operator_processing_instruction_callback(lexer, match, ctx): |
|
2076 yield match.start(), String.Doc, match.group(1) |
|
2077 ctx.stack.append('processing_instruction') |
|
2078 lexer.xquery_parse_state.append('operator') |
|
2079 ctx.pos = match.end() |
|
2080 |
|
2081 def pushstate_element_content_processing_instruction_callback(lexer, match, ctx): |
|
2082 yield match.start(), String.Doc, match.group(1) |
|
2083 ctx.stack.append('processing_instruction') |
|
2084 lexer.xquery_parse_state.append('element_content') |
|
2085 ctx.pos = match.end() |
|
2086 |
|
2087 def pushstate_element_content_cdata_section_callback(lexer, match, ctx): |
|
2088 yield match.start(), String.Doc, match.group(1) |
|
2089 ctx.stack.append('cdata_section') |
|
2090 lexer.xquery_parse_state.append('element_content') |
|
2091 ctx.pos = match.end() |
|
2092 |
|
2093 def pushstate_operator_cdata_section_callback(lexer, match, ctx): |
|
2094 yield match.start(), String.Doc, match.group(1) |
|
2095 ctx.stack.append('cdata_section') |
|
2096 lexer.xquery_parse_state.append('operator') |
|
2097 ctx.pos = match.end() |
|
2098 |
|
2099 def pushstate_element_content_xmlcomment_callback(lexer, match, ctx): |
|
2100 yield match.start(), String.Doc, match.group(1) |
|
2101 ctx.stack.append('xml_comment') |
|
2102 lexer.xquery_parse_state.append('element_content') |
|
2103 ctx.pos = match.end() |
|
2104 |
|
2105 def pushstate_operator_xmlcomment_callback(lexer, match, ctx): |
|
2106 yield match.start(), String.Doc, match.group(1) |
|
2107 ctx.stack.append('xml_comment') |
|
2108 lexer.xquery_parse_state.append('operator') |
|
2109 ctx.pos = match.end() |
|
2110 |
|
2111 def pushstate_kindtest_callback(lexer, match, ctx): |
|
2112 yield match.start(), Keyword, match.group(1) |
|
2113 yield match.start(), Text, match.group(2) |
|
2114 yield match.start(), Punctuation, match.group(3) |
|
2115 lexer.xquery_parse_state.append('kindtest') |
|
2116 ctx.stack.append('kindtest') |
|
2117 ctx.pos = match.end() |
|
2118 |
|
2119 def pushstate_operator_kindtestforpi_callback(lexer, match, ctx): |
|
2120 yield match.start(), Keyword, match.group(1) |
|
2121 yield match.start(), Text, match.group(2) |
|
2122 yield match.start(), Punctuation, match.group(3) |
|
2123 lexer.xquery_parse_state.append('operator') |
|
2124 ctx.stack.append('kindtestforpi') |
|
2125 ctx.pos = match.end() |
|
2126 |
|
2127 def pushstate_operator_kindtest_callback(lexer, match, ctx): |
|
2128 yield match.start(), Keyword, match.group(1) |
|
2129 yield match.start(), Text, match.group(2) |
|
2130 yield match.start(), Punctuation, match.group(3) |
|
2131 lexer.xquery_parse_state.append('operator') |
|
2132 ctx.stack.append('kindtest') |
|
2133 ctx.pos = match.end() |
|
2134 |
|
2135 def pushstate_occurrenceindicator_kindtest_callback(lexer, match, ctx): |
|
2136 yield match.start(), Name.Tag, match.group(1) |
|
2137 yield match.start(), Text, match.group(2) |
|
2138 yield match.start(), Punctuation, match.group(3) |
|
2139 lexer.xquery_parse_state.append('occurrenceindicator') |
|
2140 ctx.stack.append('kindtest') |
|
2141 ctx.pos = match.end() |
|
2142 |
|
2143 def pushstate_operator_starttag_callback(lexer, match, ctx): |
|
2144 yield match.start(), Name.Tag, match.group(1) |
|
2145 lexer.xquery_parse_state.append('operator') |
|
2146 ctx.stack.append('start_tag') |
|
2147 ctx.pos = match.end() |
|
2148 |
|
2149 def pushstate_operator_root_callback(lexer, match, ctx): |
|
2150 yield match.start(), Punctuation, match.group(1) |
|
2151 lexer.xquery_parse_state.append('operator') |
|
2152 ctx.stack = ['root']#.append('root') |
|
2153 ctx.pos = match.end() |
|
2154 |
|
2155 def pushstate_operator_root_construct_callback(lexer, match, ctx): |
|
2156 yield match.start(), Keyword, match.group(1) |
|
2157 yield match.start(), Text, match.group(2) |
|
2158 yield match.start(), Punctuation, match.group(3) |
|
2159 lexer.xquery_parse_state.append('operator') |
|
2160 ctx.stack = ['root'] |
|
2161 ctx.pos = match.end() |
|
2162 |
|
2163 def pushstate_root_callback(lexer, match, ctx): |
|
2164 yield match.start(), Punctuation, match.group(1) |
|
2165 cur_state = ctx.stack.pop() |
|
2166 lexer.xquery_parse_state.append(cur_state) |
|
2167 ctx.stack = ['root']#.append('root') |
|
2168 ctx.pos = match.end() |
|
2169 |
|
2170 def pushstate_operator_callback(lexer, match, ctx): |
|
2171 yield match.start(), Keyword, match.group(1) |
|
2172 yield match.start(), Text, match.group(2) |
|
2173 yield match.start(), Punctuation, match.group(3) |
|
2174 lexer.xquery_parse_state.append('operator') |
|
2175 ctx.pos = match.end() |
|
2176 |
|
2177 tokens = { |
|
2178 'comment': [ |
|
2179 # xquery comments |
|
2180 (r'(:\))', Comment, '#pop'), |
|
2181 (r'(\(:)', Comment, '#push'), |
|
2182 (r'[^:)]', Comment), |
|
2183 (r'([^:)]|:|\))', Comment), |
|
2184 ], |
|
2185 'whitespace': [ |
|
2186 (r'\s+', Text), |
|
2187 ], |
|
2188 'operator': [ |
|
2189 include('whitespace'), |
|
2190 (r'(\})', popstate_callback), |
|
2191 (r'\(:', Comment, 'comment'), |
|
2192 |
|
2193 (r'(\{)', pushstate_root_callback), |
|
2194 (r'then|else|external|at|div|except', Keyword, 'root'), |
|
2195 (r'is|mod|order\s+by|stable\s+order\s+by', Keyword, 'root'), |
|
2196 (r'and|or', Operator.Word, 'root'), |
|
2197 (r'(eq|ge|gt|le|lt|ne|idiv|intersect|in)(?=\b)', |
|
2198 Operator.Word, 'root'), |
|
2199 (r'return|satisfies|to|union|where|preserve\s+strip', |
|
2200 Keyword, 'root'), |
|
2201 (r'(::|;|>=|>>|>|\[|<=|<<|<|-|\*|!=|\+|//|/|\||:=|,|=)', |
|
2202 operator_root_callback), |
|
2203 (r'(castable|cast)(\s+)(as)', |
|
2204 bygroups(Keyword, Text, Keyword), 'singletype'), |
|
2205 (r'(instance)(\s+)(of)|(treat)(\s+)(as)', |
|
2206 bygroups(Keyword, Text, Keyword), 'itemtype'), |
|
2207 (r'(case)|(as)', Keyword, 'itemtype'), |
|
2208 (r'(\))(\s*)(as)', |
|
2209 bygroups(Punctuation, Text, Keyword), 'itemtype'), |
|
2210 (r'\$', Name.Variable, 'varname'), |
|
2211 (r'(for|let)(\s+)(\$)', |
|
2212 bygroups(Keyword, Text, Name.Variable), 'varname'), |
|
2213 #(r'\)|\?|\]', Punctuation, '#push'), |
|
2214 (r'\)|\?|\]', Punctuation), |
|
2215 (r'(empty)(\s+)(greatest|least)', bygroups(Keyword, Text, Keyword)), |
|
2216 (r'ascending|descending|default', Keyword, '#push'), |
|
2217 (r'external', Keyword), |
|
2218 (r'collation', Keyword, 'uritooperator'), |
|
2219 # finally catch all string literals and stay in operator state |
|
2220 (stringdouble, String.Double), |
|
2221 (stringsingle, String.Single), |
|
2222 |
|
2223 (r'(catch)(\s*)', bygroups(Keyword, Text), 'root'), |
|
2224 ], |
|
2225 'uritooperator': [ |
|
2226 (stringdouble, String.Double, '#pop'), |
|
2227 (stringsingle, String.Single, '#pop'), |
|
2228 ], |
|
2229 'namespacedecl': [ |
|
2230 include('whitespace'), |
|
2231 (r'\(:', Comment, 'comment'), |
|
2232 (r'(at)(\s+)'+stringdouble, bygroups(Keyword, Text, String.Double)), |
|
2233 (r"(at)(\s+)"+stringsingle, bygroups(Keyword, Text, String.Single)), |
|
2234 (stringdouble, String.Double), |
|
2235 (stringsingle, String.Single), |
|
2236 (r',', Punctuation), |
|
2237 (r'=', Operator), |
|
2238 (r';', Punctuation, 'root'), |
|
2239 (ncname, Name.Namespace), |
|
2240 ], |
|
2241 'namespacekeyword': [ |
|
2242 include('whitespace'), |
|
2243 (r'\(:', Comment, 'comment'), |
|
2244 (stringdouble, String.Double, 'namespacedecl'), |
|
2245 (stringsingle, String.Single, 'namespacedecl'), |
|
2246 (r'inherit|no-inherit', Keyword, 'root'), |
|
2247 (r'namespace', Keyword, 'namespacedecl'), |
|
2248 (r'(default)(\s+)(element)', bygroups(Keyword, Text, Keyword)), |
|
2249 (r'preserve|no-preserve', Keyword), |
|
2250 (r',', Punctuation), |
|
2251 ], |
|
2252 'varname': [ |
|
2253 (r'\(:', Comment, 'comment'), |
|
2254 (qname, Name.Variable, 'operator'), |
|
2255 ], |
|
2256 'singletype': [ |
|
2257 (r'\(:', Comment, 'comment'), |
|
2258 (ncname + r'(:\*)', Name.Variable, 'operator'), |
|
2259 (qname, Name.Variable, 'operator'), |
|
2260 ], |
|
2261 'itemtype': [ |
|
2262 include('whitespace'), |
|
2263 (r'\(:', Comment, 'comment'), |
|
2264 (r'\$', Punctuation, 'varname'), |
|
2265 (r'void\s*\(\s*\)', |
|
2266 bygroups(Keyword, Text, Punctuation, Text, Punctuation), 'operator'), |
|
2267 (r'(element|attribute|schema-element|schema-attribute|comment|text|' |
|
2268 r'node|binary|document-node)(\s*)(\()', |
|
2269 pushstate_occurrenceindicator_kindtest_callback), |
|
2270 # Marklogic specific type? |
|
2271 (r'(processing-instruction)(\s*)(\()', |
|
2272 bygroups(Keyword, Text, Punctuation), |
|
2273 ('occurrenceindicator', 'kindtestforpi')), |
|
2274 (r'(item)(\s*)(\()(\s*)(\))(?=[*+?])', |
|
2275 bygroups(Keyword, Text, Punctuation, Text, Punctuation), |
|
2276 'occurrenceindicator'), |
|
2277 (r'\(\#', Punctuation, 'pragma'), |
|
2278 (r';', Punctuation, '#pop'), |
|
2279 (r'then|else', Keyword, '#pop'), |
|
2280 (r'(at)(\s+)' + stringdouble, |
|
2281 bygroups(Keyword, Text, String.Double), 'namespacedecl'), |
|
2282 (r'(at)(\s+)' + stringsingle, |
|
2283 bygroups(Keyword, Text, String.Single), 'namespacedecl'), |
|
2284 (r'except|intersect|in|is|return|satisfies|to|union|where', |
|
2285 Keyword, 'root'), |
|
2286 (r'and|div|eq|ge|gt|le|lt|ne|idiv|mod|or', Operator.Word, 'root'), |
|
2287 (r':=|=|,|>=|>>|>|\[|\(|<=|<<|<|-|!=|\|', Operator, 'root'), |
|
2288 (r'external|at', Keyword, 'root'), |
|
2289 (r'(stable)(\s+)(order)(\s+)(by)', |
|
2290 bygroups(Keyword, Text, Keyword, Text, Keyword), 'root'), |
|
2291 (r'(castable|cast)(\s+)(as)', |
|
2292 bygroups(Keyword, Text, Keyword), 'singletype'), |
|
2293 (r'(instance)(\s+)(of)|(treat)(\s+)(as)', |
|
2294 bygroups(Keyword, Text, Keyword)), |
|
2295 (r'case|as', Keyword, 'itemtype'), |
|
2296 (r'(\))(\s*)(as)', bygroups(Operator, Text, Keyword), 'itemtype'), |
|
2297 (ncname + r'(:\*)', Keyword.Type, 'operator'), |
|
2298 (qname, Keyword.Type, 'occurrenceindicator'), |
|
2299 ], |
|
2300 'kindtest': [ |
|
2301 (r'\(:', Comment, 'comment'), |
|
2302 (r'({)', Punctuation, 'root'), |
|
2303 (r'(\))([*+?]?)', popstate_kindtest_callback), |
|
2304 (r'\*', Name, 'closekindtest'), |
|
2305 (qname, Name, 'closekindtest'), |
|
2306 (r'(element|schema-element)(\s*)(\()', pushstate_kindtest_callback), |
|
2307 ], |
|
2308 'kindtestforpi': [ |
|
2309 (r'\(:', Comment, 'comment'), |
|
2310 (r'\)', Punctuation, '#pop'), |
|
2311 (ncname, bygroups(Name.Variable, Name.Variable)), |
|
2312 (stringdouble, String.Double), |
|
2313 (stringsingle, String.Single), |
|
2314 ], |
|
2315 'closekindtest': [ |
|
2316 (r'\(:', Comment, 'comment'), |
|
2317 (r'(\))', popstate_callback), |
|
2318 (r',', Punctuation), |
|
2319 (r'(\{)', pushstate_operator_root_callback), |
|
2320 (r'\?', Punctuation), |
|
2321 ], |
|
2322 'xml_comment': [ |
|
2323 (r'(-->)', popstate_xmlcomment_callback), |
|
2324 (r'[^-]{1,2}', Literal), |
|
2325 (r'\u009|\u00A|\u00D|[\u0020-\u00D7FF]|[\u00E000-\u00FFFD]|' |
|
2326 r'[\u0010000-\u0010FFFF]', Literal), |
|
2327 ], |
|
2328 'processing_instruction': [ |
|
2329 (r'\s+', Text, 'processing_instruction_content'), |
|
2330 (r'\?>', String.Doc, '#pop'), |
|
2331 (pitarget, Name), |
|
2332 ], |
|
2333 'processing_instruction_content': [ |
|
2334 (r'\?>', String.Doc, '#pop'), |
|
2335 (r'\u009|\u00A|\u00D|[\u0020-\uD7FF]|[\uE000-\uFFFD]|' |
|
2336 r'[\u10000-\u10FFFF]', Literal), |
|
2337 ], |
|
2338 'cdata_section': [ |
|
2339 (r']]>', String.Doc, '#pop'), |
|
2340 (r'\u009|\u00A|\u00D|[\u0020-\uD7FF]|[\uE000-\uFFFD]|' |
|
2341 r'[\u10000-\u10FFFF]', Literal), |
|
2342 ], |
|
2343 'start_tag': [ |
|
2344 include('whitespace'), |
|
2345 (r'(/>)', popstate_tag_callback), |
|
2346 (r'>', Name.Tag, 'element_content'), |
|
2347 (r'"', Punctuation, 'quot_attribute_content'), |
|
2348 (r"'", Punctuation, 'apos_attribute_content'), |
|
2349 (r'=', Operator), |
|
2350 (qname, Name.Tag), |
|
2351 ], |
|
2352 'quot_attribute_content': [ |
|
2353 (r'"', Punctuation, 'start_tag'), |
|
2354 (r'(\{)', pushstate_root_callback), |
|
2355 (r'""', Name.Attribute), |
|
2356 (quotattrcontentchar, Name.Attribute), |
|
2357 (entityref, Name.Attribute), |
|
2358 (charref, Name.Attribute), |
|
2359 (r'\{\{|\}\}', Name.Attribute), |
|
2360 ], |
|
2361 'apos_attribute_content': [ |
|
2362 (r"'", Punctuation, 'start_tag'), |
|
2363 (r'\{', Punctuation, 'root'), |
|
2364 (r"''", Name.Attribute), |
|
2365 (aposattrcontentchar, Name.Attribute), |
|
2366 (entityref, Name.Attribute), |
|
2367 (charref, Name.Attribute), |
|
2368 (r'\{\{|\}\}', Name.Attribute), |
|
2369 ], |
|
2370 'element_content': [ |
|
2371 (r'</', Name.Tag, 'end_tag'), |
|
2372 (r'(\{)', pushstate_root_callback), |
|
2373 (r'(<!--)', pushstate_element_content_xmlcomment_callback), |
|
2374 (r'(<\?)', pushstate_element_content_processing_instruction_callback), |
|
2375 (r'(<!\[CDATA\[)', pushstate_element_content_cdata_section_callback), |
|
2376 (r'(<)', pushstate_element_content_starttag_callback), |
|
2377 (elementcontentchar, Literal), |
|
2378 (entityref, Literal), |
|
2379 (charref, Literal), |
|
2380 (r'\{\{|\}\}', Literal), |
|
2381 ], |
|
2382 'end_tag': [ |
|
2383 include('whitespace'), |
|
2384 (r'(>)', popstate_tag_callback), |
|
2385 (qname, Name.Tag), |
|
2386 ], |
|
2387 'xmlspace_decl': [ |
|
2388 (r'\(:', Comment, 'comment'), |
|
2389 (r'preserve|strip', Keyword, '#pop'), |
|
2390 ], |
|
2391 'declareordering': [ |
|
2392 (r'\(:', Comment, 'comment'), |
|
2393 include('whitespace'), |
|
2394 (r'ordered|unordered', Keyword, '#pop'), |
|
2395 ], |
|
2396 'xqueryversion': [ |
|
2397 include('whitespace'), |
|
2398 (r'\(:', Comment, 'comment'), |
|
2399 (stringdouble, String.Double), |
|
2400 (stringsingle, String.Single), |
|
2401 (r'encoding', Keyword), |
|
2402 (r';', Punctuation, '#pop'), |
|
2403 ], |
|
2404 'pragma': [ |
|
2405 (qname, Name.Variable, 'pragmacontents'), |
|
2406 ], |
|
2407 'pragmacontents': [ |
|
2408 (r'#\)', Punctuation, 'operator'), |
|
2409 (r'\u009|\u00A|\u00D|[\u0020-\u00D7FF]|[\u00E000-\u00FFFD]|' |
|
2410 r'[\u0010000-\u0010FFFF]', Literal), |
|
2411 (r'(\s*)', Text), |
|
2412 ], |
|
2413 'occurrenceindicator': [ |
|
2414 include('whitespace'), |
|
2415 (r'\(:', Comment, 'comment'), |
|
2416 (r'\*|\?|\+', Operator, 'operator'), |
|
2417 (r':=', Operator, 'root'), |
|
2418 (r'', Text, 'operator'), |
|
2419 ], |
|
2420 'option': [ |
|
2421 include('whitespace'), |
|
2422 (qname, Name.Variable, '#pop'), |
|
2423 ], |
|
2424 'qname_braren': [ |
|
2425 include('whitespace'), |
|
2426 (r'(\{)', pushstate_operator_root_callback), |
|
2427 (r'(\()', Punctuation, 'root'), |
|
2428 ], |
|
2429 'element_qname': [ |
|
2430 (qname, Name.Variable, 'root'), |
|
2431 ], |
|
2432 'attribute_qname': [ |
|
2433 (qname, Name.Variable, 'root'), |
|
2434 ], |
|
2435 'root': [ |
|
2436 include('whitespace'), |
|
2437 (r'\(:', Comment, 'comment'), |
|
2438 |
|
2439 # handle operator state |
|
2440 # order on numbers matters - handle most complex first |
|
2441 (r'\d+(\.\d*)?[eE][\+\-]?\d+', Number.Double, 'operator'), |
|
2442 (r'(\.\d+)[eE][\+\-]?\d+', Number.Double, 'operator'), |
|
2443 (r'(\.\d+|\d+\.\d*)', Number, 'operator'), |
|
2444 (r'(\d+)', Number.Integer, 'operator'), |
|
2445 (r'(\.\.|\.|\)|\*)', Punctuation, 'operator'), |
|
2446 (r'(declare)(\s+)(construction)', |
|
2447 bygroups(Keyword, Text, Keyword), 'operator'), |
|
2448 (r'(declare)(\s+)(default)(\s+)(order)', |
|
2449 bygroups(Keyword, Text, Keyword, Text, Keyword), 'operator'), |
|
2450 (ncname + ':\*', Name, 'operator'), |
|
2451 (stringdouble, String.Double, 'operator'), |
|
2452 (stringsingle, String.Single, 'operator'), |
|
2453 |
|
2454 (r'(\})', popstate_callback), |
|
2455 |
|
2456 #NAMESPACE DECL |
|
2457 (r'(declare)(\s+)(default)(\s+)(collation)', |
|
2458 bygroups(Keyword, Text, Keyword, Text, Keyword)), |
|
2459 (r'(module|declare)(\s+)(namespace)', |
|
2460 bygroups(Keyword, Text, Keyword), 'namespacedecl'), |
|
2461 (r'(declare)(\s+)(base-uri)', |
|
2462 bygroups(Keyword, Text, Keyword), 'namespacedecl'), |
|
2463 |
|
2464 #NAMESPACE KEYWORD |
|
2465 (r'(declare)(\s+)(default)(\s+)(element|function)', |
|
2466 bygroups(Keyword, Text, Keyword, Text, Keyword), 'namespacekeyword'), |
|
2467 (r'(import)(\s+)(schema|module)', |
|
2468 bygroups(Keyword.Pseudo, Text, Keyword.Pseudo), 'namespacekeyword'), |
|
2469 (r'(declare)(\s+)(copy-namespaces)', |
|
2470 bygroups(Keyword, Text, Keyword), 'namespacekeyword'), |
|
2471 |
|
2472 #VARNAMEs |
|
2473 (r'(for|let|some|every)(\s+)(\$)', |
|
2474 bygroups(Keyword, Text, Name.Variable), 'varname'), |
|
2475 (r'\$', Name.Variable, 'varname'), |
|
2476 (r'(declare)(\s+)(variable)(\s+)(\$)', |
|
2477 bygroups(Keyword, Text, Keyword, Text, Name.Variable), 'varname'), |
|
2478 |
|
2479 #ITEMTYPE |
|
2480 (r'(\))(\s+)(as)', bygroups(Operator, Text, Keyword), 'itemtype'), |
|
2481 |
|
2482 (r'(element|attribute|schema-element|schema-attribute|comment|' |
|
2483 r'text|node|document-node)(\s+)(\()', |
|
2484 pushstate_operator_kindtest_callback), |
|
2485 |
|
2486 (r'(processing-instruction)(\s+)(\()', |
|
2487 pushstate_operator_kindtestforpi_callback), |
|
2488 |
|
2489 (r'(<!--)', pushstate_operator_xmlcomment_callback), |
|
2490 |
|
2491 (r'(<\?)', pushstate_operator_processing_instruction_callback), |
|
2492 |
|
2493 (r'(<!\[CDATA\[)', pushstate_operator_cdata_section_callback), |
|
2494 |
|
2495 # (r'</', Name.Tag, 'end_tag'), |
|
2496 (r'(<)', pushstate_operator_starttag_callback), |
|
2497 |
|
2498 (r'(declare)(\s+)(boundary-space)', |
|
2499 bygroups(Keyword, Text, Keyword), 'xmlspace_decl'), |
|
2500 |
|
2501 (r'(validate)(\s+)(lax|strict)', |
|
2502 pushstate_operator_root_validate_withmode), |
|
2503 (r'(validate)(\s*)(\{)', pushstate_operator_root_validate), |
|
2504 (r'(typeswitch)(\s*)(\()', bygroups(Keyword, Text, Punctuation)), |
|
2505 (r'(element|attribute)(\s*)(\{)', |
|
2506 pushstate_operator_root_construct_callback), |
|
2507 |
|
2508 (r'(document|text|processing-instruction|comment)(\s*)(\{)', |
|
2509 pushstate_operator_root_construct_callback), |
|
2510 #ATTRIBUTE |
|
2511 (r'(attribute)(\s+)(?=' + qname + r')', |
|
2512 bygroups(Keyword, Text), 'attribute_qname'), |
|
2513 #ELEMENT |
|
2514 (r'(element)(\s+)(?=' +qname+ r')', |
|
2515 bygroups(Keyword, Text), 'element_qname'), |
|
2516 #PROCESSING_INSTRUCTION |
|
2517 (r'(processing-instruction)(\s+)' + ncname + r'(\s*)(\{)', |
|
2518 bygroups(Keyword, Text, Name.Variable, Text, Punctuation), 'operator'), |
|
2519 |
|
2520 (r'(declare|define)(\s+)(function)', |
|
2521 bygroups(Keyword, Text, Keyword)), |
|
2522 |
|
2523 (r'(\{)', pushstate_operator_root_callback), |
|
2524 |
|
2525 (r'(unordered|ordered)(\s*)(\{)', |
|
2526 pushstate_operator_order_callback), |
|
2527 |
|
2528 (r'(declare)(\s+)(ordering)', |
|
2529 bygroups(Keyword, Text, Keyword), 'declareordering'), |
|
2530 |
|
2531 (r'(xquery)(\s+)(version)', |
|
2532 bygroups(Keyword.Pseudo, Text, Keyword.Pseudo), 'xqueryversion'), |
|
2533 |
|
2534 (r'(\(#)', Punctuation, 'pragma'), |
|
2535 |
|
2536 # sometimes return can occur in root state |
|
2537 (r'return', Keyword), |
|
2538 |
|
2539 (r'(declare)(\s+)(option)', bygroups(Keyword, Text, Keyword), |
|
2540 'option'), |
|
2541 |
|
2542 #URI LITERALS - single and double quoted |
|
2543 (r'(at)(\s+)('+stringdouble+')', String.Double, 'namespacedecl'), |
|
2544 (r'(at)(\s+)('+stringsingle+')', String.Single, 'namespacedecl'), |
|
2545 |
|
2546 (r'(ancestor-or-self|ancestor|attribute|child|descendant-or-self)(::)', |
|
2547 bygroups(Keyword, Punctuation)), |
|
2548 (r'(descendant|following-sibling|following|parent|preceding-sibling' |
|
2549 r'|preceding|self)(::)', bygroups(Keyword, Punctuation)), |
|
2550 |
|
2551 (r'(if)(\s*)(\()', bygroups(Keyword, Text, Punctuation)), |
|
2552 |
|
2553 (r'then|else', Keyword), |
|
2554 |
|
2555 # ML specific |
|
2556 (r'(try)(\s*)', bygroups(Keyword, Text), 'root'), |
|
2557 (r'(catch)(\s*)(\()(\$)', |
|
2558 bygroups(Keyword, Text, Punctuation, Name.Variable), 'varname'), |
|
2559 |
|
2560 (r'@' + qname, Name.Attribute), |
|
2561 (r'@\*', Name.Attribute), |
|
2562 (r'@' + ncname, Name.Attribute), |
|
2563 |
|
2564 (r'//|/|\+|-|;|,|\(|\)', Punctuation), |
|
2565 |
|
2566 # STANDALONE QNAMES |
|
2567 (qname + r'(?=\s*[{])', Name.Variable, 'qname_braren'), |
|
2568 (qname + r'(?=\s*[(])', Name.Function, 'qname_braren'), |
|
2569 (qname, Name.Variable, 'operator'), |
|
2570 ] |
|
2571 } |
|
2572 |