diff MoinMoin/support/pygments/lexers/parsers.py @ 6009:b48a69886ca4

upgrade bundled pygments to 1.6
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sun, 05 Jan 2014 02:49:41 +0100
parents f76914e77229
children 815981fad7fd
line wrap: on
line diff
--- a/MoinMoin/support/pygments/lexers/parsers.py	Sun Jan 05 02:43:02 2014 +0100
+++ b/MoinMoin/support/pygments/lexers/parsers.py	Sun Jan 05 02:49:41 2014 +0100
@@ -5,7 +5,7 @@
 
     Lexers for parser generators.
 
-    :copyright: Copyright 2006-2010 by the Pygments team, see AUTHORS.
+    :copyright: Copyright 2006-2013 by the Pygments team, see AUTHORS.
     :license: BSD, see LICENSE for details.
 """
 
@@ -28,7 +28,8 @@
            'AntlrPerlLexer', 'AntlrRubyLexer', 'AntlrCppLexer',
            #'AntlrCLexer',
            'AntlrCSharpLexer', 'AntlrObjectiveCLexer',
-           'AntlrJavaLexer', "AntlrActionScriptLexer"]
+           'AntlrJavaLexer', "AntlrActionScriptLexer",
+           'TreetopLexer']
 
 
 class RagelLexer(RegexLexer):
@@ -72,8 +73,8 @@
         ],
         'operators': [
             (r',', Operator), # Join
-            (r'\||&|-|--', Operator), # Union, Intersection and Subtraction
-            (r'\.|<:|:>|:>>', Operator), # Concatention
+            (r'\||&|--?', Operator), # Union, Intersection and Subtraction
+            (r'\.|<:|:>>?', Operator), # Concatention
             (r':', Operator), # Label
             (r'->', Operator), # Epsilon Transition
             (r'(>|\$|%|<|@|<>)(/|eof\b)', Operator), # EOF Actions
@@ -393,7 +394,7 @@
             # throwsSpec
             (r'(throws)(\s+)(' + _id + ')',
              bygroups(Keyword, Whitespace, Name.Label)),
-            (r'(?:(,)(\s*)(' + _id + '))+',
+            (r'(,)(\s*)(' + _id + ')',
              bygroups(Punctuation, Whitespace, Name.Label)), # Additional throws
             # optionsSpec
             (r'options\b', Keyword, 'options'),
@@ -693,3 +694,85 @@
     def analyse_text(text):
         return AntlrLexer.analyse_text(text) and \
                re.search(r'^\s*language\s*=\s*ActionScript\s*;', text, re.M)
+
+class TreetopBaseLexer(RegexLexer):
+    """
+    A base lexer for `Treetop <http://treetop.rubyforge.org/>`_ grammars.
+    Not for direct use; use TreetopLexer instead.
+
+    *New in Pygments 1.6.*
+    """
+
+    tokens = {
+        'root': [
+            include('space'),
+            (r'require[ \t]+[^\n\r]+[\n\r]', Other),
+            (r'module\b', Keyword.Namespace, 'module'),
+            (r'grammar\b', Keyword, 'grammar'),
+        ],
+        'module': [
+            include('space'),
+            include('end'),
+            (r'module\b', Keyword, '#push'),
+            (r'grammar\b', Keyword, 'grammar'),
+            (r'[A-Z][A-Za-z_0-9]*(?:::[A-Z][A-Za-z_0-9]*)*', Name.Namespace),
+        ],
+        'grammar': [
+            include('space'),
+            include('end'),
+            (r'rule\b', Keyword, 'rule'),
+            (r'include\b', Keyword, 'include'),
+            (r'[A-Z][A-Za-z_0-9]*', Name),
+        ],
+        'include': [
+            include('space'),
+            (r'[A-Z][A-Za-z_0-9]*(?:::[A-Z][A-Za-z_0-9]*)*', Name.Class, '#pop'),
+        ],
+        'rule': [
+            include('space'),
+            include('end'),
+            (r'"(\\\\|\\"|[^"])*"', String.Double),
+            (r"'(\\\\|\\'|[^'])*'", String.Single),
+            (r'([A-Za-z_][A-Za-z_0-9]*)(:)', bygroups(Name.Label, Punctuation)),
+            (r'[A-Za-z_][A-Za-z_0-9]*', Name),
+            (r'[()]', Punctuation),
+            (r'[?+*/&!~]', Operator),
+            (r'\[(?:\\.|\[:\^?[a-z]+:\]|[^\\\]])+\]', String.Regex),
+            (r'([0-9]*)(\.\.)([0-9]*)',
+             bygroups(Number.Integer, Operator, Number.Integer)),
+            (r'(<)([^>]+)(>)', bygroups(Punctuation, Name.Class, Punctuation)),
+            (r'{', Punctuation, 'inline_module'),
+            (r'\.', String.Regex),
+        ],
+        'inline_module': [
+            (r'{', Other, 'ruby'),
+            (r'}', Punctuation, '#pop'),
+            (r'[^{}]+', Other),
+        ],
+        'ruby': [
+            (r'{', Other, '#push'),
+            (r'}', Other, '#pop'),
+            (r'[^{}]+', Other),
+        ],
+        'space': [
+            (r'[ \t\n\r]+', Whitespace),
+            (r'#[^\n]*', Comment.Single),
+        ],
+        'end': [
+            (r'end\b', Keyword, '#pop'),
+        ],
+    }
+
+class TreetopLexer(DelegatingLexer):
+    """
+    A lexer for `Treetop <http://treetop.rubyforge.org/>`_ grammars.
+
+    *New in Pygments 1.6.*
+    """
+
+    name = 'Treetop'
+    aliases = ['treetop']
+    filenames = ['*.treetop', '*.tt']
+
+    def __init__(self, **options):
+        super(TreetopLexer, self).__init__(RubyLexer, TreetopBaseLexer, **options)