Commits

Tim Hatch  committed c29ad2f

Simplify character classes, ordering fixes
---
pygments/lexers/agile.py | 6 +++---
pygments/lexers/jvm.py | 16 ++++++++--------
pygments/lexers/math.py | 2 +-
pygments/lexers/other.py | 8 ++++----
pygments/lexers/text.py | 11 +++++------
5 files changed, 21 insertions(+), 22 deletions(-)

  • Participants
  • Parent commits 4639630

Comments (0)

Files changed (5)

File pygments/lexers/agile.py

             (r'(?s)\[(=*)\[.*?\]\1\]', String),
             (r'(->|=>)', Name.Function),
             (r':[a-zA-Z_][a-zA-Z0-9_]*', Name.Variable),
-            (r'(==|!=|~=|<=|>=|\.\.|\.\.\.|[=+\-*/%^<>#!.\\:])', Operator),
+            (r'(==|!=|~=|<=|>=|\.\.\.|\.\.|[=+\-*/%^<>#!.\\:])', Operator),
             (r'[;,]', Punctuation),
             (r'[\[\]\{\}\(\)]', Keyword.Type),
             (r'[a-zA-Z_][a-zA-Z0-9_]*:', Name.Variable),
             (r"(class|extends|if|then|super|do|with|import|export|"
-            r"while|elseif|return|for|in|from|when|using|else|"
-            r"and|or|not|switch|break)\b", Keyword),
+             r"while|elseif|return|for|in|from|when|using|else|"
+             r"and|or|not|switch|break)\b", Keyword),
             (r'(true|false|nil)\b', Keyword.Constant),
             (r'(and|or|not)\b', Operator.Word),
             (r'(self)\b', Name.Builtin.Pseudo),

File pygments/lexers/jvm.py

              ur'lazy|match|new|override|pr(?:ivate|otected)'
              ur'|re(?:quires|turn)|s(?:ealed|uper)|'
              ur't(?:h(?:is|row)|ry)|va[lr]|w(?:hile|ith)|yield)\b|'
-             u'(<[%:-]|=>|>:|[#=@_\u21D2\u2190])(\b|(?=\\s)|$)', Keyword),
+             u'(<[%:-]|=>|>:|[#=@_\u21D2\u2190])(\\b|(?=\\s)|$)', Keyword),
             (ur':(?!%s)' % op, Keyword, 'type'),
             (ur'%s%s\b' % (upper, idrest), Name.Class),
             (r'(true|false|null)\b', Keyword.Constant),
             (r'(type)(\s+)', bygroups(Keyword, Text), 'type'),
             (r'""".*?"""', String),
             (r'"(\\\\|\\"|[^"])*"', String),
-            (ur"'\\.'|'[^\\]'|'\\u[0-9a-f]{4}'", String.Char),
+            (r"'\\.'|'[^\\]'|'\\u[0-9a-f]{4}'", String.Char),
 #            (ur'(\.)(%s|%s|`[^`]+`)' % (idrest, op), bygroups(Operator,
 #             Name.Attribute)),
             (idrest, Name),
             (r'\[', Operator, 'typeparam'),
             (r'[\(\)\{\};,.#]', Operator),
             (op, Operator),
-            (ur'([0-9][0-9]*\.[0-9]*|\.[0-9]+)([eE][+-]?[0-9]+)?[fFdD]?',
+            (r'([0-9][0-9]*\.[0-9]*|\.[0-9]+)([eE][+-]?[0-9]+)?[fFdD]?',
              Number.Float),
             (r'0x[0-9a-f]+', Number.Hex),
             (r'[0-9]+L?', Number.Integer),
         'class': [
             (ur'(%s|%s|`[^`]+`)(\s*)(\[)' % (idrest, op),
              bygroups(Name.Class, Text, Operator), 'typeparam'),
-            (r'[\s\n]+', Text),
+            (r'\s+', Text),
             (r'{', Operator, '#pop'),
             (r'\(', Operator, '#pop'),
             (r'//.*?\n', Comment.Single, '#pop'),
         'type': [
             (r'\s+', Text),
             (u'<[%:]|>:|[#_\u21D2]|forSome|type', Keyword),
-            (r'([,\);}]|=>|=)([\s\n]*)', bygroups(Operator, Text), '#pop'),
+            (r'([,\);}]|=>|=)(\s*)', bygroups(Operator, Text), '#pop'),
             (r'[\(\{]', Operator, '#push'),
             (ur'((?:%s|%s|`[^`]+`)(?:\.(?:%s|%s|`[^`]+`))*)(\s*)(\[)' %
              (idrest, op, idrest, op),
             (ur'\.|%s|%s|`[^`]+`' % (idrest, op), Keyword.Type)
         ],
         'typeparam': [
-            (r'[\s\n,]+', Text),
+            (r'[\s,]+', Text),
             (u'<[%:]|=>|>:|[#_\u21D2]|forSome|type', Keyword),
             (r'([\]\)\}])', Operator, '#pop'),
             (r'[\(\[\{]', Operator, '#push'),
             #Documentation
             (r'((?<=fn\()|(?<=fnx\()|(?<=method\()|(?<=macro\()|(?<=lecro\()'
              r'|(?<=syntax\()|(?<=dmacro\()|(?<=dlecro\()|(?<=dlecrox\()'
-             r'|(?<=dsyntax\())[\s\n\r]*"', String.Doc, 'documentation'),
+             r'|(?<=dsyntax\())\s*"', String.Doc, 'documentation'),
 
             #Text
             (r'"', String, 'text'),
              Operator),
 
             # Punctuation
-            (r'(\`\`|\`|\'\'|\'|\.|\,|@|@@|\[|\]|\(|\)|{|})', Punctuation),
+            (r'(\`\`|\`|\'\'|\'|\.|\,|@@|@|\[|\]|\(|\)|{|})', Punctuation),
 
             #kinds
             (r'[A-Z][a-zA-Z0-9_!:?]*', Name.Class),

File pygments/lexers/math.py

 
 
             # punctuation:
-            (r'[\[\](){}:@.,=:;]', Punctuation),
+            (r'[\[\](){}@.,=:;]', Punctuation),
 
             (r'"[^"]*"', String),
 

File pygments/lexers/other.py

             ],
         'variable-names': [
             (r'<[\S_]+>', Name.Variable),
-            (r'[\w][\w_~]*(?:(\[\])|->\*)?', Name.Variable),
+            (r'\w[\w~]*(?:(\[\])|->\*)?', Name.Variable),
             ],
         'root': [
             include('common'),
                 bygroups(Keyword, Text, Name.Function, Text, Keyword)),
 
             # method implementation
-            (r'(METHOD)(\s+)([\w_~]+)',
+            (r'(METHOD)(\s+)([\w~]+)',
                 bygroups(Keyword, Text, Name.Function)),
             # method calls
-            (r'(\s+)([\w_\-]+)([=\-]>)([\w_\-~]+)',
+            (r'(\s+)([\w\-]+)([=\-]>)([\w\-~]+)',
                 bygroups(Text, Name.Variable, Operator, Name.Function)),
             # call methodnames returning style
-            (r'(?<=(=|-)>)([\w_\-~]+)(?=\()', Name.Function),
+            (r'(?<=(=|-)>)([\w\-~]+)(?=\()', Name.Function),
 
             # keywords with dashes in them.
             # these need to be first, because for instance the -ID part

File pygments/lexers/text.py

             # join/part msgs
             ("^" + timestamp + r"""
                 (\s*(?:\*{3}|<?-[!@=P]?->?)\s*)  # Star(s) or symbols
-                ([^\s]+\s+)                     # Nick + Space
+                (\S+\s+)                     # Nick + Space
                 (.*?\n)                         # Rest of message """,
              bygroups(Comment.Preproc, Keyword, String, Comment)),
             (r"^.*?\n", Text),
         ],
         'msg': [
-            (r"[^\s]+:(?!//)", Name.Attribute),  # Prefix
+            (r"\S+:(?!//)", Name.Attribute),  # Prefix
             (r".*\n", Text, '#pop'),
         ],
     }
             (r'[}\)]\s*$', Text, '#pop'),
             (r'[}]', Text),
             (r'[^,]$', Name.Function, '#pop'),
-            (r'([\+\.a-zA-Z0-9-][\s\n]*)', Name.Function),
+            (r'([\+\.a-zA-Z0-9-])(\s*)', bygroups(Name.Function, Text)),
             (r'\[.*?\]', Name.Entity),
         ],
         'depend_vers': [
              r"arraylen_gc|"
              r"getarrayitem_gc_pure|getarrayitem_gc|setarrayitem_gc|"
              r"getarrayitem_raw|setarrayitem_raw|getfield_gc_pure|"
-             r"getfield_gc|getinteriorfield_gc|"
-             r"getinteriorfield_gc|setinteriorfield_gc|"
+             r"getfield_gc|getinteriorfield_gc|setinteriorfield_gc|"
              r"getfield_raw|setfield_gc|setfield_raw|"
              r"strgetitem|strsetitem|strlen|copystrcontent|"
              r"unicodegetitem|unicodesetitem|unicodelen|"
             include("extra-stuff"),
         ],
         "extra-stuff": [
-            (r"[\n\s]+", Text),
+            (r"\s+", Text),
             (r"#.*?$", Comment),
         ],
     }