ThirdParty/Pygments/pygments/lexers/qvt.py

changeset 5713
6762afd9f963
parent 4697
c2e9bf425554
child 6651
e8f3b5568b21
equal deleted inserted replaced
5712:f0d08bdeacf4 5713:6762afd9f963
3 pygments.lexers.qvt 3 pygments.lexers.qvt
4 ~~~~~~~~~~~~~~~~~~~ 4 ~~~~~~~~~~~~~~~~~~~
5 5
6 Lexer for QVT Operational language. 6 Lexer for QVT Operational language.
7 7
8 :copyright: Copyright 2006-2015 by the Pygments team, see AUTHORS. 8 :copyright: Copyright 2006-2017 by the Pygments team, see AUTHORS.
9 :license: BSD, see LICENSE for details. 9 :license: BSD, see LICENSE for details.
10 """ 10 """
11 11
12 from pygments.lexer import RegexLexer, bygroups, include, combined 12 from pygments.lexer import RegexLexer, bygroups, include, combined, default, \
13 words
13 from pygments.token import Text, Comment, Operator, Keyword, Punctuation, \ 14 from pygments.token import Text, Comment, Operator, Keyword, Punctuation, \
14 Name, String, Number 15 Name, String, Number
15 16
16 __all__ = ['QVToLexer'] 17 __all__ = ['QVToLexer']
17 18
48 (r'[^\S\n]+', Text), 49 (r'[^\S\n]+', Text),
49 (r'(--|//)(\s*)(directive:)?(.*)$', 50 (r'(--|//)(\s*)(directive:)?(.*)$',
50 bygroups(Comment, Comment, Comment.Preproc, Comment)), 51 bygroups(Comment, Comment, Comment.Preproc, Comment)),
51 # Uncomment the following if you want to distinguish between 52 # Uncomment the following if you want to distinguish between
52 # '/*' and '/**', à la javadoc 53 # '/*' and '/**', à la javadoc
53 #(r'/[*]{2}(.|\n)*?[*]/', Comment.Multiline), 54 # (r'/[*]{2}(.|\n)*?[*]/', Comment.Multiline),
54 (r'/[*](.|\n)*?[*]/', Comment.Multiline), 55 (r'/[*](.|\n)*?[*]/', Comment.Multiline),
55 (r'\\\n', Text), 56 (r'\\\n', Text),
56 (r'(and|not|or|xor|##?)\b', Operator.Word), 57 (r'(and|not|or|xor|##?)\b', Operator.Word),
57 (r'([:]{1-2}=|[-+]=)\b', Operator.Word), 58 (r'(:{1,2}=|[-+]=)\b', Operator.Word),
58 (r'(@|<<|>>)\b', Keyword), # stereotypes 59 (r'(@|<<|>>)\b', Keyword), # stereotypes
59 (r'!=|<>|=|==|!->|->|>=|<=|[.]{3}|[+/*%=<>&|.~]', Operator), 60 (r'!=|<>|==|=|!->|->|>=|<=|[.]{3}|[+/*%=<>&|.~]', Operator),
60 (r'[]{}:(),;[]', Punctuation), 61 (r'[]{}:(),;[]', Punctuation),
61 (r'(true|false|unlimited|null)\b', Keyword.Constant), 62 (r'(true|false|unlimited|null)\b', Keyword.Constant),
62 (r'(this|self|result)\b', Name.Builtin.Pseudo), 63 (r'(this|self|result)\b', Name.Builtin.Pseudo),
63 (r'(var)\b', Keyword.Declaration), 64 (r'(var)\b', Keyword.Declaration),
64 (r'(from|import)\b', Keyword.Namespace, 'fromimport'), 65 (r'(from|import)\b', Keyword.Namespace, 'fromimport'),
65 (r'(metamodel|class|exception|primitive|enum|transformation|library)(\s+)([a-zA-Z0-9_]+)', 66 (r'(metamodel|class|exception|primitive|enum|transformation|'
67 r'library)(\s+)(\w+)',
66 bygroups(Keyword.Word, Text, Name.Class)), 68 bygroups(Keyword.Word, Text, Name.Class)),
67 (r'(exception)(\s+)([a-zA-Z0-9_]+)', bygroups(Keyword.Word, Text, Name.Exception)), 69 (r'(exception)(\s+)(\w+)',
70 bygroups(Keyword.Word, Text, Name.Exception)),
68 (r'(main)\b', Name.Function), 71 (r'(main)\b', Name.Function),
69 (r'(mapping|helper|query)(\s+)', bygroups(Keyword.Declaration, Text), 'operation'), 72 (r'(mapping|helper|query)(\s+)',
73 bygroups(Keyword.Declaration, Text), 'operation'),
70 (r'(assert)(\s+)\b', bygroups(Keyword, Text), 'assert'), 74 (r'(assert)(\s+)\b', bygroups(Keyword, Text), 'assert'),
71 (r'(Bag|Collection|Dict|OrderedSet|Sequence|Set|Tuple|List)\b', 75 (r'(Bag|Collection|Dict|OrderedSet|Sequence|Set|Tuple|List)\b',
72 Keyword.Type), 76 Keyword.Type),
73 include('keywords'), 77 include('keywords'),
74 ('"', String, combined('stringescape', 'dqs')), 78 ('"', String, combined('stringescape', 'dqs')),
75 ("'", String, combined('stringescape', 'sqs')), 79 ("'", String, combined('stringescape', 'sqs')),
76 include('name'), 80 include('name'),
77 include('numbers'), 81 include('numbers'),
78 # (r'([a-zA-Z_][a-zA-Z0-9_]*)(::)([a-zA-Z_][a-zA-Z0-9_]*)', 82 # (r'([a-zA-Z_]\w*)(::)([a-zA-Z_]\w*)',
79 # bygroups(Text, Text, Text)), 83 # bygroups(Text, Text, Text)),
80 ], 84 ],
81 85
82 'fromimport': [ 86 'fromimport': [
83 (r'(?:[ \t]|\\\n)+', Text), 87 (r'(?:[ \t]|\\\n)+', Text),
84 (r'[a-zA-Z_][a-zA-Z0-9_.]*', Name.Namespace), 88 (r'[a-zA-Z_][\w.]*', Name.Namespace),
85 (r'', Text, '#pop'), 89 default('#pop'),
86 ], 90 ],
87 91
88 'operation': [ 92 'operation': [
89 (r'::', Text), 93 (r'::', Text),
90 (r'(.*::)([a-zA-Z_][a-zA-Z0-9_]*)[ \t]*(\()', bygroups(Text,Name.Function, Text), '#pop') 94 (r'(.*::)([a-zA-Z_]\w*)([ \t]*)(\()',
91 ], 95 bygroups(Text, Name.Function, Text, Punctuation), '#pop')
96 ],
92 97
93 'assert': [ 98 'assert': [
94 (r'(warning|error|fatal)\b', Keyword, '#pop'), 99 (r'(warning|error|fatal)\b', Keyword, '#pop'),
95 (r'', Text, '#pop') # all else: go back 100 default('#pop'), # all else: go back
96 ], 101 ],
97 102
98 'keywords': [ 103 'keywords': [
99 (r'(abstract|access|any|assert|' 104 (words((
100 r'blackbox|break|case|collect|collectNested|' 105 'abstract', 'access', 'any', 'assert', 'blackbox', 'break',
101 r'collectOne|collectselect|collectselectOne|composes|' 106 'case', 'collect', 'collectNested', 'collectOne', 'collectselect',
102 r'compute|configuration|constructor|continue|datatype|' 107 'collectselectOne', 'composes', 'compute', 'configuration',
103 r'default|derived|disjuncts|do|elif|else|end|' 108 'constructor', 'continue', 'datatype', 'default', 'derived',
104 r'endif|except|exists|extends|' 109 'disjuncts', 'do', 'elif', 'else', 'end', 'endif', 'except',
105 r'forAll|forEach|forOne|from|if|' 110 'exists', 'extends', 'forAll', 'forEach', 'forOne', 'from', 'if',
106 r'implies|in|inherits|init|inout|' 111 'implies', 'in', 'inherits', 'init', 'inout', 'intermediate',
107 r'intermediate|invresolve|invresolveIn|invresolveone|' 112 'invresolve', 'invresolveIn', 'invresolveone', 'invresolveoneIn',
108 r'invresolveoneIn|isUnique|iterate|late|let|' 113 'isUnique', 'iterate', 'late', 'let', 'literal', 'log', 'map',
109 r'literal|log|map|merges|' 114 'merges', 'modeltype', 'new', 'object', 'one', 'ordered', 'out',
110 r'modeltype|new|object|one|' 115 'package', 'population', 'property', 'raise', 'readonly',
111 r'ordered|out|package|population|' 116 'references', 'refines', 'reject', 'resolve', 'resolveIn',
112 r'property|raise|readonly|references|refines|' 117 'resolveone', 'resolveoneIn', 'return', 'select', 'selectOne',
113 r'reject|resolve|resolveIn|resolveone|resolveoneIn|' 118 'sortedBy', 'static', 'switch', 'tag', 'then', 'try', 'typedef',
114 r'return|select|selectOne|sortedBy|static|switch|' 119 'unlimited', 'uses', 'when', 'where', 'while', 'with', 'xcollect',
115 r'tag|then|try|typedef|' 120 'xmap', 'xselect'), suffix=r'\b'), Keyword),
116 r'unlimited|uses|when|where|while|with|'
117 r'xcollect|xmap|xselect)\b', Keyword),
118 ], 121 ],
119 122
120 # There is no need to distinguish between String.Single and 123 # There is no need to distinguish between String.Single and
121 # String.Double: 'strings' is factorised for 'dqs' and 'sqs' 124 # String.Double: 'strings' is factorised for 'dqs' and 'sqs'
122 'strings': [ 125 'strings': [
125 (r'[\'"\\]', String), 128 (r'[\'"\\]', String),
126 ], 129 ],
127 'stringescape': [ 130 'stringescape': [
128 (r'\\([\\btnfr"\']|u[0-3][0-7]{2}|u[0-7]{1,2})', String.Escape) 131 (r'\\([\\btnfr"\']|u[0-3][0-7]{2}|u[0-7]{1,2})', String.Escape)
129 ], 132 ],
130 'dqs': [ # double-quoted string 133 'dqs': [ # double-quoted string
131 (r'"', String, '#pop'), 134 (r'"', String, '#pop'),
132 (r'\\\\|\\"', String.Escape), 135 (r'\\\\|\\"', String.Escape),
133 include('strings') 136 include('strings')
134 ], 137 ],
135 'sqs': [ # single-quoted string 138 'sqs': [ # single-quoted string
136 (r"'", String, '#pop'), 139 (r"'", String, '#pop'),
137 (r"\\\\|\\'", String.Escape), 140 (r"\\\\|\\'", String.Escape),
138 include('strings') 141 include('strings')
139 ], 142 ],
140 'name': [ 143 'name': [
141 ('[a-zA-Z_][a-zA-Z0-9_]*', Name), 144 ('[a-zA-Z_]\w*', Name),
142 ], 145 ],
143 # numbers: excerpt taken from the python lexer 146 # numbers: excerpt taken from the python lexer
144 'numbers': [ 147 'numbers': [
145 (r'(\d+\.\d*|\d*\.\d+)([eE][+-]?[0-9]+)?', Number.Float), 148 (r'(\d+\.\d*|\d*\.\d+)([eE][+-]?[0-9]+)?', Number.Float),
146 (r'\d+[eE][+-]?[0-9]+', Number.Float), 149 (r'\d+[eE][+-]?[0-9]+', Number.Float),
147 (r'\d+', Number.Integer) 150 (r'\d+', Number.Integer)
148 ], 151 ],
149 } 152 }
150

eric ide

mercurial