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': [ |