eric6/ThirdParty/Pygments/pygments/lexers/basic.py

changeset 6942
2602857055c5
parent 5713
6762afd9f963
child 7547
21b0534faebc
equal deleted inserted replaced
6941:f99d60d6b59b 6942:2602857055c5
1 # -*- coding: utf-8 -*-
2 """
3 pygments.lexers.basic
4 ~~~~~~~~~~~~~~~~~~~~~
5
6 Lexers for BASIC like languages (other than VB.net).
7
8 :copyright: Copyright 2006-2017 by the Pygments team, see AUTHORS.
9 :license: BSD, see LICENSE for details.
10 """
11
12 import re
13
14 from pygments.lexer import RegexLexer, bygroups, default, words, include
15 from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
16 Number, Punctuation
17
18 __all__ = ['BlitzBasicLexer', 'BlitzMaxLexer', 'MonkeyLexer', 'CbmBasicV2Lexer',
19 'QBasicLexer']
20
21
22 class BlitzMaxLexer(RegexLexer):
23 """
24 For `BlitzMax <http://blitzbasic.com>`_ source code.
25
26 .. versionadded:: 1.4
27 """
28
29 name = 'BlitzMax'
30 aliases = ['blitzmax', 'bmax']
31 filenames = ['*.bmx']
32 mimetypes = ['text/x-bmx']
33
34 bmax_vopwords = r'\b(Shl|Shr|Sar|Mod)\b'
35 bmax_sktypes = r'@{1,2}|[!#$%]'
36 bmax_lktypes = r'\b(Int|Byte|Short|Float|Double|Long)\b'
37 bmax_name = r'[a-z_]\w*'
38 bmax_var = (r'(%s)(?:(?:([ \t]*)(%s)|([ \t]*:[ \t]*\b(?:Shl|Shr|Sar|Mod)\b)'
39 r'|([ \t]*)(:)([ \t]*)(?:%s|(%s)))(?:([ \t]*)(Ptr))?)') % \
40 (bmax_name, bmax_sktypes, bmax_lktypes, bmax_name)
41 bmax_func = bmax_var + r'?((?:[ \t]|\.\.\n)*)([(])'
42
43 flags = re.MULTILINE | re.IGNORECASE
44 tokens = {
45 'root': [
46 # Text
47 (r'[ \t]+', Text),
48 (r'\.\.\n', Text), # Line continuation
49 # Comments
50 (r"'.*?\n", Comment.Single),
51 (r'([ \t]*)\bRem\n(\n|.)*?\s*\bEnd([ \t]*)Rem', Comment.Multiline),
52 # Data types
53 ('"', String.Double, 'string'),
54 # Numbers
55 (r'[0-9]+\.[0-9]*(?!\.)', Number.Float),
56 (r'\.[0-9]*(?!\.)', Number.Float),
57 (r'[0-9]+', Number.Integer),
58 (r'\$[0-9a-f]+', Number.Hex),
59 (r'\%[10]+', Number.Bin),
60 # Other
61 (r'(?:(?:(:)?([ \t]*)(:?%s|([+\-*/&|~]))|Or|And|Not|[=<>^]))' %
62 (bmax_vopwords), Operator),
63 (r'[(),.:\[\]]', Punctuation),
64 (r'(?:#[\w \t]*)', Name.Label),
65 (r'(?:\?[\w \t]*)', Comment.Preproc),
66 # Identifiers
67 (r'\b(New)\b([ \t]?)([(]?)(%s)' % (bmax_name),
68 bygroups(Keyword.Reserved, Text, Punctuation, Name.Class)),
69 (r'\b(Import|Framework|Module)([ \t]+)(%s\.%s)' %
70 (bmax_name, bmax_name),
71 bygroups(Keyword.Reserved, Text, Keyword.Namespace)),
72 (bmax_func, bygroups(Name.Function, Text, Keyword.Type,
73 Operator, Text, Punctuation, Text,
74 Keyword.Type, Name.Class, Text,
75 Keyword.Type, Text, Punctuation)),
76 (bmax_var, bygroups(Name.Variable, Text, Keyword.Type, Operator,
77 Text, Punctuation, Text, Keyword.Type,
78 Name.Class, Text, Keyword.Type)),
79 (r'\b(Type|Extends)([ \t]+)(%s)' % (bmax_name),
80 bygroups(Keyword.Reserved, Text, Name.Class)),
81 # Keywords
82 (r'\b(Ptr)\b', Keyword.Type),
83 (r'\b(Pi|True|False|Null|Self|Super)\b', Keyword.Constant),
84 (r'\b(Local|Global|Const|Field)\b', Keyword.Declaration),
85 (words((
86 'TNullMethodException', 'TNullFunctionException',
87 'TNullObjectException', 'TArrayBoundsException',
88 'TRuntimeException'), prefix=r'\b', suffix=r'\b'), Name.Exception),
89 (words((
90 'Strict', 'SuperStrict', 'Module', 'ModuleInfo',
91 'End', 'Return', 'Continue', 'Exit', 'Public', 'Private',
92 'Var', 'VarPtr', 'Chr', 'Len', 'Asc', 'SizeOf', 'Sgn', 'Abs', 'Min', 'Max',
93 'New', 'Release', 'Delete', 'Incbin', 'IncbinPtr', 'IncbinLen',
94 'Framework', 'Include', 'Import', 'Extern', 'EndExtern',
95 'Function', 'EndFunction', 'Type', 'EndType', 'Extends', 'Method', 'EndMethod',
96 'Abstract', 'Final', 'If', 'Then', 'Else', 'ElseIf', 'EndIf',
97 'For', 'To', 'Next', 'Step', 'EachIn', 'While', 'Wend', 'EndWhile',
98 'Repeat', 'Until', 'Forever', 'Select', 'Case', 'Default', 'EndSelect',
99 'Try', 'Catch', 'EndTry', 'Throw', 'Assert', 'Goto', 'DefData', 'ReadData',
100 'RestoreData'), prefix=r'\b', suffix=r'\b'),
101 Keyword.Reserved),
102 # Final resolve (for variable names and such)
103 (r'(%s)' % (bmax_name), Name.Variable),
104 ],
105 'string': [
106 (r'""', String.Double),
107 (r'"C?', String.Double, '#pop'),
108 (r'[^"]+', String.Double),
109 ],
110 }
111
112
113 class BlitzBasicLexer(RegexLexer):
114 """
115 For `BlitzBasic <http://blitzbasic.com>`_ source code.
116
117 .. versionadded:: 2.0
118 """
119
120 name = 'BlitzBasic'
121 aliases = ['blitzbasic', 'b3d', 'bplus']
122 filenames = ['*.bb', '*.decls']
123 mimetypes = ['text/x-bb']
124
125 bb_sktypes = r'@{1,2}|[#$%]'
126 bb_name = r'[a-z]\w*'
127 bb_var = (r'(%s)(?:([ \t]*)(%s)|([ \t]*)([.])([ \t]*)(?:(%s)))?') % \
128 (bb_name, bb_sktypes, bb_name)
129
130 flags = re.MULTILINE | re.IGNORECASE
131 tokens = {
132 'root': [
133 # Text
134 (r'[ \t]+', Text),
135 # Comments
136 (r";.*?\n", Comment.Single),
137 # Data types
138 ('"', String.Double, 'string'),
139 # Numbers
140 (r'[0-9]+\.[0-9]*(?!\.)', Number.Float),
141 (r'\.[0-9]+(?!\.)', Number.Float),
142 (r'[0-9]+', Number.Integer),
143 (r'\$[0-9a-f]+', Number.Hex),
144 (r'\%[10]+', Number.Bin),
145 # Other
146 (words(('Shl', 'Shr', 'Sar', 'Mod', 'Or', 'And', 'Not',
147 'Abs', 'Sgn', 'Handle', 'Int', 'Float', 'Str',
148 'First', 'Last', 'Before', 'After'),
149 prefix=r'\b', suffix=r'\b'),
150 Operator),
151 (r'([+\-*/~=<>^])', Operator),
152 (r'[(),:\[\]\\]', Punctuation),
153 (r'\.([ \t]*)(%s)' % bb_name, Name.Label),
154 # Identifiers
155 (r'\b(New)\b([ \t]+)(%s)' % (bb_name),
156 bygroups(Keyword.Reserved, Text, Name.Class)),
157 (r'\b(Gosub|Goto)\b([ \t]+)(%s)' % (bb_name),
158 bygroups(Keyword.Reserved, Text, Name.Label)),
159 (r'\b(Object)\b([ \t]*)([.])([ \t]*)(%s)\b' % (bb_name),
160 bygroups(Operator, Text, Punctuation, Text, Name.Class)),
161 (r'\b%s\b([ \t]*)(\()' % bb_var,
162 bygroups(Name.Function, Text, Keyword.Type, Text, Punctuation,
163 Text, Name.Class, Text, Punctuation)),
164 (r'\b(Function)\b([ \t]+)%s' % bb_var,
165 bygroups(Keyword.Reserved, Text, Name.Function, Text, Keyword.Type,
166 Text, Punctuation, Text, Name.Class)),
167 (r'\b(Type)([ \t]+)(%s)' % (bb_name),
168 bygroups(Keyword.Reserved, Text, Name.Class)),
169 # Keywords
170 (r'\b(Pi|True|False|Null)\b', Keyword.Constant),
171 (r'\b(Local|Global|Const|Field|Dim)\b', Keyword.Declaration),
172 (words((
173 'End', 'Return', 'Exit', 'Chr', 'Len', 'Asc', 'New', 'Delete', 'Insert',
174 'Include', 'Function', 'Type', 'If', 'Then', 'Else', 'ElseIf', 'EndIf',
175 'For', 'To', 'Next', 'Step', 'Each', 'While', 'Wend',
176 'Repeat', 'Until', 'Forever', 'Select', 'Case', 'Default',
177 'Goto', 'Gosub', 'Data', 'Read', 'Restore'), prefix=r'\b', suffix=r'\b'),
178 Keyword.Reserved),
179 # Final resolve (for variable names and such)
180 # (r'(%s)' % (bb_name), Name.Variable),
181 (bb_var, bygroups(Name.Variable, Text, Keyword.Type,
182 Text, Punctuation, Text, Name.Class)),
183 ],
184 'string': [
185 (r'""', String.Double),
186 (r'"C?', String.Double, '#pop'),
187 (r'[^"]+', String.Double),
188 ],
189 }
190
191
192 class MonkeyLexer(RegexLexer):
193 """
194 For
195 `Monkey <https://en.wikipedia.org/wiki/Monkey_(programming_language)>`_
196 source code.
197
198 .. versionadded:: 1.6
199 """
200
201 name = 'Monkey'
202 aliases = ['monkey']
203 filenames = ['*.monkey']
204 mimetypes = ['text/x-monkey']
205
206 name_variable = r'[a-z_]\w*'
207 name_function = r'[A-Z]\w*'
208 name_constant = r'[A-Z_][A-Z0-9_]*'
209 name_class = r'[A-Z]\w*'
210 name_module = r'[a-z0-9_]*'
211
212 keyword_type = r'(?:Int|Float|String|Bool|Object|Array|Void)'
213 # ? == Bool // % == Int // # == Float // $ == String
214 keyword_type_special = r'[?%#$]'
215
216 flags = re.MULTILINE
217
218 tokens = {
219 'root': [
220 # Text
221 (r'\s+', Text),
222 # Comments
223 (r"'.*", Comment),
224 (r'(?i)^#rem\b', Comment.Multiline, 'comment'),
225 # preprocessor directives
226 (r'(?i)^(?:#If|#ElseIf|#Else|#EndIf|#End|#Print|#Error)\b', Comment.Preproc),
227 # preprocessor variable (any line starting with '#' that is not a directive)
228 (r'^#', Comment.Preproc, 'variables'),
229 # String
230 ('"', String.Double, 'string'),
231 # Numbers
232 (r'[0-9]+\.[0-9]*(?!\.)', Number.Float),
233 (r'\.[0-9]+(?!\.)', Number.Float),
234 (r'[0-9]+', Number.Integer),
235 (r'\$[0-9a-fA-Z]+', Number.Hex),
236 (r'\%[10]+', Number.Bin),
237 # Native data types
238 (r'\b%s\b' % keyword_type, Keyword.Type),
239 # Exception handling
240 (r'(?i)\b(?:Try|Catch|Throw)\b', Keyword.Reserved),
241 (r'Throwable', Name.Exception),
242 # Builtins
243 (r'(?i)\b(?:Null|True|False)\b', Name.Builtin),
244 (r'(?i)\b(?:Self|Super)\b', Name.Builtin.Pseudo),
245 (r'\b(?:HOST|LANG|TARGET|CONFIG)\b', Name.Constant),
246 # Keywords
247 (r'(?i)^(Import)(\s+)(.*)(\n)',
248 bygroups(Keyword.Namespace, Text, Name.Namespace, Text)),
249 (r'(?i)^Strict\b.*\n', Keyword.Reserved),
250 (r'(?i)(Const|Local|Global|Field)(\s+)',
251 bygroups(Keyword.Declaration, Text), 'variables'),
252 (r'(?i)(New|Class|Interface|Extends|Implements)(\s+)',
253 bygroups(Keyword.Reserved, Text), 'classname'),
254 (r'(?i)(Function|Method)(\s+)',
255 bygroups(Keyword.Reserved, Text), 'funcname'),
256 (r'(?i)(?:End|Return|Public|Private|Extern|Property|'
257 r'Final|Abstract)\b', Keyword.Reserved),
258 # Flow Control stuff
259 (r'(?i)(?:If|Then|Else|ElseIf|EndIf|'
260 r'Select|Case|Default|'
261 r'While|Wend|'
262 r'Repeat|Until|Forever|'
263 r'For|To|Until|Step|EachIn|Next|'
264 r'Exit|Continue)\s+', Keyword.Reserved),
265 # not used yet
266 (r'(?i)\b(?:Module|Inline)\b', Keyword.Reserved),
267 # Array
268 (r'[\[\]]', Punctuation),
269 # Other
270 (r'<=|>=|<>|\*=|/=|\+=|-=|&=|~=|\|=|[-&*/^+=<>|~]', Operator),
271 (r'(?i)(?:Not|Mod|Shl|Shr|And|Or)', Operator.Word),
272 (r'[(){}!#,.:]', Punctuation),
273 # catch the rest
274 (r'%s\b' % name_constant, Name.Constant),
275 (r'%s\b' % name_function, Name.Function),
276 (r'%s\b' % name_variable, Name.Variable),
277 ],
278 'funcname': [
279 (r'(?i)%s\b' % name_function, Name.Function),
280 (r':', Punctuation, 'classname'),
281 (r'\s+', Text),
282 (r'\(', Punctuation, 'variables'),
283 (r'\)', Punctuation, '#pop')
284 ],
285 'classname': [
286 (r'%s\.' % name_module, Name.Namespace),
287 (r'%s\b' % keyword_type, Keyword.Type),
288 (r'%s\b' % name_class, Name.Class),
289 # array (of given size)
290 (r'(\[)(\s*)(\d*)(\s*)(\])',
291 bygroups(Punctuation, Text, Number.Integer, Text, Punctuation)),
292 # generics
293 (r'\s+(?!<)', Text, '#pop'),
294 (r'<', Punctuation, '#push'),
295 (r'>', Punctuation, '#pop'),
296 (r'\n', Text, '#pop'),
297 default('#pop')
298 ],
299 'variables': [
300 (r'%s\b' % name_constant, Name.Constant),
301 (r'%s\b' % name_variable, Name.Variable),
302 (r'%s' % keyword_type_special, Keyword.Type),
303 (r'\s+', Text),
304 (r':', Punctuation, 'classname'),
305 (r',', Punctuation, '#push'),
306 default('#pop')
307 ],
308 'string': [
309 (r'[^"~]+', String.Double),
310 (r'~q|~n|~r|~t|~z|~~', String.Escape),
311 (r'"', String.Double, '#pop'),
312 ],
313 'comment': [
314 (r'(?i)^#rem.*?', Comment.Multiline, "#push"),
315 (r'(?i)^#end.*?', Comment.Multiline, "#pop"),
316 (r'\n', Comment.Multiline),
317 (r'.+', Comment.Multiline),
318 ],
319 }
320
321
322 class CbmBasicV2Lexer(RegexLexer):
323 """
324 For CBM BASIC V2 sources.
325
326 .. versionadded:: 1.6
327 """
328 name = 'CBM BASIC V2'
329 aliases = ['cbmbas']
330 filenames = ['*.bas']
331
332 flags = re.IGNORECASE
333
334 tokens = {
335 'root': [
336 (r'rem.*\n', Comment.Single),
337 (r'\s+', Text),
338 (r'new|run|end|for|to|next|step|go(to|sub)?|on|return|stop|cont'
339 r'|if|then|input#?|read|wait|load|save|verify|poke|sys|print#?'
340 r'|list|clr|cmd|open|close|get#?', Keyword.Reserved),
341 (r'data|restore|dim|let|def|fn', Keyword.Declaration),
342 (r'tab|spc|sgn|int|abs|usr|fre|pos|sqr|rnd|log|exp|cos|sin|tan|atn'
343 r'|peek|len|val|asc|(str|chr|left|right|mid)\$', Name.Builtin),
344 (r'[-+*/^<>=]', Operator),
345 (r'not|and|or', Operator.Word),
346 (r'"[^"\n]*.', String),
347 (r'\d+|[-+]?\d*\.\d*(e[-+]?\d+)?', Number.Float),
348 (r'[(),:;]', Punctuation),
349 (r'\w+[$%]?', Name),
350 ]
351 }
352
353 def analyse_text(self, text):
354 # if it starts with a line number, it shouldn't be a "modern" Basic
355 # like VB.net
356 if re.match(r'\d+', text):
357 return 0.2
358
359
360 class QBasicLexer(RegexLexer):
361 """
362 For
363 `QBasic <http://en.wikipedia.org/wiki/QBasic>`_
364 source code.
365
366 .. versionadded:: 2.0
367 """
368
369 name = 'QBasic'
370 aliases = ['qbasic', 'basic']
371 filenames = ['*.BAS', '*.bas']
372 mimetypes = ['text/basic']
373
374 declarations = ('DATA', 'LET')
375
376 functions = (
377 'ABS', 'ASC', 'ATN', 'CDBL', 'CHR$', 'CINT', 'CLNG',
378 'COMMAND$', 'COS', 'CSNG', 'CSRLIN', 'CVD', 'CVDMBF', 'CVI',
379 'CVL', 'CVS', 'CVSMBF', 'DATE$', 'ENVIRON$', 'EOF', 'ERDEV',
380 'ERDEV$', 'ERL', 'ERR', 'EXP', 'FILEATTR', 'FIX', 'FRE',
381 'FREEFILE', 'HEX$', 'INKEY$', 'INP', 'INPUT$', 'INSTR', 'INT',
382 'IOCTL$', 'LBOUND', 'LCASE$', 'LEFT$', 'LEN', 'LOC', 'LOF',
383 'LOG', 'LPOS', 'LTRIM$', 'MID$', 'MKD$', 'MKDMBF$', 'MKI$',
384 'MKL$', 'MKS$', 'MKSMBF$', 'OCT$', 'PEEK', 'PEN', 'PLAY',
385 'PMAP', 'POINT', 'POS', 'RIGHT$', 'RND', 'RTRIM$', 'SADD',
386 'SCREEN', 'SEEK', 'SETMEM', 'SGN', 'SIN', 'SPACE$', 'SPC',
387 'SQR', 'STICK', 'STR$', 'STRIG', 'STRING$', 'TAB', 'TAN',
388 'TIME$', 'TIMER', 'UBOUND', 'UCASE$', 'VAL', 'VARPTR',
389 'VARPTR$', 'VARSEG'
390 )
391
392 metacommands = ('$DYNAMIC', '$INCLUDE', '$STATIC')
393
394 operators = ('AND', 'EQV', 'IMP', 'NOT', 'OR', 'XOR')
395
396 statements = (
397 'BEEP', 'BLOAD', 'BSAVE', 'CALL', 'CALL ABSOLUTE',
398 'CALL INTERRUPT', 'CALLS', 'CHAIN', 'CHDIR', 'CIRCLE', 'CLEAR',
399 'CLOSE', 'CLS', 'COLOR', 'COM', 'COMMON', 'CONST', 'DATA',
400 'DATE$', 'DECLARE', 'DEF FN', 'DEF SEG', 'DEFDBL', 'DEFINT',
401 'DEFLNG', 'DEFSNG', 'DEFSTR', 'DEF', 'DIM', 'DO', 'LOOP',
402 'DRAW', 'END', 'ENVIRON', 'ERASE', 'ERROR', 'EXIT', 'FIELD',
403 'FILES', 'FOR', 'NEXT', 'FUNCTION', 'GET', 'GOSUB', 'GOTO',
404 'IF', 'THEN', 'INPUT', 'INPUT #', 'IOCTL', 'KEY', 'KEY',
405 'KILL', 'LET', 'LINE', 'LINE INPUT', 'LINE INPUT #', 'LOCATE',
406 'LOCK', 'UNLOCK', 'LPRINT', 'LSET', 'MID$', 'MKDIR', 'NAME',
407 'ON COM', 'ON ERROR', 'ON KEY', 'ON PEN', 'ON PLAY',
408 'ON STRIG', 'ON TIMER', 'ON UEVENT', 'ON', 'OPEN', 'OPEN COM',
409 'OPTION BASE', 'OUT', 'PAINT', 'PALETTE', 'PCOPY', 'PEN',
410 'PLAY', 'POKE', 'PRESET', 'PRINT', 'PRINT #', 'PRINT USING',
411 'PSET', 'PUT', 'PUT', 'RANDOMIZE', 'READ', 'REDIM', 'REM',
412 'RESET', 'RESTORE', 'RESUME', 'RETURN', 'RMDIR', 'RSET', 'RUN',
413 'SCREEN', 'SEEK', 'SELECT CASE', 'SHARED', 'SHELL', 'SLEEP',
414 'SOUND', 'STATIC', 'STOP', 'STRIG', 'SUB', 'SWAP', 'SYSTEM',
415 'TIME$', 'TIMER', 'TROFF', 'TRON', 'TYPE', 'UEVENT', 'UNLOCK',
416 'VIEW', 'WAIT', 'WHILE', 'WEND', 'WIDTH', 'WINDOW', 'WRITE'
417 )
418
419 keywords = (
420 'ACCESS', 'ALIAS', 'ANY', 'APPEND', 'AS', 'BASE', 'BINARY',
421 'BYVAL', 'CASE', 'CDECL', 'DOUBLE', 'ELSE', 'ELSEIF', 'ENDIF',
422 'INTEGER', 'IS', 'LIST', 'LOCAL', 'LONG', 'LOOP', 'MOD',
423 'NEXT', 'OFF', 'ON', 'OUTPUT', 'RANDOM', 'SIGNAL', 'SINGLE',
424 'STEP', 'STRING', 'THEN', 'TO', 'UNTIL', 'USING', 'WEND'
425 )
426
427 tokens = {
428 'root': [
429 (r'\n+', Text),
430 (r'\s+', Text.Whitespace),
431 (r'^(\s*)(\d*)(\s*)(REM .*)$',
432 bygroups(Text.Whitespace, Name.Label, Text.Whitespace,
433 Comment.Single)),
434 (r'^(\s*)(\d+)(\s*)',
435 bygroups(Text.Whitespace, Name.Label, Text.Whitespace)),
436 (r'(?=[\s]*)(\w+)(?=[\s]*=)', Name.Variable.Global),
437 (r'(?=[^"]*)\'.*$', Comment.Single),
438 (r'"[^\n"]*"', String.Double),
439 (r'(END)(\s+)(FUNCTION|IF|SELECT|SUB)',
440 bygroups(Keyword.Reserved, Text.Whitespace, Keyword.Reserved)),
441 (r'(DECLARE)(\s+)([A-Z]+)(\s+)(\S+)',
442 bygroups(Keyword.Declaration, Text.Whitespace, Name.Variable,
443 Text.Whitespace, Name)),
444 (r'(DIM)(\s+)(SHARED)(\s+)([^\s(]+)',
445 bygroups(Keyword.Declaration, Text.Whitespace, Name.Variable,
446 Text.Whitespace, Name.Variable.Global)),
447 (r'(DIM)(\s+)([^\s(]+)',
448 bygroups(Keyword.Declaration, Text.Whitespace, Name.Variable.Global)),
449 (r'^(\s*)([a-zA-Z_]+)(\s*)(\=)',
450 bygroups(Text.Whitespace, Name.Variable.Global, Text.Whitespace,
451 Operator)),
452 (r'(GOTO|GOSUB)(\s+)(\w+\:?)',
453 bygroups(Keyword.Reserved, Text.Whitespace, Name.Label)),
454 (r'(SUB)(\s+)(\w+\:?)',
455 bygroups(Keyword.Reserved, Text.Whitespace, Name.Label)),
456 include('declarations'),
457 include('functions'),
458 include('metacommands'),
459 include('operators'),
460 include('statements'),
461 include('keywords'),
462 (r'[a-zA-Z_]\w*[$@#&!]', Name.Variable.Global),
463 (r'[a-zA-Z_]\w*\:', Name.Label),
464 (r'\-?\d*\.\d+[@|#]?', Number.Float),
465 (r'\-?\d+[@|#]', Number.Float),
466 (r'\-?\d+#?', Number.Integer.Long),
467 (r'\-?\d+#?', Number.Integer),
468 (r'!=|==|:=|\.=|<<|>>|[-~+/\\*%=<>&^|?:!.]', Operator),
469 (r'[\[\]{}(),;]', Punctuation),
470 (r'[\w]+', Name.Variable.Global),
471 ],
472 # can't use regular \b because of X$()
473 # XXX: use words() here
474 'declarations': [
475 (r'\b(%s)(?=\(|\b)' % '|'.join(map(re.escape, declarations)),
476 Keyword.Declaration),
477 ],
478 'functions': [
479 (r'\b(%s)(?=\(|\b)' % '|'.join(map(re.escape, functions)),
480 Keyword.Reserved),
481 ],
482 'metacommands': [
483 (r'\b(%s)(?=\(|\b)' % '|'.join(map(re.escape, metacommands)),
484 Keyword.Constant),
485 ],
486 'operators': [
487 (r'\b(%s)(?=\(|\b)' % '|'.join(map(re.escape, operators)), Operator.Word),
488 ],
489 'statements': [
490 (r'\b(%s)\b' % '|'.join(map(re.escape, statements)),
491 Keyword.Reserved),
492 ],
493 'keywords': [
494 (r'\b(%s)\b' % '|'.join(keywords), Keyword),
495 ],
496 }
497
498 def analyse_text(text):
499 if '$DYNAMIC' in text or '$STATIC' in text:
500 return 0.9

eric ide

mercurial