ThirdParty/Pygments/pygments/lexers/qvt.py

changeset 5713
6762afd9f963
parent 4697
c2e9bf425554
child 6651
e8f3b5568b21
diff -r f0d08bdeacf4 -r 6762afd9f963 ThirdParty/Pygments/pygments/lexers/qvt.py
--- a/ThirdParty/Pygments/pygments/lexers/qvt.py	Sun Apr 23 16:40:31 2017 +0200
+++ b/ThirdParty/Pygments/pygments/lexers/qvt.py	Tue Apr 25 18:36:38 2017 +0200
@@ -5,11 +5,12 @@
 
     Lexer for QVT Operational language.
 
-    :copyright: Copyright 2006-2015 by the Pygments team, see AUTHORS.
+    :copyright: Copyright 2006-2017 by the Pygments team, see AUTHORS.
     :license: BSD, see LICENSE for details.
 """
 
-from pygments.lexer import RegexLexer, bygroups, include, combined
+from pygments.lexer import RegexLexer, bygroups, include, combined, default, \
+    words
 from pygments.token import Text, Comment, Operator, Keyword, Punctuation, \
     Name, String, Number
 
@@ -50,23 +51,26 @@
              bygroups(Comment, Comment, Comment.Preproc, Comment)),
             # Uncomment the following if you want to distinguish between
             # '/*' and '/**', à la javadoc
-            #(r'/[*]{2}(.|\n)*?[*]/', Comment.Multiline),
+            # (r'/[*]{2}(.|\n)*?[*]/', Comment.Multiline),
             (r'/[*](.|\n)*?[*]/', Comment.Multiline),
             (r'\\\n', Text),
             (r'(and|not|or|xor|##?)\b', Operator.Word),
-            (r'([:]{1-2}=|[-+]=)\b', Operator.Word),
-            (r'(@|<<|>>)\b', Keyword), # stereotypes
-            (r'!=|<>|=|==|!->|->|>=|<=|[.]{3}|[+/*%=<>&|.~]', Operator),
+            (r'(:{1,2}=|[-+]=)\b', Operator.Word),
+            (r'(@|<<|>>)\b', Keyword),  # stereotypes
+            (r'!=|<>|==|=|!->|->|>=|<=|[.]{3}|[+/*%=<>&|.~]', Operator),
             (r'[]{}:(),;[]', Punctuation),
             (r'(true|false|unlimited|null)\b', Keyword.Constant),
             (r'(this|self|result)\b', Name.Builtin.Pseudo),
             (r'(var)\b', Keyword.Declaration),
             (r'(from|import)\b', Keyword.Namespace, 'fromimport'),
-            (r'(metamodel|class|exception|primitive|enum|transformation|library)(\s+)([a-zA-Z0-9_]+)',
+            (r'(metamodel|class|exception|primitive|enum|transformation|'
+             r'library)(\s+)(\w+)',
              bygroups(Keyword.Word, Text, Name.Class)),
-            (r'(exception)(\s+)([a-zA-Z0-9_]+)', bygroups(Keyword.Word, Text, Name.Exception)),
+            (r'(exception)(\s+)(\w+)',
+             bygroups(Keyword.Word, Text, Name.Exception)),
             (r'(main)\b', Name.Function),
-            (r'(mapping|helper|query)(\s+)', bygroups(Keyword.Declaration, Text), 'operation'),
+            (r'(mapping|helper|query)(\s+)',
+             bygroups(Keyword.Declaration, Text), 'operation'),
             (r'(assert)(\s+)\b', bygroups(Keyword, Text), 'assert'),
             (r'(Bag|Collection|Dict|OrderedSet|Sequence|Set|Tuple|List)\b',
              Keyword.Type),
@@ -75,46 +79,45 @@
             ("'", String, combined('stringescape', 'sqs')),
             include('name'),
             include('numbers'),
-            # (r'([a-zA-Z_][a-zA-Z0-9_]*)(::)([a-zA-Z_][a-zA-Z0-9_]*)',
+            # (r'([a-zA-Z_]\w*)(::)([a-zA-Z_]\w*)',
             # bygroups(Text, Text, Text)),
-            ],
+        ],
 
         'fromimport': [
             (r'(?:[ \t]|\\\n)+', Text),
-            (r'[a-zA-Z_][a-zA-Z0-9_.]*', Name.Namespace),
-            (r'', Text, '#pop'),
-            ],
+            (r'[a-zA-Z_][\w.]*', Name.Namespace),
+            default('#pop'),
+        ],
 
         'operation': [
             (r'::', Text),
-            (r'(.*::)([a-zA-Z_][a-zA-Z0-9_]*)[ \t]*(\()', bygroups(Text,Name.Function, Text), '#pop')
-            ],
+            (r'(.*::)([a-zA-Z_]\w*)([ \t]*)(\()',
+             bygroups(Text, Name.Function, Text, Punctuation), '#pop')
+        ],
 
         'assert': [
             (r'(warning|error|fatal)\b', Keyword, '#pop'),
-            (r'', Text, '#pop') # all else: go back
-            ],
+            default('#pop'),  # all else: go back
+        ],
 
         'keywords': [
-            (r'(abstract|access|any|assert|'
-             r'blackbox|break|case|collect|collectNested|'
-             r'collectOne|collectselect|collectselectOne|composes|'
-             r'compute|configuration|constructor|continue|datatype|'
-             r'default|derived|disjuncts|do|elif|else|end|'
-             r'endif|except|exists|extends|'
-             r'forAll|forEach|forOne|from|if|'
-             r'implies|in|inherits|init|inout|'
-             r'intermediate|invresolve|invresolveIn|invresolveone|'
-             r'invresolveoneIn|isUnique|iterate|late|let|'
-             r'literal|log|map|merges|'
-             r'modeltype|new|object|one|'
-             r'ordered|out|package|population|'
-             r'property|raise|readonly|references|refines|'
-             r'reject|resolve|resolveIn|resolveone|resolveoneIn|'
-             r'return|select|selectOne|sortedBy|static|switch|'
-             r'tag|then|try|typedef|'
-             r'unlimited|uses|when|where|while|with|'
-             r'xcollect|xmap|xselect)\b', Keyword),
+            (words((
+                'abstract', 'access', 'any', 'assert', 'blackbox', 'break',
+                'case', 'collect', 'collectNested', 'collectOne', 'collectselect',
+                'collectselectOne', 'composes', 'compute', 'configuration',
+                'constructor', 'continue', 'datatype', 'default', 'derived',
+                'disjuncts', 'do', 'elif', 'else', 'end', 'endif', 'except',
+                'exists', 'extends', 'forAll', 'forEach', 'forOne', 'from', 'if',
+                'implies', 'in', 'inherits', 'init', 'inout', 'intermediate',
+                'invresolve', 'invresolveIn', 'invresolveone', 'invresolveoneIn',
+                'isUnique', 'iterate', 'late', 'let', 'literal', 'log', 'map',
+                'merges', 'modeltype', 'new', 'object', 'one', 'ordered', 'out',
+                'package', 'population', 'property', 'raise', 'readonly',
+                'references', 'refines', 'reject', 'resolve', 'resolveIn',
+                'resolveone', 'resolveoneIn', 'return', 'select', 'selectOne',
+                'sortedBy', 'static', 'switch', 'tag', 'then', 'try', 'typedef',
+                'unlimited', 'uses', 'when', 'where', 'while', 'with', 'xcollect',
+                'xmap', 'xselect'), suffix=r'\b'), Keyword),
         ],
 
         # There is no need to distinguish between String.Single and
@@ -127,18 +130,18 @@
         'stringescape': [
             (r'\\([\\btnfr"\']|u[0-3][0-7]{2}|u[0-7]{1,2})', String.Escape)
         ],
-        'dqs': [ # double-quoted string
+        'dqs': [  # double-quoted string
             (r'"', String, '#pop'),
             (r'\\\\|\\"', String.Escape),
             include('strings')
             ],
-        'sqs': [ # single-quoted string
+        'sqs': [  # single-quoted string
             (r"'", String, '#pop'),
             (r"\\\\|\\'", String.Escape),
             include('strings')
             ],
         'name': [
-            ('[a-zA-Z_][a-zA-Z0-9_]*', Name),
+            ('[a-zA-Z_]\w*', Name),
             ],
         # numbers: excerpt taken from the python lexer
         'numbers': [
@@ -146,5 +149,4 @@
             (r'\d+[eE][+-]?[0-9]+', Number.Float),
             (r'\d+', Number.Integer)
         ],
-       }
-
+    }

eric ide

mercurial