Commits

Jeffrey Arnold  committed 99351dc Draft Merge

merge with

  • Participants
  • Parent commits 8bdb2a7, e97df81
  • Branches rd-lexer

Comments (0)

Files changed (5)

File pygments/lexers/_mapping.py

     'VerilogLexer': ('pygments.lexers.hdl', 'verilog', ('v',), ('*.v',), ('text/x-verilog',)),
     'VhdlLexer': ('pygments.lexers.hdl', 'vhdl', ('vhdl',), ('*.vhdl', '*.vhd'), ('text/x-vhdl',)),
     'VimLexer': ('pygments.lexers.text', 'VimL', ('vim',), ('*.vim', '.vimrc', '.exrc', '.gvimrc', '_vimrc', '_exrc', '_gvimrc', 'vimrc', 'gvimrc'), ('text/x-vim',)),
-    'XQueryLexer': ('pygments.lexers.web', 'XQuery', ('xquery', 'xqy'), ('*.xqy', '*.xquery'), ('text/xquery', 'application/xquery')),
+    'XQueryLexer': ('pygments.lexers.web', 'XQuery', ('xquery', 'xqy', 'xq', 'xql', 'xqm'), ('*.xqy', '*.xquery', '*.xq', '*.xql', '*.xqm'), ('text/xquery', 'application/xquery')),
     'XmlDjangoLexer': ('pygments.lexers.templates', 'XML+Django/Jinja', ('xml+django', 'xml+jinja'), (), ('application/xml+django', 'application/xml+jinja')),
     'XmlErbLexer': ('pygments.lexers.templates', 'XML+Ruby', ('xml+erb', 'xml+ruby'), (), ('application/xml+ruby',)),
     'XmlLexer': ('pygments.lexers.web', 'XML', ('xml',), ('*.xml', '*.xsl', '*.rss', '*.xslt', '*.xsd', '*.wsdl'), ('text/xml', 'application/xml', 'image/svg+xml', 'application/rss+xml', 'application/atom+xml')),

File pygments/lexers/compiled.py

             (r'\\\n', Text), # line continuations
             (r'//(.*?)\n', Comment.Single),
             (r'/(\\\n)?[*](.|\n)*?[*](\\\n)?/', Comment.Multiline),
-            (r'(break|default|func|interface|select'
-             r'|case|defer|go|map|struct'
-             r'|chan|else|goto|package|switch'
-             r'|const|fallthrough|if|range|type'
-             r'|continue|for|import|return|var)\b', Keyword
+            (r'(import|package)\b', Keyword.Namespace),
+            (r'(var|func|struct|map|chan|type|interface|const)\b', Keyword.Declaration),
+            (r'(break|default|select|case|defer|go'
+             r'|else|goto|switch|fallthrough|if|range'
+             r'|continue|for|return)\b', Keyword
             ),
-            # It seems the builtin types aren't actually keywords.
-            (r'(uint8|uint16|uint32|uint64'
-             r'|int8|int16|int32|int64'
-             r'|float32|float64|byte'
-             r'|uint|int|float|uintptr'
-             r'|string|close|closed|len|cap|new|make)\b', Name.Builtin
+            (r'(true|false|iota|nil)\b', Keyword.Constant),
+            # It seems the builtin types aren't actually keywords, but
+            # can be used as functions. So we need two declarations.
+            (r'(uint|uint8|uint16|uint32|uint64'
+             r'|int|int8|int16|int32|int64'
+             r'|float|float32|float64'
+             r'|complex64|complex128|byte|rune'
+             r'|string|bool|error|uintptr'
+             r'|print|println|panic|recover|close|complex|real|imag'
+             r'|len|cap|append|copy|delete|new|make)\b(\()', bygroups(Name.Builtin, Punctuation)
+            ),
+            (r'(uint|uint8|uint16|uint32|uint64'
+             r'|int|int8|int16|int32|int64'
+             r'|float|float32|float64'
+             r'|complex64|complex128|byte|rune'
+             r'|string|bool|error|uintptr)\b', Keyword.Type
             ),
             # float_lit
             (r'\d+(\.\d+[eE][+\-]?\d+|'
             (r'"(\\\\|\\"|[^"])*"', String),
             # Tokens
             (r'(<<=|>>=|<<|>>|<=|>=|&\^=|&\^|\+=|-=|\*=|/=|%=|&=|\|=|&&|\|\|'
-             r'|<-|\+\+|--|==|!=|:=|\.\.\.)|[+\-*/%&|^<>=!()\[\]{}.,;:]',
-             Punctuation
-            ),
+             r'|<-|\+\+|--|==|!=|:=|\.\.\.|[+\-*/%&])', Operator),
+            (r'[|^<>=!()\[\]{}.,;:]', Punctuation),
             # identifier
-            (r'[a-zA-Z_]\w*', Name),
+            (r'[a-zA-Z_]\w*', Name.Other),
         ]
     }
 

File pygments/lexers/jvm.py

             (r'(true|false|null)\b', Keyword.Constant),
             (r'(import|package)(\s+)', bygroups(Keyword, Text), 'import'),
             (r'(type)(\s+)', bygroups(Keyword, Text), 'type'),
-            (r'""".*?"""', String),
+            (r'""".*?"""(?!")', String),
             (r'"(\\\\|\\"|[^"])*"', String),
             (r"'\\.'|'[^\\]'|'\\u[0-9a-f]{4}'", String.Char),
 #            (ur'(\.)(%s|%s|`[^`]+`)' % (idrest, op), bygroups(Operator,

File pygments/lexers/other.py

             (r'(true|false|NULL|Real|Integer|Boolean)\b', Name.Builtin),
             (r"([a-zA-Z_][\w]*|'[a-zA-Z_\+\-\*\/\^][\w]*')"
              r"(\.([a-zA-Z_][\w]*|'[a-zA-Z_\+\-\*\/\^][\w]*'))+", Name.Class),
-            (r"('[\w\+\-\*\/\^]+'|\w+)", Name)        ],
+            (r"('[\w\+\-\*\/\^]+'|\w+)", Name),
+        ],
         'root': [
             include('whitespace'),
             include('keywords'),
             include('operators'),
             include('classes'),
             (r'("<html>|<html>)', Name.Tag, 'html-content'),
-            include('statements')
+            include('statements'),
         ],
         'keywords': [
             (r'(algorithm|annotation|break|connect|constant|constrainedby|'
             r'discrete|each|else|elseif|elsewhen|encapsulated|enumeration|'
             r'end|equation|exit|expandable|extends|'
-            r'external|false|final|flow|for|if|import|in|inner|input|'
-            r'loop|nondiscrete|outer|output|parameter|partial|'
-            r'protected|public|redeclare|replaceable|stream|time|then|true|'
-            r'when|while|within)\b', Keyword)
+            r'external|false|final|flow|for|if|import|impure|in|initial\sequation|'
+            r'inner|input|loop|nondiscrete|outer|output|parameter|partial|'
+            r'protected|public|pure|redeclare|replaceable|stream|time|then|true|'
+            r'when|while|within)\b', Keyword),
         ],
         'functions': [
             (r'(abs|acos|acosh|asin|asinh|atan|atan2|atan3|ceil|cos|cosh|'
-             r'cross|div|exp|floor|log|log10|mod|rem|semiLinear|sign|sin|'
-             r'sinh|size|sqrt|tan|tanh|zeros)\b', Name.Function)
+             r'cross|div|exp|floor|getInstanceName|log|log10|mod|rem|'
+             r'semiLinear|sign|sin|sinh|size|spatialDistribution|sqrt|tan|'
+             r'tanh|zeros)\b', Name.Function),
         ],
         'operators': [
-            (r'(and|assert|cardinality|change|delay|der|edge|homotopy|initial|'
-             r'noEvent|not|or|pre|reinit|return|sample|smooth|'
-             r'terminal|terminate)\b', Name.Builtin)
+            (r'(actualStream|and|assert|cardinality|change|Clock|delay|der|edge|'
+             r'hold|homotopy|initial|inStream|noEvent|not|or|pre|previous|reinit|'
+             r'return|sample|smooth|spatialDistribution|subSample|terminal|'
+             r'terminate)\b', Name.Builtin),
         ],
         'classes': [
             (r'(block|class|connector|function|model|package|'
-             r'record|type)\b', Name.Class)
+             r'record|type)\b', Name.Class),
         ],
         'string': [
             (r'"', String, '#pop'),
              String.Escape),
             (r'[^\\"\n]+', String), # all other characters
             (r'\\\n', String), # line continuation
-            (r'\\', String) # stray backslash
+            (r'\\', String), # stray backslash
         ],
         'html-content': [
             (r'<\s*/\s*html\s*>', Name.Tag, '#pop'),

File pygments/lexers/web.py

     *New in Pygments 1.4.*
     """
     name = 'XQuery'
-    aliases = ['xquery', 'xqy']
-    filenames = ['*.xqy', '*.xquery']
+    aliases = ['xquery', 'xqy', 'xq', 'xql', 'xqm']
+    filenames = ['*.xqy', '*.xquery', '*.xq', '*.xql', '*.xqm']
     mimetypes = ['text/xquery', 'application/xquery']
 
     xquery_parse_state = []
 
 class LassoLexer(RegexLexer):
     """
-    For `Lasso <http://www.lassosoft.com/>`_ source code, covering both
-    Lasso 9 syntax and LassoScript for Lasso 8.6 and earlier. For Lasso
-    embedded in HTML, use the `LassoHtmlLexer`.
+    For `Lasso <http://www.lassosoft.com/>`_ source code, covering both Lasso 9
+    syntax and LassoScript for Lasso 8.6 and earlier. For Lasso embedded in
+    HTML, use the `LassoHtmlLexer`.
 
     Additional options accepted:
 
         'root': [
             (r'^#!.+lasso9\b', Comment.Preproc, 'lasso'),
             (r'\s+', Other),
+            (r'\[no_square_brackets\]', Comment.Preproc, 'nosquarebrackets'),
             (r'\[noprocess\]', Comment.Preproc, ('delimiters', 'noprocess')),
             (r'\[', Comment.Preproc, ('delimiters', 'squarebrackets')),
             (r'<\?(LassoScript|lasso|=)', Comment.Preproc,
             (r'<', Other, 'delimiters'),
             include('lasso'),
         ],
+        'nosquarebrackets': [
+            (r'<\?(LassoScript|lasso|=)', Comment.Preproc, 'anglebrackets'),
+            (r'<', Other),
+            (r'[^<]+', Other),
+        ],
         'delimiters': [
+            (r'\[no_square_brackets\]', Comment.Preproc, 'nosquarebrackets'),
             (r'\[noprocess\]', Comment.Preproc, 'noprocess'),
             (r'\[', Comment.Preproc, 'squarebrackets'),
             (r'<\?(LassoScript|lasso|=)', Comment.Preproc, 'anglebrackets'),
             (r'/\*\*!.*?\*/', String.Doc),
             (r'/\*.*?\*/', Comment.Multiline),
 
+            # literals
+            (r'\d*\.\d+(e[+-]?\d+)?', Number.Float),
+            (r'0x[\da-f]+', Number.Hex),
+            (r'\d+', Number.Integer),
+            (r'([+-]?)(infinity|NaN)\b', bygroups(Operator, Number)),
+            (r"'", String.Single, 'singlestring'),
+            (r'"', String.Double, 'doublestring'),
+            (r'`[^`]*`', String.Backtick),
+
             # names
-            (r'\$[a-z_][\w\.]*', Name.Variable),
-            (r'(#[a-z_][\w\.]*|#\d+)', Name.Variable.Instance),
-            (r"\.'[a-z_][\w\.]*'", Name.Variable.Class),
-            (r"(self)(->)('[a-z_][\w\.]*')",
+            (r'\$[a-z_][\w.]*', Name.Variable),
+            (r'#[a-z_][\w.]*|#\d+', Name.Variable.Instance),
+            (r"(\.)('[a-z_][\w.]*')",
+                bygroups(Name.Builtin.Pseudo, Name.Variable.Class)),
+            (r"(self)(->)('[a-z_][\w.]*')",
                 bygroups(Name.Builtin.Pseudo, Operator, Name.Variable.Class)),
-            (r'(self|void)\b', Name.Builtin.Pseudo),
-            (r'-[a-z_][\w\.]*', Name.Attribute),
-            (r'(::)([a-z_][\w\.]*)', bygroups(Punctuation, Name.Label)),
+            (r'(\.\.?)([a-z_][\w.]*)',
+                bygroups(Name.Builtin.Pseudo, Name.Other)),
+            (r'(self|inherited|global|void)\b', Name.Builtin.Pseudo),
+            (r'-[a-z_][\w.]*', Name.Attribute),
+            (r'(::\s*)([a-z_][\w.]*)', bygroups(Punctuation, Name.Label)),
             (r'(error_(code|msg)_\w+|Error_AddError|Error_ColumnRestriction|'
              r'Error_DatabaseConnectionUnavailable|Error_DatabaseTimeout|'
              r'Error_DeleteError|Error_FieldRestriction|Error_FileNotFound|'
              r'Error_UpdateError)\b', Name.Exception),
 
             # definitions
-            (r'(parent)(\s+)([a-z_][\w\.]*)',
-                bygroups(Keyword.Declaration, Text, Name.Class)),
-            (r'(define)(\s+)([a-z_][\w\.]*)(\s*)(=>)(\s*)(type|trait|thread)',
+            (r'(define)(\s+)([a-z_][\w.]*)(\s*)(=>)(\s*)(type|trait|thread)\b',
                 bygroups(Keyword.Declaration, Text, Name.Class, Text, Operator,
                          Text, Keyword)),
-            (r'(define)(\s+)([a-z_][\w\.]*)(->)([a-z_][\w\.]*=?)',
+            (r'(define)(\s+)([a-z_][\w.]*)(->)([a-z_][\w.]*=?|[-+*/%<>]|==)',
                 bygroups(Keyword.Declaration, Text, Name.Class, Operator,
-                         Name.Function)),
-            (r'(define)(\s+)([a-z_][\w\.]*=?)',
-                bygroups(Keyword.Declaration, Text, Name.Function)),
-            (r'(public|protected|private)(\s+)([a-z_][\w\.]*)(\s*)(=>)',
-                bygroups(Keyword, Text, Name.Function, Text, Operator)),
-            (r'(public|protected|private|provide)(\s+)([a-z_][\w\.]*=?)(\s*)(\()',
-                bygroups(Keyword, Text, Name.Function, Text, Punctuation)),
+                         Name.Function), 'signature'),
+            (r'(define)(\s+)([a-z_][\w.]*)',
+                bygroups(Keyword.Declaration, Text, Name.Function),
+                'signature'),
+            (r'(public|protected|private|provide)(\s+)([a-z_][\w.]*=?|'
+             r'[-+*/%<>]|==)(\s*)(\()',
+                bygroups(Keyword, Text, Name.Function, Text, Punctuation),
+                ('signature', 'parameter')),
+            (r'(public|protected|private)(\s+)([a-z_][\w.]*)',
+                bygroups(Keyword, Text, Name.Function)),
 
             # keywords
-            (r'\.\.\.', Keyword.Pseudo),
-            (r'(true|false|null|[+\-]?infinity|\+?NaN)\b', Keyword.Constant),
-            (r'(local|var|variable|global|data)\b', Keyword.Declaration),
-            (r'(array|date|decimal|duration|integer|map|pair|string|tag|'
-             r'xml)\b', Keyword.Type),
+            (r'(true|false|none|minimal|full|all)\b', Keyword.Constant),
+            (r'(local|var|variable|data)\b', Keyword.Declaration),
+            (r'(array|date|decimal|duration|integer|map|pair|string|tag|xml|'
+             r'null)\b', Keyword.Type),
+            (r'([a-z_][\w.]*)(\s+)(in)\b', bygroups(Name, Text, Keyword)),
+            (r'(let|into)(\s+)([a-z_][\w.]*)', bygroups(Keyword, Text, Name)),
             (r'(/?)(Cache|Database_Names|Database_SchemaNames|'
              r'Database_TableNames|Define_Tag|Define_Type|Email_Batch|'
              r'Encode_Set|HTML_Comment|Handle|Handle_Error|Header|If|Inline|'
              r'Value_List|While|Abort|Case|Else|If_Empty|If_False|If_Null|'
              r'If_True|Loop_Abort|Loop_Continue|Loop_Count|Params|Params_Up|'
              r'Return|Return_Value|Run_Children|SOAP_DefineTag|'
-             r'SOAP_LastRequest|SOAP_LastResponse|Tag_Name)\b',
-                 bygroups(Punctuation, Keyword)),
-            (r'(and|ascending|average|by|case|define|descending|do|else|'
-             r'equals|frozen|group|import|in|inherited|into|join|let|match|'
-             r'max|min|not|on|or|order|params|parent|private|protected|'
-             r'provide|public|require|return|select|skip|sum|take|thread|to|'
-             r'trait|type|where|with)\b', Keyword),
-
-            # literals
-            (r'([+\-]?\d*\.\d+(e[+\-]?\d+)?)', Number.Float),
-            (r'0x[\da-f]+', Number.Hex),
-            (r'[+\-]?\d+', Number.Integer),
-            (r"'", String.Single, 'singlestring'),
-            (r'"', String.Double, 'doublestring'),
-            (r'`[^`]*`', String.Backtick),
+             r'SOAP_LastRequest|SOAP_LastResponse|Tag_Name|ascending|average|'
+             r'by|define|descending|do|equals|frozen|group|handle_failure|'
+             r'import|in|into|join|let|match|max|min|on|order|parent|protected|'
+             r'provide|public|require|skip|split_thread|sum|take|thread|to|'
+             r'trait|type|where|with|yield)\b', bygroups(Punctuation, Keyword)),
 
             # other
+            (r'(and|or|not)\b', Operator.Word),
+            (r'([a-z_][\w.]*)(\s*)(::\s*)([a-z_][\w.]*)(\s*)(=)',
+                bygroups(Name, Text, Punctuation, Name.Label, Text, Operator)),
+            (r'((?<!->)[a-z_][\w.]*)(\s*)(=(?!=))',
+                bygroups(Name, Text, Operator)),
+            (r'(/?)([\w.]+)', bygroups(Punctuation, Name.Other)),
             (r'(=)(bw|ew|cn|lte?|gte?|n?eq|ft|n?rx)\b',
                 bygroups(Operator, Operator.Word)),
-            (r'([=\+\-\*/%<>&|!\?\.\\]+|:=)', Operator),
+            (r':=|[-+*/%=<>&|!?\\]+', Operator),
             (r'[{}():;,@^]', Punctuation),
-            (r'(/?)([\w\.]+)', bygroups(Punctuation, Name.Other)),
         ],
         'singlestring': [
             (r"'", String.Single, '#pop'),
         ],
         'escape': [
             (r'\\(U[\da-f]{8}|u[\da-f]{4}|x[\da-f]{1,2}|[0-7]{1,3}|:[^:]+:|'
-             r'[abefnrtv\"\'\?\\]|$)', String.Escape),
+             r'[abefnrtv?\"\'\\]|$)', String.Escape),
+        ],
+        'signature': [
+            (r'[(,]', Punctuation, 'parameter'),
+            (r'=>', Operator, '#pop'),
+            include('lasso'),
+        ],
+        'parameter': [
+            (r'\.\.\.', Name.Builtin.Pseudo),
+            (r'-?[a-z_][\w.]*', Name.Attribute, '#pop'),
+            (r'\)', Punctuation, '#pop'),
+            include('lasso'),
         ],
     }
 
             rv += 0.4
         if re.search(r'local\(', text, re.I):
             rv += 0.4
-        if re.search(r'(\[\n|\?>)', text):
+        if re.search(r'\[\n|\?>', text):
             rv += 0.4
         return rv