ThirdParty/Pygments/pygments/lexers/other.py

changeset 4172
4f20dba37ab6
parent 3145
a9de05d4a22f
child 4697
c2e9bf425554
equal deleted inserted replaced
4170:8bc578136279 4172:4f20dba37ab6
1 # -*- coding: utf-8 -*- 1 # -*- coding: utf-8 -*-
2 """ 2 """
3 pygments.lexers.other 3 pygments.lexers.other
4 ~~~~~~~~~~~~~~~~~~~~~ 4 ~~~~~~~~~~~~~~~~~~~~~
5 5
6 Lexers for other languages. 6 Just export lexer classes previously contained in this module.
7 7
8 :copyright: Copyright 2006-2013 by the Pygments team, see AUTHORS. 8 :copyright: Copyright 2006-2014 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 __future__ import unicode_literals
13
14 import re
15
16 from pygments.lexer import RegexLexer, include, bygroups, using, \
17 this, combined, ExtendedRegexLexer
18 from pygments.token import Error, Punctuation, Literal, Token, \
19 Text, Comment, Operator, Keyword, Name, String, Number, Generic
20 from pygments.util import get_bool_opt
21 from pygments.lexers.web import HtmlLexer
22
23 from pygments.lexers._openedgebuiltins import OPENEDGEKEYWORDS
24 from pygments.lexers._robotframeworklexer import RobotFrameworkLexer
25
26 # backwards compatibility
27 from pygments.lexers.sql import SqlLexer, MySqlLexer, SqliteConsoleLexer 12 from pygments.lexers.sql import SqlLexer, MySqlLexer, SqliteConsoleLexer
28 from pygments.lexers.shell import BashLexer, BashSessionLexer, BatchLexer, \ 13 from pygments.lexers.shell import BashLexer, BashSessionLexer, BatchLexer, \
29 TcshLexer 14 TcshLexer
15 from pygments.lexers.robotframework import RobotFrameworkLexer
16 from pygments.lexers.testing import GherkinLexer
17 from pygments.lexers.esoteric import BrainfuckLexer, BefungeLexer, RedcodeLexer
18 from pygments.lexers.prolog import LogtalkLexer
19 from pygments.lexers.snobol import SnobolLexer
20 from pygments.lexers.rebol import RebolLexer
21 from pygments.lexers.configs import KconfigLexer, Cfengine3Lexer
22 from pygments.lexers.modeling import ModelicaLexer
23 from pygments.lexers.scripting import AppleScriptLexer, MOOCodeLexer, \
24 HybrisLexer
25 from pygments.lexers.graphics import PostScriptLexer, GnuplotLexer, \
26 AsymptoteLexer, PovrayLexer
27 from pygments.lexers.business import ABAPLexer, OpenEdgeLexer, \
28 GoodDataCLLexer, MaqlLexer
29 from pygments.lexers.automation import AutoItLexer, AutohotkeyLexer
30 from pygments.lexers.dsls import ProtoBufLexer, BroLexer, PuppetLexer, \
31 MscgenLexer, VGLLexer
32 from pygments.lexers.basic import CbmBasicV2Lexer
33 from pygments.lexers.pawn import SourcePawnLexer, PawnLexer
34 from pygments.lexers.ecl import ECLLexer
35 from pygments.lexers.urbi import UrbiscriptLexer
36 from pygments.lexers.smalltalk import SmalltalkLexer, NewspeakLexer
37 from pygments.lexers.installers import NSISLexer, RPMSpecLexer
38 from pygments.lexers.textedit import AwkLexer
30 39
31 __all__ = ['BrainfuckLexer', 'BefungeLexer', 'RedcodeLexer', 'MOOCodeLexer', 40 __all__ = []
32 'SmalltalkLexer', 'LogtalkLexer', 'GnuplotLexer', 'PovrayLexer',
33 'AppleScriptLexer', 'ModelicaLexer', 'RebolLexer', 'ABAPLexer',
34 'NewspeakLexer', 'GherkinLexer', 'AsymptoteLexer', 'PostScriptLexer',
35 'AutohotkeyLexer', 'GoodDataCLLexer', 'MaqlLexer', 'ProtoBufLexer',
36 'HybrisLexer', 'AwkLexer', 'Cfengine3Lexer', 'SnobolLexer',
37 'ECLLexer', 'UrbiscriptLexer', 'OpenEdgeLexer', 'BroLexer',
38 'MscgenLexer', 'KconfigLexer', 'VGLLexer', 'SourcePawnLexer',
39 'RobotFrameworkLexer', 'PuppetLexer', 'NSISLexer', 'RPMSpecLexer',
40 'CbmBasicV2Lexer', 'AutoItLexer']
41
42
43 class ECLLexer(RegexLexer):
44 """
45 Lexer for the declarative big-data `ECL
46 <http://hpccsystems.com/community/docs/ecl-language-reference/html>`_
47 language.
48
49 *New in Pygments 1.5.*
50 """
51
52 name = 'ECL'
53 aliases = ['ecl']
54 filenames = ['*.ecl']
55 mimetypes = ['application/x-ecl']
56
57 flags = re.IGNORECASE | re.MULTILINE
58
59 tokens = {
60 'root': [
61 include('whitespace'),
62 include('statements'),
63 ],
64 'whitespace': [
65 (r'\s+', Text),
66 (r'\/\/.*', Comment.Single),
67 (r'/(\\\n)?\*(.|\n)*?\*(\\\n)?/', Comment.Multiline),
68 ],
69 'statements': [
70 include('types'),
71 include('keywords'),
72 include('functions'),
73 include('hash'),
74 (r'"', String, 'string'),
75 (r'\'', String, 'string'),
76 (r'(\d+\.\d*|\.\d+|\d+)[eE][+-]?\d+[LlUu]*', Number.Float),
77 (r'(\d+\.\d*|\.\d+|\d+[fF])[fF]?', Number.Float),
78 (r'0x[0-9a-fA-F]+[LlUu]*', Number.Hex),
79 (r'0[0-7]+[LlUu]*', Number.Oct),
80 (r'\d+[LlUu]*', Number.Integer),
81 (r'\*/', Error),
82 (r'[~!%^&*+=|?:<>/-]+', Operator),
83 (r'[{}()\[\],.;]', Punctuation),
84 (r'[a-zA-Z_][a-zA-Z0-9_]*', Name),
85 ],
86 'hash': [
87 (r'^#.*$', Comment.Preproc),
88 ],
89 'types': [
90 (r'(RECORD|END)\D', Keyword.Declaration),
91 (r'((?:ASCII|BIG_ENDIAN|BOOLEAN|DATA|DECIMAL|EBCDIC|INTEGER|PATTERN|'
92 r'QSTRING|REAL|RECORD|RULE|SET OF|STRING|TOKEN|UDECIMAL|UNICODE|'
93 r'UNSIGNED|VARSTRING|VARUNICODE)\d*)(\s+)',
94 bygroups(Keyword.Type, Text)),
95 ],
96 'keywords': [
97 (r'(APPLY|ASSERT|BUILD|BUILDINDEX|EVALUATE|FAIL|KEYDIFF|KEYPATCH|'
98 r'LOADXML|NOTHOR|NOTIFY|OUTPUT|PARALLEL|SEQUENTIAL|SOAPCALL|WAIT'
99 r'CHECKPOINT|DEPRECATED|FAILCODE|FAILMESSAGE|FAILURE|GLOBAL|'
100 r'INDEPENDENT|ONWARNING|PERSIST|PRIORITY|RECOVERY|STORED|SUCCESS|'
101 r'WAIT|WHEN)\b', Keyword.Reserved),
102 # These are classed differently, check later
103 (r'(ALL|AND|ANY|AS|ATMOST|BEFORE|BEGINC\+\+|BEST|BETWEEN|CASE|CONST|'
104 r'COUNTER|CSV|DESCEND|ENCRYPT|ENDC\+\+|ENDMACRO|EXCEPT|EXCLUSIVE|'
105 r'EXPIRE|EXPORT|EXTEND|FALSE|FEW|FIRST|FLAT|FULL|FUNCTION|GROUP|'
106 r'HEADER|HEADING|HOLE|IFBLOCK|IMPORT|IN|JOINED|KEEP|KEYED|LAST|'
107 r'LEFT|LIMIT|LOAD|LOCAL|LOCALE|LOOKUP|MACRO|MANY|MAXCOUNT|'
108 r'MAXLENGTH|MIN SKEW|MODULE|INTERFACE|NAMED|NOCASE|NOROOT|NOSCAN|'
109 r'NOSORT|NOT|OF|ONLY|OPT|OR|OUTER|OVERWRITE|PACKED|PARTITION|'
110 r'PENALTY|PHYSICALLENGTH|PIPE|QUOTE|RELATIONSHIP|REPEAT|RETURN|'
111 r'RIGHT|SCAN|SELF|SEPARATOR|SERVICE|SHARED|SKEW|SKIP|SQL|STORE|'
112 r'TERMINATOR|THOR|THRESHOLD|TOKEN|TRANSFORM|TRIM|TRUE|TYPE|'
113 r'UNICODEORDER|UNSORTED|VALIDATE|VIRTUAL|WHOLE|WILD|WITHIN|XML|'
114 r'XPATH|__COMPRESSED__)\b', Keyword.Reserved),
115 ],
116 'functions': [
117 (r'(ABS|ACOS|ALLNODES|ASCII|ASIN|ASSTRING|ATAN|ATAN2|AVE|CASE|'
118 r'CHOOSE|CHOOSEN|CHOOSESETS|CLUSTERSIZE|COMBINE|CORRELATION|COS|'
119 r'COSH|COUNT|COVARIANCE|CRON|DATASET|DEDUP|DEFINE|DENORMALIZE|'
120 r'DISTRIBUTE|DISTRIBUTED|DISTRIBUTION|EBCDIC|ENTH|ERROR|EVALUATE|'
121 r'EVENT|EVENTEXTRA|EVENTNAME|EXISTS|EXP|FAILCODE|FAILMESSAGE|'
122 r'FETCH|FROMUNICODE|GETISVALID|GLOBAL|GRAPH|GROUP|HASH|HASH32|'
123 r'HASH64|HASHCRC|HASHMD5|HAVING|IF|INDEX|INTFORMAT|ISVALID|'
124 r'ITERATE|JOIN|KEYUNICODE|LENGTH|LIBRARY|LIMIT|LN|LOCAL|LOG|LOOP|'
125 r'MAP|MATCHED|MATCHLENGTH|MATCHPOSITION|MATCHTEXT|MATCHUNICODE|'
126 r'MAX|MERGE|MERGEJOIN|MIN|NOLOCAL|NONEMPTY|NORMALIZE|PARSE|PIPE|'
127 r'POWER|PRELOAD|PROCESS|PROJECT|PULL|RANDOM|RANGE|RANK|RANKED|'
128 r'REALFORMAT|RECORDOF|REGEXFIND|REGEXREPLACE|REGROUP|REJECTED|'
129 r'ROLLUP|ROUND|ROUNDUP|ROW|ROWDIFF|SAMPLE|SET|SIN|SINH|SIZEOF|'
130 r'SOAPCALL|SORT|SORTED|SQRT|STEPPED|STORED|SUM|TABLE|TAN|TANH|'
131 r'THISNODE|TOPN|TOUNICODE|TRANSFER|TRIM|TRUNCATE|TYPEOF|UNGROUP|'
132 r'UNICODEORDER|VARIANCE|WHICH|WORKUNIT|XMLDECODE|XMLENCODE|'
133 r'XMLTEXT|XMLUNICODE)\b', Name.Function),
134 ],
135 'string': [
136 (r'"', String, '#pop'),
137 (r'\'', String, '#pop'),
138 (r'[^"\']+', String),
139 ],
140 }
141
142
143 class BrainfuckLexer(RegexLexer):
144 """
145 Lexer for the esoteric `BrainFuck <http://www.muppetlabs.com/~breadbox/bf/>`_
146 language.
147 """
148
149 name = 'Brainfuck'
150 aliases = ['brainfuck', 'bf']
151 filenames = ['*.bf', '*.b']
152 mimetypes = ['application/x-brainfuck']
153
154 tokens = {
155 'common': [
156 # use different colors for different instruction types
157 (r'[.,]+', Name.Tag),
158 (r'[+-]+', Name.Builtin),
159 (r'[<>]+', Name.Variable),
160 (r'[^.,+\-<>\[\]]+', Comment),
161 ],
162 'root': [
163 (r'\[', Keyword, 'loop'),
164 (r'\]', Error),
165 include('common'),
166 ],
167 'loop': [
168 (r'\[', Keyword, '#push'),
169 (r'\]', Keyword, '#pop'),
170 include('common'),
171 ]
172 }
173
174
175 class BefungeLexer(RegexLexer):
176 """
177 Lexer for the esoteric `Befunge <http://en.wikipedia.org/wiki/Befunge>`_
178 language.
179
180 *New in Pygments 0.7.*
181 """
182 name = 'Befunge'
183 aliases = ['befunge']
184 filenames = ['*.befunge']
185 mimetypes = ['application/x-befunge']
186
187 tokens = {
188 'root': [
189 (r'[0-9a-f]', Number),
190 (r'[\+\*/%!`-]', Operator), # Traditional math
191 (r'[<>^v?\[\]rxjk]', Name.Variable), # Move, imperatives
192 (r'[:\\$.,n]', Name.Builtin), # Stack ops, imperatives
193 (r'[|_mw]', Keyword),
194 (r'[{}]', Name.Tag), # Befunge-98 stack ops
195 (r'".*?"', String.Double), # Strings don't appear to allow escapes
196 (r'\'.', String.Single), # Single character
197 (r'[#;]', Comment), # Trampoline... depends on direction hit
198 (r'[pg&~=@iotsy]', Keyword), # Misc
199 (r'[()A-Z]', Comment), # Fingerprints
200 (r'\s+', Text), # Whitespace doesn't matter
201 ],
202 }
203
204
205 class RedcodeLexer(RegexLexer):
206 """
207 A simple Redcode lexer based on ICWS'94.
208 Contributed by Adam Blinkinsop <blinks@acm.org>.
209
210 *New in Pygments 0.8.*
211 """
212 name = 'Redcode'
213 aliases = ['redcode']
214 filenames = ['*.cw']
215
216 opcodes = ['DAT','MOV','ADD','SUB','MUL','DIV','MOD',
217 'JMP','JMZ','JMN','DJN','CMP','SLT','SPL',
218 'ORG','EQU','END']
219 modifiers = ['A','B','AB','BA','F','X','I']
220
221 tokens = {
222 'root': [
223 # Whitespace:
224 (r'\s+', Text),
225 (r';.*$', Comment.Single),
226 # Lexemes:
227 # Identifiers
228 (r'\b(%s)\b' % '|'.join(opcodes), Name.Function),
229 (r'\b(%s)\b' % '|'.join(modifiers), Name.Decorator),
230 (r'[A-Za-z_][A-Za-z_0-9]+', Name),
231 # Operators
232 (r'[-+*/%]', Operator),
233 (r'[#$@<>]', Operator), # mode
234 (r'[.,]', Punctuation), # mode
235 # Numbers
236 (r'[-+]?\d+', Number.Integer),
237 ],
238 }
239
240
241 class MOOCodeLexer(RegexLexer):
242 """
243 For `MOOCode <http://www.moo.mud.org/>`_ (the MOO scripting
244 language).
245
246 *New in Pygments 0.9.*
247 """
248 name = 'MOOCode'
249 filenames = ['*.moo']
250 aliases = ['moocode']
251 mimetypes = ['text/x-moocode']
252
253 tokens = {
254 'root' : [
255 # Numbers
256 (r'(0|[1-9][0-9_]*)', Number.Integer),
257 # Strings
258 (r'"(\\\\|\\"|[^"])*"', String),
259 # exceptions
260 (r'(E_PERM|E_DIV)', Name.Exception),
261 # db-refs
262 (r'((#[-0-9]+)|(\$[a-z_A-Z0-9]+))', Name.Entity),
263 # Keywords
264 (r'\b(if|else|elseif|endif|for|endfor|fork|endfork|while'
265 r'|endwhile|break|continue|return|try'
266 r'|except|endtry|finally|in)\b', Keyword),
267 # builtins
268 (r'(random|length)', Name.Builtin),
269 # special variables
270 (r'(player|caller|this|args)', Name.Variable.Instance),
271 # skip whitespace
272 (r'\s+', Text),
273 (r'\n', Text),
274 # other operators
275 (r'([!;=,{}&\|:\.\[\]@\(\)\<\>\?]+)', Operator),
276 # function call
277 (r'([a-z_A-Z0-9]+)(\()', bygroups(Name.Function, Operator)),
278 # variables
279 (r'([a-zA-Z_0-9]+)', Text),
280 ]
281 }
282
283
284 class SmalltalkLexer(RegexLexer):
285 """
286 For `Smalltalk <http://www.smalltalk.org/>`_ syntax.
287 Contributed by Stefan Matthias Aust.
288 Rewritten by Nils Winter.
289
290 *New in Pygments 0.10.*
291 """
292 name = 'Smalltalk'
293 filenames = ['*.st']
294 aliases = ['smalltalk', 'squeak']
295 mimetypes = ['text/x-smalltalk']
296
297 tokens = {
298 'root' : [
299 (r'(<)(\w+:)(.*?)(>)', bygroups(Text, Keyword, Text, Text)),
300 include('squeak fileout'),
301 include('whitespaces'),
302 include('method definition'),
303 (r'(\|)([\w\s]*)(\|)', bygroups(Operator, Name.Variable, Operator)),
304 include('objects'),
305 (r'\^|\:=|\_', Operator),
306 # temporaries
307 (r'[\]({}.;!]', Text),
308 ],
309 'method definition' : [
310 # Not perfect can't allow whitespaces at the beginning and the
311 # without breaking everything
312 (r'([a-zA-Z]+\w*:)(\s*)(\w+)',
313 bygroups(Name.Function, Text, Name.Variable)),
314 (r'^(\b[a-zA-Z]+\w*\b)(\s*)$', bygroups(Name.Function, Text)),
315 (r'^([-+*/\\~<>=|&!?,@%]+)(\s*)(\w+)(\s*)$',
316 bygroups(Name.Function, Text, Name.Variable, Text)),
317 ],
318 'blockvariables' : [
319 include('whitespaces'),
320 (r'(:)(\s*)(\w+)',
321 bygroups(Operator, Text, Name.Variable)),
322 (r'\|', Operator, '#pop'),
323 (r'', Text, '#pop'), # else pop
324 ],
325 'literals' : [
326 (r"'(''|[^'])*'", String, 'afterobject'),
327 (r'\$.', String.Char, 'afterobject'),
328 (r'#\(', String.Symbol, 'parenth'),
329 (r'\)', Text, 'afterobject'),
330 (r'(\d+r)?-?\d+(\.\d+)?(e-?\d+)?', Number, 'afterobject'),
331 ],
332 '_parenth_helper' : [
333 include('whitespaces'),
334 (r'(\d+r)?-?\d+(\.\d+)?(e-?\d+)?', Number),
335 (r'[-+*/\\~<>=|&#!?,@%\w:]+', String.Symbol),
336 # literals
337 (r"'(''|[^'])*'", String),
338 (r'\$.', String.Char),
339 (r'#*\(', String.Symbol, 'inner_parenth'),
340 ],
341 'parenth' : [
342 # This state is a bit tricky since
343 # we can't just pop this state
344 (r'\)', String.Symbol, ('root', 'afterobject')),
345 include('_parenth_helper'),
346 ],
347 'inner_parenth': [
348 (r'\)', String.Symbol, '#pop'),
349 include('_parenth_helper'),
350 ],
351 'whitespaces' : [
352 # skip whitespace and comments
353 (r'\s+', Text),
354 (r'"(""|[^"])*"', Comment),
355 ],
356 'objects' : [
357 (r'\[', Text, 'blockvariables'),
358 (r'\]', Text, 'afterobject'),
359 (r'\b(self|super|true|false|nil|thisContext)\b',
360 Name.Builtin.Pseudo, 'afterobject'),
361 (r'\b[A-Z]\w*(?!:)\b', Name.Class, 'afterobject'),
362 (r'\b[a-z]\w*(?!:)\b', Name.Variable, 'afterobject'),
363 (r'#("(""|[^"])*"|[-+*/\\~<>=|&!?,@%]+|[\w:]+)',
364 String.Symbol, 'afterobject'),
365 include('literals'),
366 ],
367 'afterobject' : [
368 (r'! !$', Keyword , '#pop'), # squeak chunk delimeter
369 include('whitespaces'),
370 (r'\b(ifTrue:|ifFalse:|whileTrue:|whileFalse:|timesRepeat:)',
371 Name.Builtin, '#pop'),
372 (r'\b(new\b(?!:))', Name.Builtin),
373 (r'\:=|\_', Operator, '#pop'),
374 (r'\b[a-zA-Z]+\w*:', Name.Function, '#pop'),
375 (r'\b[a-zA-Z]+\w*', Name.Function),
376 (r'\w+:?|[-+*/\\~<>=|&!?,@%]+', Name.Function, '#pop'),
377 (r'\.', Punctuation, '#pop'),
378 (r';', Punctuation),
379 (r'[\])}]', Text),
380 (r'[\[({]', Text, '#pop'),
381 ],
382 'squeak fileout' : [
383 # Squeak fileout format (optional)
384 (r'^"(""|[^"])*"!', Keyword),
385 (r"^'(''|[^'])*'!", Keyword),
386 (r'^(!)(\w+)( commentStamp: )(.*?)( prior: .*?!\n)(.*?)(!)',
387 bygroups(Keyword, Name.Class, Keyword, String, Keyword, Text, Keyword)),
388 (r"^(!)(\w+(?: class)?)( methodsFor: )('(?:''|[^'])*')(.*?!)",
389 bygroups(Keyword, Name.Class, Keyword, String, Keyword)),
390 (r'^(\w+)( subclass: )(#\w+)'
391 r'(\s+instanceVariableNames: )(.*?)'
392 r'(\s+classVariableNames: )(.*?)'
393 r'(\s+poolDictionaries: )(.*?)'
394 r'(\s+category: )(.*?)(!)',
395 bygroups(Name.Class, Keyword, String.Symbol, Keyword, String, Keyword,
396 String, Keyword, String, Keyword, String, Keyword)),
397 (r'^(\w+(?: class)?)(\s+instanceVariableNames: )(.*?)(!)',
398 bygroups(Name.Class, Keyword, String, Keyword)),
399 (r'(!\n)(\].*)(! !)$', bygroups(Keyword, Text, Keyword)),
400 (r'! !$', Keyword),
401 ],
402 }
403
404
405 class LogtalkLexer(RegexLexer):
406 """
407 For `Logtalk <http://logtalk.org/>`_ source code.
408
409 *New in Pygments 0.10.*
410 """
411
412 name = 'Logtalk'
413 aliases = ['logtalk']
414 filenames = ['*.lgt']
415 mimetypes = ['text/x-logtalk']
416
417 tokens = {
418 'root': [
419 # Directives
420 (r'^\s*:-\s',Punctuation,'directive'),
421 # Comments
422 (r'%.*?\n', Comment),
423 (r'/\*(.|\n)*?\*/',Comment),
424 # Whitespace
425 (r'\n', Text),
426 (r'\s+', Text),
427 # Numbers
428 (r"0'.", Number),
429 (r'0b[01]+', Number),
430 (r'0o[0-7]+', Number),
431 (r'0x[0-9a-fA-F]+', Number),
432 (r'\d+\.?\d*((e|E)(\+|-)?\d+)?', Number),
433 # Variables
434 (r'([A-Z_][a-zA-Z0-9_]*)', Name.Variable),
435 # Event handlers
436 (r'(after|before)(?=[(])', Keyword),
437 # Execution-context methods
438 (r'(parameter|this|se(lf|nder))(?=[(])', Keyword),
439 # Reflection
440 (r'(current_predicate|predicate_property)(?=[(])', Keyword),
441 # DCGs and term expansion
442 (r'(expand_(goal|term)|(goal|term)_expansion|phrase)(?=[(])',
443 Keyword),
444 # Entity
445 (r'(abolish|c(reate|urrent))_(object|protocol|category)(?=[(])',
446 Keyword),
447 (r'(object|protocol|category)_property(?=[(])', Keyword),
448 # Entity relations
449 (r'co(mplements_object|nforms_to_protocol)(?=[(])', Keyword),
450 (r'extends_(object|protocol|category)(?=[(])', Keyword),
451 (r'imp(lements_protocol|orts_category)(?=[(])', Keyword),
452 (r'(instantiat|specializ)es_class(?=[(])', Keyword),
453 # Events
454 (r'(current_event|(abolish|define)_events)(?=[(])', Keyword),
455 # Flags
456 (r'(current|set)_logtalk_flag(?=[(])', Keyword),
457 # Compiling, loading, and library paths
458 (r'logtalk_(compile|l(ibrary_path|oad_context|oad))(?=[(])',
459 Keyword),
460 # Database
461 (r'(clause|retract(all)?)(?=[(])', Keyword),
462 (r'a(bolish|ssert(a|z))(?=[(])', Keyword),
463 # Control constructs
464 (r'(ca(ll|tch)|throw)(?=[(])', Keyword),
465 (r'(fail|true)\b', Keyword),
466 # All solutions
467 (r'((bag|set)of|f(ind|or)all)(?=[(])', Keyword),
468 # Multi-threading meta-predicates
469 (r'threaded(_(call|once|ignore|exit|peek|wait|notify))?(?=[(])',
470 Keyword),
471 # Term unification
472 (r'unify_with_occurs_check(?=[(])', Keyword),
473 # Term creation and decomposition
474 (r'(functor|arg|copy_term|numbervars)(?=[(])', Keyword),
475 # Evaluable functors
476 (r'(rem|mod|abs|sign)(?=[(])', Keyword),
477 (r'float(_(integer|fractional)_part)?(?=[(])', Keyword),
478 (r'(floor|truncate|round|ceiling)(?=[(])', Keyword),
479 # Other arithmetic functors
480 (r'(cos|atan|exp|log|s(in|qrt))(?=[(])', Keyword),
481 # Term testing
482 (r'(var|atom(ic)?|integer|float|c(allable|ompound)|n(onvar|umber)|'
483 r'ground)(?=[(])', Keyword),
484 # Term comparison
485 (r'compare(?=[(])', Keyword),
486 # Stream selection and control
487 (r'(curren|se)t_(in|out)put(?=[(])', Keyword),
488 (r'(open|close)(?=[(])', Keyword),
489 (r'flush_output(?=[(])', Keyword),
490 (r'(at_end_of_stream|flush_output)\b', Keyword),
491 (r'(stream_property|at_end_of_stream|set_stream_position)(?=[(])',
492 Keyword),
493 # Character and byte input/output
494 (r'(nl|(get|peek|put)_(byte|c(har|ode)))(?=[(])', Keyword),
495 (r'\bnl\b', Keyword),
496 # Term input/output
497 (r'read(_term)?(?=[(])', Keyword),
498 (r'write(q|_(canonical|term))?(?=[(])', Keyword),
499 (r'(current_)?op(?=[(])', Keyword),
500 (r'(current_)?char_conversion(?=[(])', Keyword),
501 # Atomic term processing
502 (r'atom_(length|c(hars|o(ncat|des)))(?=[(])', Keyword),
503 (r'(char_code|sub_atom)(?=[(])', Keyword),
504 (r'number_c(har|ode)s(?=[(])', Keyword),
505 # Implementation defined hooks functions
506 (r'(se|curren)t_prolog_flag(?=[(])', Keyword),
507 (r'\bhalt\b', Keyword),
508 (r'halt(?=[(])', Keyword),
509 # Message sending operators
510 (r'(::|:|\^\^)', Operator),
511 # External call
512 (r'[{}]', Keyword),
513 # Logic and control
514 (r'\b(ignore|once)(?=[(])', Keyword),
515 (r'\brepeat\b', Keyword),
516 # Sorting
517 (r'(key)?sort(?=[(])', Keyword),
518 # Bitwise functors
519 (r'(>>|<<|/\\|\\\\|\\)', Operator),
520 # Arithemtic evaluation
521 (r'\bis\b', Keyword),
522 # Arithemtic comparison
523 (r'(=:=|=\\=|<|=<|>=|>)', Operator),
524 # Term creation and decomposition
525 (r'=\.\.', Operator),
526 # Term unification
527 (r'(=|\\=)', Operator),
528 # Term comparison
529 (r'(==|\\==|@=<|@<|@>=|@>)', Operator),
530 # Evaluable functors
531 (r'(//|[-+*/])', Operator),
532 (r'\b(e|pi|mod|rem)\b', Operator),
533 # Other arithemtic functors
534 (r'\b\*\*\b', Operator),
535 # DCG rules
536 (r'-->', Operator),
537 # Control constructs
538 (r'([!;]|->)', Operator),
539 # Logic and control
540 (r'\\+', Operator),
541 # Mode operators
542 (r'[?@]', Operator),
543 # Existential quantifier
544 (r'\^', Operator),
545 # Strings
546 (r'"(\\\\|\\"|[^"])*"', String),
547 # Ponctuation
548 (r'[()\[\],.|]', Text),
549 # Atoms
550 (r"[a-z][a-zA-Z0-9_]*", Text),
551 (r"'", String, 'quoted_atom'),
552 ],
553
554 'quoted_atom': [
555 (r"''", String),
556 (r"'", String, '#pop'),
557 (r'\\([\\abfnrtv"\']|(x[a-fA-F0-9]+|[0-7]+)\\)', String.Escape),
558 (r"[^\\'\n]+", String),
559 (r'\\', String),
560 ],
561
562 'directive': [
563 # Conditional compilation directives
564 (r'(el)?if(?=[(])', Keyword, 'root'),
565 (r'(e(lse|ndif))[.]', Keyword, 'root'),
566 # Entity directives
567 (r'(category|object|protocol)(?=[(])', Keyword, 'entityrelations'),
568 (r'(end_(category|object|protocol))[.]',Keyword, 'root'),
569 # Predicate scope directives
570 (r'(public|protected|private)(?=[(])', Keyword, 'root'),
571 # Other directives
572 (r'e(n(coding|sure_loaded)|xport)(?=[(])', Keyword, 'root'),
573 (r'in(fo|itialization)(?=[(])', Keyword, 'root'),
574 (r'(dynamic|synchronized|threaded)[.]', Keyword, 'root'),
575 (r'(alias|d(ynamic|iscontiguous)|m(eta_predicate|ode|ultifile)|'
576 r's(et_(logtalk|prolog)_flag|ynchronized))(?=[(])',
577 Keyword, 'root'),
578 (r'op(?=[(])', Keyword, 'root'),
579 (r'(c(alls|oinductive)|reexport|use(s|_module))(?=[(])',
580 Keyword, 'root'),
581 (r'[a-z][a-zA-Z0-9_]*(?=[(])', Text, 'root'),
582 (r'[a-z][a-zA-Z0-9_]*[.]', Text, 'root'),
583 ],
584
585 'entityrelations': [
586 (r'(complements|extends|i(nstantiates|mp(lements|orts))|specializes)'
587 r'(?=[(])', Keyword),
588 # Numbers
589 (r"0'.", Number),
590 (r'0b[01]+', Number),
591 (r'0o[0-7]+', Number),
592 (r'0x[0-9a-fA-F]+', Number),
593 (r'\d+\.?\d*((e|E)(\+|-)?\d+)?', Number),
594 # Variables
595 (r'([A-Z_][a-zA-Z0-9_]*)', Name.Variable),
596 # Atoms
597 (r"[a-z][a-zA-Z0-9_]*", Text),
598 (r"'", String, 'quoted_atom'),
599 # Strings
600 (r'"(\\\\|\\"|[^"])*"', String),
601 # End of entity-opening directive
602 (r'([)]\.)', Text, 'root'),
603 # Scope operator
604 (r'(::)', Operator),
605 # Ponctuation
606 (r'[()\[\],.|]', Text),
607 # Comments
608 (r'%.*?\n', Comment),
609 (r'/\*(.|\n)*?\*/',Comment),
610 # Whitespace
611 (r'\n', Text),
612 (r'\s+', Text),
613 ]
614 }
615
616 def analyse_text(text):
617 if ':- object(' in text:
618 return True
619 if ':- protocol(' in text:
620 return True
621 if ':- category(' in text:
622 return True
623 return False
624
625
626 def _shortened(word):
627 dpos = word.find('$')
628 return '|'.join([word[:dpos] + word[dpos+1:i] + r'\b'
629 for i in range(len(word), dpos, -1)])
630 def _shortened_many(*words):
631 return '|'.join(map(_shortened, words))
632
633 class GnuplotLexer(RegexLexer):
634 """
635 For `Gnuplot <http://gnuplot.info/>`_ plotting scripts.
636
637 *New in Pygments 0.11.*
638 """
639
640 name = 'Gnuplot'
641 aliases = ['gnuplot']
642 filenames = ['*.plot', '*.plt']
643 mimetypes = ['text/x-gnuplot']
644
645 tokens = {
646 'root': [
647 include('whitespace'),
648 (_shortened('bi$nd'), Keyword, 'bind'),
649 (_shortened_many('ex$it', 'q$uit'), Keyword, 'quit'),
650 (_shortened('f$it'), Keyword, 'fit'),
651 (r'(if)(\s*)(\()', bygroups(Keyword, Text, Punctuation), 'if'),
652 (r'else\b', Keyword),
653 (_shortened('pa$use'), Keyword, 'pause'),
654 (_shortened_many('p$lot', 'rep$lot', 'sp$lot'), Keyword, 'plot'),
655 (_shortened('sa$ve'), Keyword, 'save'),
656 (_shortened('se$t'), Keyword, ('genericargs', 'optionarg')),
657 (_shortened_many('sh$ow', 'uns$et'),
658 Keyword, ('noargs', 'optionarg')),
659 (_shortened_many('low$er', 'ra$ise', 'ca$ll', 'cd$', 'cl$ear',
660 'h$elp', '\\?$', 'hi$story', 'l$oad', 'pr$int',
661 'pwd$', 're$read', 'res$et', 'scr$eendump',
662 'she$ll', 'sy$stem', 'up$date'),
663 Keyword, 'genericargs'),
664 (_shortened_many('pwd$', 're$read', 'res$et', 'scr$eendump',
665 'she$ll', 'test$'),
666 Keyword, 'noargs'),
667 ('([a-zA-Z_][a-zA-Z0-9_]*)(\s*)(=)',
668 bygroups(Name.Variable, Text, Operator), 'genericargs'),
669 ('([a-zA-Z_][a-zA-Z0-9_]*)(\s*\(.*?\)\s*)(=)',
670 bygroups(Name.Function, Text, Operator), 'genericargs'),
671 (r'@[a-zA-Z_][a-zA-Z0-9_]*', Name.Constant), # macros
672 (r';', Keyword),
673 ],
674 'comment': [
675 (r'[^\\\n]', Comment),
676 (r'\\\n', Comment),
677 (r'\\', Comment),
678 # don't add the newline to the Comment token
679 ('', Comment, '#pop'),
680 ],
681 'whitespace': [
682 ('#', Comment, 'comment'),
683 (r'[ \t\v\f]+', Text),
684 ],
685 'noargs': [
686 include('whitespace'),
687 # semicolon and newline end the argument list
688 (r';', Punctuation, '#pop'),
689 (r'\n', Text, '#pop'),
690 ],
691 'dqstring': [
692 (r'"', String, '#pop'),
693 (r'\\([\\abfnrtv"\']|x[a-fA-F0-9]{2,4}|[0-7]{1,3})', String.Escape),
694 (r'[^\\"\n]+', String), # all other characters
695 (r'\\\n', String), # line continuation
696 (r'\\', String), # stray backslash
697 (r'\n', String, '#pop'), # newline ends the string too
698 ],
699 'sqstring': [
700 (r"''", String), # escaped single quote
701 (r"'", String, '#pop'),
702 (r"[^\\'\n]+", String), # all other characters
703 (r'\\\n', String), # line continuation
704 (r'\\', String), # normal backslash
705 (r'\n', String, '#pop'), # newline ends the string too
706 ],
707 'genericargs': [
708 include('noargs'),
709 (r'"', String, 'dqstring'),
710 (r"'", String, 'sqstring'),
711 (r'(\d+\.\d*|\.\d+|\d+)[eE][+-]?\d+', Number.Float),
712 (r'(\d+\.\d*|\.\d+)', Number.Float),
713 (r'-?\d+', Number.Integer),
714 ('[,.~!%^&*+=|?:<>/-]', Operator),
715 ('[{}()\[\]]', Punctuation),
716 (r'(eq|ne)\b', Operator.Word),
717 (r'([a-zA-Z_][a-zA-Z0-9_]*)(\s*)(\()',
718 bygroups(Name.Function, Text, Punctuation)),
719 (r'[a-zA-Z_][a-zA-Z0-9_]*', Name),
720 (r'@[a-zA-Z_][a-zA-Z0-9_]*', Name.Constant), # macros
721 (r'\\\n', Text),
722 ],
723 'optionarg': [
724 include('whitespace'),
725 (_shortened_many(
726 "a$ll","an$gles","ar$row","au$toscale","b$ars","bor$der",
727 "box$width","cl$abel","c$lip","cn$trparam","co$ntour","da$ta",
728 "data$file","dg$rid3d","du$mmy","enc$oding","dec$imalsign",
729 "fit$","font$path","fo$rmat","fu$nction","fu$nctions","g$rid",
730 "hid$den3d","his$torysize","is$osamples","k$ey","keyt$itle",
731 "la$bel","li$nestyle","ls$","loa$dpath","loc$ale","log$scale",
732 "mac$ros","map$ping","map$ping3d","mar$gin","lmar$gin",
733 "rmar$gin","tmar$gin","bmar$gin","mo$use","multi$plot",
734 "mxt$ics","nomxt$ics","mx2t$ics","nomx2t$ics","myt$ics",
735 "nomyt$ics","my2t$ics","nomy2t$ics","mzt$ics","nomzt$ics",
736 "mcbt$ics","nomcbt$ics","of$fsets","or$igin","o$utput",
737 "pa$rametric","pm$3d","pal$ette","colorb$ox","p$lot",
738 "poi$ntsize","pol$ar","pr$int","obj$ect","sa$mples","si$ze",
739 "st$yle","su$rface","table$","t$erminal","termo$ptions","ti$cs",
740 "ticsc$ale","ticsl$evel","timef$mt","tim$estamp","tit$le",
741 "v$ariables","ve$rsion","vi$ew","xyp$lane","xda$ta","x2da$ta",
742 "yda$ta","y2da$ta","zda$ta","cbda$ta","xl$abel","x2l$abel",
743 "yl$abel","y2l$abel","zl$abel","cbl$abel","xti$cs","noxti$cs",
744 "x2ti$cs","nox2ti$cs","yti$cs","noyti$cs","y2ti$cs","noy2ti$cs",
745 "zti$cs","nozti$cs","cbti$cs","nocbti$cs","xdti$cs","noxdti$cs",
746 "x2dti$cs","nox2dti$cs","ydti$cs","noydti$cs","y2dti$cs",
747 "noy2dti$cs","zdti$cs","nozdti$cs","cbdti$cs","nocbdti$cs",
748 "xmti$cs","noxmti$cs","x2mti$cs","nox2mti$cs","ymti$cs",
749 "noymti$cs","y2mti$cs","noy2mti$cs","zmti$cs","nozmti$cs",
750 "cbmti$cs","nocbmti$cs","xr$ange","x2r$ange","yr$ange",
751 "y2r$ange","zr$ange","cbr$ange","rr$ange","tr$ange","ur$ange",
752 "vr$ange","xzeroa$xis","x2zeroa$xis","yzeroa$xis","y2zeroa$xis",
753 "zzeroa$xis","zeroa$xis","z$ero"), Name.Builtin, '#pop'),
754 ],
755 'bind': [
756 ('!', Keyword, '#pop'),
757 (_shortened('all$windows'), Name.Builtin),
758 include('genericargs'),
759 ],
760 'quit': [
761 (r'gnuplot\b', Keyword),
762 include('noargs'),
763 ],
764 'fit': [
765 (r'via\b', Name.Builtin),
766 include('plot'),
767 ],
768 'if': [
769 (r'\)', Punctuation, '#pop'),
770 include('genericargs'),
771 ],
772 'pause': [
773 (r'(mouse|any|button1|button2|button3)\b', Name.Builtin),
774 (_shortened('key$press'), Name.Builtin),
775 include('genericargs'),
776 ],
777 'plot': [
778 (_shortened_many('ax$es', 'axi$s', 'bin$ary', 'ev$ery', 'i$ndex',
779 'mat$rix', 's$mooth', 'thru$', 't$itle',
780 'not$itle', 'u$sing', 'w$ith'),
781 Name.Builtin),
782 include('genericargs'),
783 ],
784 'save': [
785 (_shortened_many('f$unctions', 's$et', 't$erminal', 'v$ariables'),
786 Name.Builtin),
787 include('genericargs'),
788 ],
789 }
790
791
792 class PovrayLexer(RegexLexer):
793 """
794 For `Persistence of Vision Raytracer <http://www.povray.org/>`_ files.
795
796 *New in Pygments 0.11.*
797 """
798 name = 'POVRay'
799 aliases = ['pov']
800 filenames = ['*.pov', '*.inc']
801 mimetypes = ['text/x-povray']
802
803 tokens = {
804 'root': [
805 (r'/\*[\w\W]*?\*/', Comment.Multiline),
806 (r'//.*\n', Comment.Single),
807 (r'(?s)"(?:\\.|[^"\\])+"', String.Double),
808 (r'#(debug|default|else|end|error|fclose|fopen|ifdef|ifndef|'
809 r'include|range|read|render|statistics|switch|undef|version|'
810 r'warning|while|write|define|macro|local|declare)\b',
811 Comment.Preproc),
812 (r'\b(aa_level|aa_threshold|abs|acos|acosh|adaptive|adc_bailout|'
813 r'agate|agate_turb|all|alpha|ambient|ambient_light|angle|'
814 r'aperture|arc_angle|area_light|asc|asin|asinh|assumed_gamma|'
815 r'atan|atan2|atanh|atmosphere|atmospheric_attenuation|'
816 r'attenuating|average|background|black_hole|blue|blur_samples|'
817 r'bounded_by|box_mapping|bozo|break|brick|brick_size|'
818 r'brightness|brilliance|bumps|bumpy1|bumpy2|bumpy3|bump_map|'
819 r'bump_size|case|caustics|ceil|checker|chr|clipped_by|clock|'
820 r'color|color_map|colour|colour_map|component|composite|concat|'
821 r'confidence|conic_sweep|constant|control0|control1|cos|cosh|'
822 r'count|crackle|crand|cube|cubic_spline|cylindrical_mapping|'
823 r'debug|declare|default|degrees|dents|diffuse|direction|'
824 r'distance|distance_maximum|div|dust|dust_type|eccentricity|'
825 r'else|emitting|end|error|error_bound|exp|exponent|'
826 r'fade_distance|fade_power|falloff|falloff_angle|false|'
827 r'file_exists|filter|finish|fisheye|flatness|flip|floor|'
828 r'focal_point|fog|fog_alt|fog_offset|fog_type|frequency|gif|'
829 r'global_settings|glowing|gradient|granite|gray_threshold|'
830 r'green|halo|hexagon|hf_gray_16|hierarchy|hollow|hypercomplex|'
831 r'if|ifdef|iff|image_map|incidence|include|int|interpolate|'
832 r'inverse|ior|irid|irid_wavelength|jitter|lambda|leopard|'
833 r'linear|linear_spline|linear_sweep|location|log|looks_like|'
834 r'look_at|low_error_factor|mandel|map_type|marble|material_map|'
835 r'matrix|max|max_intersections|max_iteration|max_trace_level|'
836 r'max_value|metallic|min|minimum_reuse|mod|mortar|'
837 r'nearest_count|no|normal|normal_map|no_shadow|number_of_waves|'
838 r'octaves|off|offset|omega|omnimax|on|once|onion|open|'
839 r'orthographic|panoramic|pattern1|pattern2|pattern3|'
840 r'perspective|pgm|phase|phong|phong_size|pi|pigment|'
841 r'pigment_map|planar_mapping|png|point_at|pot|pow|ppm|'
842 r'precision|pwr|quadratic_spline|quaternion|quick_color|'
843 r'quick_colour|quilted|radial|radians|radiosity|radius|rainbow|'
844 r'ramp_wave|rand|range|reciprocal|recursion_limit|red|'
845 r'reflection|refraction|render|repeat|rgb|rgbf|rgbft|rgbt|'
846 r'right|ripples|rotate|roughness|samples|scale|scallop_wave|'
847 r'scattering|seed|shadowless|sin|sine_wave|sinh|sky|sky_sphere|'
848 r'slice|slope_map|smooth|specular|spherical_mapping|spiral|'
849 r'spiral1|spiral2|spotlight|spotted|sqr|sqrt|statistics|str|'
850 r'strcmp|strength|strlen|strlwr|strupr|sturm|substr|switch|sys|'
851 r't|tan|tanh|test_camera_1|test_camera_2|test_camera_3|'
852 r'test_camera_4|texture|texture_map|tga|thickness|threshold|'
853 r'tightness|tile2|tiles|track|transform|translate|transmit|'
854 r'triangle_wave|true|ttf|turbulence|turb_depth|type|'
855 r'ultra_wide_angle|up|use_color|use_colour|use_index|u_steps|'
856 r'val|variance|vaxis_rotate|vcross|vdot|version|vlength|'
857 r'vnormalize|volume_object|volume_rendered|vol_with_light|'
858 r'vrotate|v_steps|warning|warp|water_level|waves|while|width|'
859 r'wood|wrinkles|yes)\b', Keyword),
860 (r'(bicubic_patch|blob|box|camera|cone|cubic|cylinder|difference|'
861 r'disc|height_field|intersection|julia_fractal|lathe|'
862 r'light_source|merge|mesh|object|plane|poly|polygon|prism|'
863 r'quadric|quartic|smooth_triangle|sor|sphere|superellipsoid|'
864 r'text|torus|triangle|union)\b', Name.Builtin),
865 # TODO: <=, etc
866 (r'[\[\](){}<>;,]', Punctuation),
867 (r'[-+*/=]', Operator),
868 (r'\b(x|y|z|u|v)\b', Name.Builtin.Pseudo),
869 (r'[a-zA-Z_][a-zA-Z_0-9]*', Name),
870 (r'[0-9]+\.[0-9]*', Number.Float),
871 (r'\.[0-9]+', Number.Float),
872 (r'[0-9]+', Number.Integer),
873 (r'\s+', Text),
874 ]
875 }
876
877
878 class AppleScriptLexer(RegexLexer):
879 """
880 For `AppleScript source code
881 <http://developer.apple.com/documentation/AppleScript/
882 Conceptual/AppleScriptLangGuide>`_,
883 including `AppleScript Studio
884 <http://developer.apple.com/documentation/AppleScript/
885 Reference/StudioReference>`_.
886 Contributed by Andreas Amann <aamann@mac.com>.
887 """
888
889 name = 'AppleScript'
890 aliases = ['applescript']
891 filenames = ['*.applescript']
892
893 flags = re.MULTILINE | re.DOTALL
894
895 Identifiers = r'[a-zA-Z]\w*'
896 Literals = ['AppleScript', 'current application', 'false', 'linefeed',
897 'missing value', 'pi','quote', 'result', 'return', 'space',
898 'tab', 'text item delimiters', 'true', 'version']
899 Classes = ['alias ', 'application ', 'boolean ', 'class ', 'constant ',
900 'date ', 'file ', 'integer ', 'list ', 'number ', 'POSIX file ',
901 'real ', 'record ', 'reference ', 'RGB color ', 'script ',
902 'text ', 'unit types', '(?:Unicode )?text', 'string']
903 BuiltIn = ['attachment', 'attribute run', 'character', 'day', 'month',
904 'paragraph', 'word', 'year']
905 HandlerParams = ['about', 'above', 'against', 'apart from', 'around',
906 'aside from', 'at', 'below', 'beneath', 'beside',
907 'between', 'for', 'given', 'instead of', 'on', 'onto',
908 'out of', 'over', 'since']
909 Commands = ['ASCII (character|number)', 'activate', 'beep', 'choose URL',
910 'choose application', 'choose color', 'choose file( name)?',
911 'choose folder', 'choose from list',
912 'choose remote application', 'clipboard info',
913 'close( access)?', 'copy', 'count', 'current date', 'delay',
914 'delete', 'display (alert|dialog)', 'do shell script',
915 'duplicate', 'exists', 'get eof', 'get volume settings',
916 'info for', 'launch', 'list (disks|folder)', 'load script',
917 'log', 'make', 'mount volume', 'new', 'offset',
918 'open( (for access|location))?', 'path to', 'print', 'quit',
919 'random number', 'read', 'round', 'run( script)?',
920 'say', 'scripting components',
921 'set (eof|the clipboard to|volume)', 'store script',
922 'summarize', 'system attribute', 'system info',
923 'the clipboard', 'time to GMT', 'write', 'quoted form']
924 References = ['(in )?back of', '(in )?front of', '[0-9]+(st|nd|rd|th)',
925 'first', 'second', 'third', 'fourth', 'fifth', 'sixth',
926 'seventh', 'eighth', 'ninth', 'tenth', 'after', 'back',
927 'before', 'behind', 'every', 'front', 'index', 'last',
928 'middle', 'some', 'that', 'through', 'thru', 'where', 'whose']
929 Operators = ["and", "or", "is equal", "equals", "(is )?equal to", "is not",
930 "isn't", "isn't equal( to)?", "is not equal( to)?",
931 "doesn't equal", "does not equal", "(is )?greater than",
932 "comes after", "is not less than or equal( to)?",
933 "isn't less than or equal( to)?", "(is )?less than",
934 "comes before", "is not greater than or equal( to)?",
935 "isn't greater than or equal( to)?",
936 "(is )?greater than or equal( to)?", "is not less than",
937 "isn't less than", "does not come before",
938 "doesn't come before", "(is )?less than or equal( to)?",
939 "is not greater than", "isn't greater than",
940 "does not come after", "doesn't come after", "starts? with",
941 "begins? with", "ends? with", "contains?", "does not contain",
942 "doesn't contain", "is in", "is contained by", "is not in",
943 "is not contained by", "isn't contained by", "div", "mod",
944 "not", "(a )?(ref( to)?|reference to)", "is", "does"]
945 Control = ['considering', 'else', 'error', 'exit', 'from', 'if',
946 'ignoring', 'in', 'repeat', 'tell', 'then', 'times', 'to',
947 'try', 'until', 'using terms from', 'while', 'whith',
948 'with timeout( of)?', 'with transaction', 'by', 'continue',
949 'end', 'its?', 'me', 'my', 'return', 'of' , 'as']
950 Declarations = ['global', 'local', 'prop(erty)?', 'set', 'get']
951 Reserved = ['but', 'put', 'returning', 'the']
952 StudioClasses = ['action cell', 'alert reply', 'application', 'box',
953 'browser( cell)?', 'bundle', 'button( cell)?', 'cell',
954 'clip view', 'color well', 'color-panel',
955 'combo box( item)?', 'control',
956 'data( (cell|column|item|row|source))?', 'default entry',
957 'dialog reply', 'document', 'drag info', 'drawer',
958 'event', 'font(-panel)?', 'formatter',
959 'image( (cell|view))?', 'matrix', 'menu( item)?', 'item',
960 'movie( view)?', 'open-panel', 'outline view', 'panel',
961 'pasteboard', 'plugin', 'popup button',
962 'progress indicator', 'responder', 'save-panel',
963 'scroll view', 'secure text field( cell)?', 'slider',
964 'sound', 'split view', 'stepper', 'tab view( item)?',
965 'table( (column|header cell|header view|view))',
966 'text( (field( cell)?|view))?', 'toolbar( item)?',
967 'user-defaults', 'view', 'window']
968 StudioEvents = ['accept outline drop', 'accept table drop', 'action',
969 'activated', 'alert ended', 'awake from nib', 'became key',
970 'became main', 'begin editing', 'bounds changed',
971 'cell value', 'cell value changed', 'change cell value',
972 'change item value', 'changed', 'child of item',
973 'choose menu item', 'clicked', 'clicked toolbar item',
974 'closed', 'column clicked', 'column moved',
975 'column resized', 'conclude drop', 'data representation',
976 'deminiaturized', 'dialog ended', 'document nib name',
977 'double clicked', 'drag( (entered|exited|updated))?',
978 'drop', 'end editing', 'exposed', 'idle', 'item expandable',
979 'item value', 'item value changed', 'items changed',
980 'keyboard down', 'keyboard up', 'launched',
981 'load data representation', 'miniaturized', 'mouse down',
982 'mouse dragged', 'mouse entered', 'mouse exited',
983 'mouse moved', 'mouse up', 'moved',
984 'number of browser rows', 'number of items',
985 'number of rows', 'open untitled', 'opened', 'panel ended',
986 'parameters updated', 'plugin loaded', 'prepare drop',
987 'prepare outline drag', 'prepare outline drop',
988 'prepare table drag', 'prepare table drop',
989 'read from file', 'resigned active', 'resigned key',
990 'resigned main', 'resized( sub views)?',
991 'right mouse down', 'right mouse dragged',
992 'right mouse up', 'rows changed', 'scroll wheel',
993 'selected tab view item', 'selection changed',
994 'selection changing', 'should begin editing',
995 'should close', 'should collapse item',
996 'should end editing', 'should expand item',
997 'should open( untitled)?',
998 'should quit( after last window closed)?',
999 'should select column', 'should select item',
1000 'should select row', 'should select tab view item',
1001 'should selection change', 'should zoom', 'shown',
1002 'update menu item', 'update parameters',
1003 'update toolbar item', 'was hidden', 'was miniaturized',
1004 'will become active', 'will close', 'will dismiss',
1005 'will display browser cell', 'will display cell',
1006 'will display item cell', 'will display outline cell',
1007 'will finish launching', 'will hide', 'will miniaturize',
1008 'will move', 'will open', 'will pop up', 'will quit',
1009 'will resign active', 'will resize( sub views)?',
1010 'will select tab view item', 'will show', 'will zoom',
1011 'write to file', 'zoomed']
1012 StudioCommands = ['animate', 'append', 'call method', 'center',
1013 'close drawer', 'close panel', 'display',
1014 'display alert', 'display dialog', 'display panel', 'go',
1015 'hide', 'highlight', 'increment', 'item for',
1016 'load image', 'load movie', 'load nib', 'load panel',
1017 'load sound', 'localized string', 'lock focus', 'log',
1018 'open drawer', 'path for', 'pause', 'perform action',
1019 'play', 'register', 'resume', 'scroll', 'select( all)?',
1020 'show', 'size to fit', 'start', 'step back',
1021 'step forward', 'stop', 'synchronize', 'unlock focus',
1022 'update']
1023 StudioProperties = ['accepts arrow key', 'action method', 'active',
1024 'alignment', 'allowed identifiers',
1025 'allows branch selection', 'allows column reordering',
1026 'allows column resizing', 'allows column selection',
1027 'allows customization',
1028 'allows editing text attributes',
1029 'allows empty selection', 'allows mixed state',
1030 'allows multiple selection', 'allows reordering',
1031 'allows undo', 'alpha( value)?', 'alternate image',
1032 'alternate increment value', 'alternate title',
1033 'animation delay', 'associated file name',
1034 'associated object', 'auto completes', 'auto display',
1035 'auto enables items', 'auto repeat',
1036 'auto resizes( outline column)?',
1037 'auto save expanded items', 'auto save name',
1038 'auto save table columns', 'auto saves configuration',
1039 'auto scroll', 'auto sizes all columns to fit',
1040 'auto sizes cells', 'background color', 'bezel state',
1041 'bezel style', 'bezeled', 'border rect', 'border type',
1042 'bordered', 'bounds( rotation)?', 'box type',
1043 'button returned', 'button type',
1044 'can choose directories', 'can choose files',
1045 'can draw', 'can hide',
1046 'cell( (background color|size|type))?', 'characters',
1047 'class', 'click count', 'clicked( data)? column',
1048 'clicked data item', 'clicked( data)? row',
1049 'closeable', 'collating', 'color( (mode|panel))',
1050 'command key down', 'configuration',
1051 'content(s| (size|view( margins)?))?', 'context',
1052 'continuous', 'control key down', 'control size',
1053 'control tint', 'control view',
1054 'controller visible', 'coordinate system',
1055 'copies( on scroll)?', 'corner view', 'current cell',
1056 'current column', 'current( field)? editor',
1057 'current( menu)? item', 'current row',
1058 'current tab view item', 'data source',
1059 'default identifiers', 'delta (x|y|z)',
1060 'destination window', 'directory', 'display mode',
1061 'displayed cell', 'document( (edited|rect|view))?',
1062 'double value', 'dragged column', 'dragged distance',
1063 'dragged items', 'draws( cell)? background',
1064 'draws grid', 'dynamically scrolls', 'echos bullets',
1065 'edge', 'editable', 'edited( data)? column',
1066 'edited data item', 'edited( data)? row', 'enabled',
1067 'enclosing scroll view', 'ending page',
1068 'error handling', 'event number', 'event type',
1069 'excluded from windows menu', 'executable path',
1070 'expanded', 'fax number', 'field editor', 'file kind',
1071 'file name', 'file type', 'first responder',
1072 'first visible column', 'flipped', 'floating',
1073 'font( panel)?', 'formatter', 'frameworks path',
1074 'frontmost', 'gave up', 'grid color', 'has data items',
1075 'has horizontal ruler', 'has horizontal scroller',
1076 'has parent data item', 'has resize indicator',
1077 'has shadow', 'has sub menu', 'has vertical ruler',
1078 'has vertical scroller', 'header cell', 'header view',
1079 'hidden', 'hides when deactivated', 'highlights by',
1080 'horizontal line scroll', 'horizontal page scroll',
1081 'horizontal ruler view', 'horizontally resizable',
1082 'icon image', 'id', 'identifier',
1083 'ignores multiple clicks',
1084 'image( (alignment|dims when disabled|frame style|'
1085 'scaling))?',
1086 'imports graphics', 'increment value',
1087 'indentation per level', 'indeterminate', 'index',
1088 'integer value', 'intercell spacing', 'item height',
1089 'key( (code|equivalent( modifier)?|window))?',
1090 'knob thickness', 'label', 'last( visible)? column',
1091 'leading offset', 'leaf', 'level', 'line scroll',
1092 'loaded', 'localized sort', 'location', 'loop mode',
1093 'main( (bunde|menu|window))?', 'marker follows cell',
1094 'matrix mode', 'maximum( content)? size',
1095 'maximum visible columns',
1096 'menu( form representation)?', 'miniaturizable',
1097 'miniaturized', 'minimized image', 'minimized title',
1098 'minimum column width', 'minimum( content)? size',
1099 'modal', 'modified', 'mouse down state',
1100 'movie( (controller|file|rect))?', 'muted', 'name',
1101 'needs display', 'next state', 'next text',
1102 'number of tick marks', 'only tick mark values',
1103 'opaque', 'open panel', 'option key down',
1104 'outline table column', 'page scroll', 'pages across',
1105 'pages down', 'palette label', 'pane splitter',
1106 'parent data item', 'parent window', 'pasteboard',
1107 'path( (names|separator))?', 'playing',
1108 'plays every frame', 'plays selection only', 'position',
1109 'preferred edge', 'preferred type', 'pressure',
1110 'previous text', 'prompt', 'properties',
1111 'prototype cell', 'pulls down', 'rate',
1112 'released when closed', 'repeated',
1113 'requested print time', 'required file type',
1114 'resizable', 'resized column', 'resource path',
1115 'returns records', 'reuses columns', 'rich text',
1116 'roll over', 'row height', 'rulers visible',
1117 'save panel', 'scripts path', 'scrollable',
1118 'selectable( identifiers)?', 'selected cell',
1119 'selected( data)? columns?', 'selected data items?',
1120 'selected( data)? rows?', 'selected item identifier',
1121 'selection by rect', 'send action on arrow key',
1122 'sends action when done editing', 'separates columns',
1123 'separator item', 'sequence number', 'services menu',
1124 'shared frameworks path', 'shared support path',
1125 'sheet', 'shift key down', 'shows alpha',
1126 'shows state by', 'size( mode)?',
1127 'smart insert delete enabled', 'sort case sensitivity',
1128 'sort column', 'sort order', 'sort type',
1129 'sorted( data rows)?', 'sound', 'source( mask)?',
1130 'spell checking enabled', 'starting page', 'state',
1131 'string value', 'sub menu', 'super menu', 'super view',
1132 'tab key traverses cells', 'tab state', 'tab type',
1133 'tab view', 'table view', 'tag', 'target( printer)?',
1134 'text color', 'text container insert',
1135 'text container origin', 'text returned',
1136 'tick mark position', 'time stamp',
1137 'title(d| (cell|font|height|position|rect))?',
1138 'tool tip', 'toolbar', 'trailing offset', 'transparent',
1139 'treat packages as directories', 'truncated labels',
1140 'types', 'unmodified characters', 'update views',
1141 'use sort indicator', 'user defaults',
1142 'uses data source', 'uses ruler',
1143 'uses threaded animation',
1144 'uses title from previous column', 'value wraps',
1145 'version',
1146 'vertical( (line scroll|page scroll|ruler view))?',
1147 'vertically resizable', 'view',
1148 'visible( document rect)?', 'volume', 'width', 'window',
1149 'windows menu', 'wraps', 'zoomable', 'zoomed']
1150
1151 tokens = {
1152 'root': [
1153 (r'\s+', Text),
1154 (r'¬\n', String.Escape),
1155 (r"'s\s+", Text), # This is a possessive, consider moving
1156 (r'(--|#).*?$', Comment),
1157 (r'\(\*', Comment.Multiline, 'comment'),
1158 (r'[\(\){}!,.:]', Punctuation),
1159 (r'(«)([^»]+)(»)',
1160 bygroups(Text, Name.Builtin, Text)),
1161 (r'\b((?:considering|ignoring)\s*)'
1162 r'(application responses|case|diacriticals|hyphens|'
1163 r'numeric strings|punctuation|white space)',
1164 bygroups(Keyword, Name.Builtin)),
1165 (r'(-|\*|\+|&|≠|>=?|<=?|=|≥|≤|/|÷|\^)', Operator),
1166 (r"\b(%s)\b" % '|'.join(Operators), Operator.Word),
1167 (r'^(\s*(?:on|end)\s+)'
1168 r'(%s)' % '|'.join(StudioEvents[::-1]),
1169 bygroups(Keyword, Name.Function)),
1170 (r'^(\s*)(in|on|script|to)(\s+)', bygroups(Text, Keyword, Text)),
1171 (r'\b(as )(%s)\b' % '|'.join(Classes),
1172 bygroups(Keyword, Name.Class)),
1173 (r'\b(%s)\b' % '|'.join(Literals), Name.Constant),
1174 (r'\b(%s)\b' % '|'.join(Commands), Name.Builtin),
1175 (r'\b(%s)\b' % '|'.join(Control), Keyword),
1176 (r'\b(%s)\b' % '|'.join(Declarations), Keyword),
1177 (r'\b(%s)\b' % '|'.join(Reserved), Name.Builtin),
1178 (r'\b(%s)s?\b' % '|'.join(BuiltIn), Name.Builtin),
1179 (r'\b(%s)\b' % '|'.join(HandlerParams), Name.Builtin),
1180 (r'\b(%s)\b' % '|'.join(StudioProperties), Name.Attribute),
1181 (r'\b(%s)s?\b' % '|'.join(StudioClasses), Name.Builtin),
1182 (r'\b(%s)\b' % '|'.join(StudioCommands), Name.Builtin),
1183 (r'\b(%s)\b' % '|'.join(References), Name.Builtin),
1184 (r'"(\\\\|\\"|[^"])*"', String.Double),
1185 (r'\b(%s)\b' % Identifiers, Name.Variable),
1186 (r'[-+]?(\d+\.\d*|\d*\.\d+)(E[-+][0-9]+)?', Number.Float),
1187 (r'[-+]?\d+', Number.Integer),
1188 ],
1189 'comment': [
1190 ('\(\*', Comment.Multiline, '#push'),
1191 ('\*\)', Comment.Multiline, '#pop'),
1192 ('[^*(]+', Comment.Multiline),
1193 ('[*(]', Comment.Multiline),
1194 ],
1195 }
1196
1197
1198 class ModelicaLexer(RegexLexer):
1199 """
1200 For `Modelica <http://www.modelica.org/>`_ source code.
1201
1202 *New in Pygments 1.1.*
1203 """
1204 name = 'Modelica'
1205 aliases = ['modelica']
1206 filenames = ['*.mo']
1207 mimetypes = ['text/x-modelica']
1208
1209 flags = re.IGNORECASE | re.DOTALL
1210
1211 tokens = {
1212 'whitespace': [
1213 (r'\n', Text),
1214 (r'\s+', Text),
1215 (r'\\\n', Text), # line continuation
1216 (r'//(\n|(.|\n)*?[^\\]\n)', Comment),
1217 (r'/(\\\n)?\*(.|\n)*?\*(\\\n)?/', Comment),
1218 ],
1219 'statements': [
1220 (r'"', String, 'string'),
1221 (r'(\d+\.\d*|\.\d+|\d+|\d.)[eE][+-]?\d+[lL]?', Number.Float),
1222 (r'(\d+\.\d*|\.\d+)', Number.Float),
1223 (r'\d+[Ll]?', Number.Integer),
1224 (r'[~!%^&*+=|?:<>/-]', Operator),
1225 (r'[()\[\]{},.;]', Punctuation),
1226 (r'(true|false|NULL|Real|Integer|Boolean)\b', Name.Builtin),
1227 (r"([a-zA-Z_][\w]*|'[a-zA-Z_\+\-\*\/\^][\w]*')"
1228 r"(\.([a-zA-Z_][\w]*|'[a-zA-Z_\+\-\*\/\^][\w]*'))+", Name.Class),
1229 (r"('[\w\+\-\*\/\^]+'|\w+)", Name),
1230 ],
1231 'root': [
1232 include('whitespace'),
1233 include('keywords'),
1234 include('functions'),
1235 include('operators'),
1236 include('classes'),
1237 (r'("<html>|<html>)', Name.Tag, 'html-content'),
1238 include('statements'),
1239 ],
1240 'keywords': [
1241 (r'(algorithm|annotation|break|connect|constant|constrainedby|'
1242 r'discrete|each|else|elseif|elsewhen|encapsulated|enumeration|'
1243 r'end|equation|exit|expandable|extends|'
1244 r'external|false|final|flow|for|if|import|impure|in|initial\sequation|'
1245 r'inner|input|loop|nondiscrete|outer|output|parameter|partial|'
1246 r'protected|public|pure|redeclare|replaceable|stream|time|then|true|'
1247 r'when|while|within)\b', Keyword),
1248 ],
1249 'functions': [
1250 (r'(abs|acos|acosh|asin|asinh|atan|atan2|atan3|ceil|cos|cosh|'
1251 r'cross|div|exp|floor|getInstanceName|log|log10|mod|rem|'
1252 r'semiLinear|sign|sin|sinh|size|spatialDistribution|sqrt|tan|'
1253 r'tanh|zeros)\b', Name.Function),
1254 ],
1255 'operators': [
1256 (r'(actualStream|and|assert|cardinality|change|Clock|delay|der|edge|'
1257 r'hold|homotopy|initial|inStream|noEvent|not|or|pre|previous|reinit|'
1258 r'return|sample|smooth|spatialDistribution|subSample|terminal|'
1259 r'terminate)\b', Name.Builtin),
1260 ],
1261 'classes': [
1262 (r'(block|class|connector|function|model|package|'
1263 r'record|type)(\s+)([A-Za-z_]+)',
1264 bygroups(Keyword, Text, Name.Class))
1265 ],
1266 'string': [
1267 (r'"', String, '#pop'),
1268 (r'\\([\\abfnrtv"\']|x[a-fA-F0-9]{2,4}|[0-7]{1,3})',
1269 String.Escape),
1270 (r'[^\\"\n]+', String), # all other characters
1271 (r'\\\n', String), # line continuation
1272 (r'\\', String), # stray backslash
1273 ],
1274 'html-content': [
1275 (r'<\s*/\s*html\s*>', Name.Tag, '#pop'),
1276 (r'.+?(?=<\s*/\s*html\s*>)', using(HtmlLexer)),
1277 ]
1278 }
1279
1280
1281 class RebolLexer(RegexLexer):
1282 """
1283 A `REBOL <http://www.rebol.com/>`_ lexer.
1284
1285 *New in Pygments 1.1.*
1286 """
1287 name = 'REBOL'
1288 aliases = ['rebol']
1289 filenames = ['*.r', '*.r3']
1290 mimetypes = ['text/x-rebol']
1291
1292 flags = re.IGNORECASE | re.MULTILINE
1293
1294 re.IGNORECASE
1295
1296 escape_re = r'(?:\^\([0-9a-fA-F]{1,4}\)*)'
1297
1298 def word_callback(lexer, match):
1299 word = match.group()
1300
1301 if re.match(".*:$", word):
1302 yield match.start(), Generic.Subheading, word
1303 elif re.match(
1304 r'(native|alias|all|any|as-string|as-binary|bind|bound\?|case|'
1305 r'catch|checksum|comment|debase|dehex|exclude|difference|disarm|'
1306 r'either|else|enbase|foreach|remove-each|form|free|get|get-env|if|'
1307 r'in|intersect|loop|minimum-of|maximum-of|mold|new-line|'
1308 r'new-line\?|not|now|prin|print|reduce|compose|construct|repeat|'
1309 r'reverse|save|script\?|set|shift|switch|throw|to-hex|trace|try|'
1310 r'type\?|union|unique|unless|unprotect|unset|until|use|value\?|'
1311 r'while|compress|decompress|secure|open|close|read|read-io|'
1312 r'write-io|write|update|query|wait|input\?|exp|log-10|log-2|'
1313 r'log-e|square-root|cosine|sine|tangent|arccosine|arcsine|'
1314 r'arctangent|protect|lowercase|uppercase|entab|detab|connected\?|'
1315 r'browse|launch|stats|get-modes|set-modes|to-local-file|'
1316 r'to-rebol-file|encloak|decloak|create-link|do-browser|bind\?|'
1317 r'hide|draw|show|size-text|textinfo|offset-to-caret|'
1318 r'caret-to-offset|local-request-file|rgb-to-hsv|hsv-to-rgb|'
1319 r'crypt-strength\?|dh-make-key|dh-generate-key|dh-compute-key|'
1320 r'dsa-make-key|dsa-generate-key|dsa-make-signature|'
1321 r'dsa-verify-signature|rsa-make-key|rsa-generate-key|'
1322 r'rsa-encrypt)$', word):
1323 yield match.start(), Name.Builtin, word
1324 elif re.match(
1325 r'(add|subtract|multiply|divide|remainder|power|and~|or~|xor~|'
1326 r'minimum|maximum|negate|complement|absolute|random|head|tail|'
1327 r'next|back|skip|at|pick|first|second|third|fourth|fifth|sixth|'
1328 r'seventh|eighth|ninth|tenth|last|path|find|select|make|to|copy\*|'
1329 r'insert|remove|change|poke|clear|trim|sort|min|max|abs|cp|'
1330 r'copy)$', word):
1331 yield match.start(), Name.Function, word
1332 elif re.match(
1333 r'(error|source|input|license|help|install|echo|Usage|with|func|'
1334 r'throw-on-error|function|does|has|context|probe|\?\?|as-pair|'
1335 r'mod|modulo|round|repend|about|set-net|append|join|rejoin|reform|'
1336 r'remold|charset|array|replace|move|extract|forskip|forall|alter|'
1337 r'first+|also|take|for|forever|dispatch|attempt|what-dir|'
1338 r'change-dir|clean-path|list-dir|dirize|rename|split-path|delete|'
1339 r'make-dir|delete-dir|in-dir|confirm|dump-obj|upgrade|what|'
1340 r'build-tag|process-source|build-markup|decode-cgi|read-cgi|'
1341 r'write-user|save-user|set-user-name|protect-system|parse-xml|'
1342 r'cvs-date|cvs-version|do-boot|get-net-info|desktop|layout|'
1343 r'scroll-para|get-face|alert|set-face|uninstall|unfocus|'
1344 r'request-dir|center-face|do-events|net-error|decode-url|'
1345 r'parse-header|parse-header-date|parse-email-addrs|import-email|'
1346 r'send|build-attach-body|resend|show-popup|hide-popup|open-events|'
1347 r'find-key-face|do-face|viewtop|confine|find-window|'
1348 r'insert-event-func|remove-event-func|inform|dump-pane|dump-face|'
1349 r'flag-face|deflag-face|clear-fields|read-net|vbug|path-thru|'
1350 r'read-thru|load-thru|do-thru|launch-thru|load-image|'
1351 r'request-download|do-face-alt|set-font|set-para|get-style|'
1352 r'set-style|make-face|stylize|choose|hilight-text|hilight-all|'
1353 r'unlight-text|focus|scroll-drag|clear-face|reset-face|scroll-face|'
1354 r'resize-face|load-stock|load-stock-block|notify|request|flash|'
1355 r'request-color|request-pass|request-text|request-list|'
1356 r'request-date|request-file|dbug|editor|link-relative-path|'
1357 r'emailer|parse-error)$', word):
1358 yield match.start(), Keyword.Namespace, word
1359 elif re.match(
1360 r'(halt|quit|do|load|q|recycle|call|run|ask|parse|view|unview|'
1361 r'return|exit|break)$', word):
1362 yield match.start(), Name.Exception, word
1363 elif re.match('REBOL$', word):
1364 yield match.start(), Generic.Heading, word
1365 elif re.match("to-.*", word):
1366 yield match.start(), Keyword, word
1367 elif re.match('(\+|-|\*|/|//|\*\*|and|or|xor|=\?|=|==|<>|<|>|<=|>=)$',
1368 word):
1369 yield match.start(), Operator, word
1370 elif re.match(".*\?$", word):
1371 yield match.start(), Keyword, word
1372 elif re.match(".*\!$", word):
1373 yield match.start(), Keyword.Type, word
1374 elif re.match("'.*", word):
1375 yield match.start(), Name.Variable.Instance, word # lit-word
1376 elif re.match("#.*", word):
1377 yield match.start(), Name.Label, word # issue
1378 elif re.match("%.*", word):
1379 yield match.start(), Name.Decorator, word # file
1380 else:
1381 yield match.start(), Name.Variable, word
1382
1383 tokens = {
1384 'root': [
1385 (r'REBOL', Generic.Strong, 'script'),
1386 (r'R', Comment),
1387 (r'[^R]+', Comment),
1388 ],
1389 'script': [
1390 (r'\s+', Text),
1391 (r'#"', String.Char, 'char'),
1392 (r'#{[0-9a-fA-F]*}', Number.Hex),
1393 (r'2#{', Number.Hex, 'bin2'),
1394 (r'64#{[0-9a-zA-Z+/=\s]*}', Number.Hex),
1395 (r'"', String, 'string'),
1396 (r'{', String, 'string2'),
1397 (r';#+.*\n', Comment.Special),
1398 (r';\*+.*\n', Comment.Preproc),
1399 (r';.*\n', Comment),
1400 (r'%"', Name.Decorator, 'stringFile'),
1401 (r'%[^(\^{^")\s\[\]]+', Name.Decorator),
1402 (r'<[a-zA-Z0-9:._-]*>', Name.Tag),
1403 (r'<[^(<>\s")]+', Name.Tag, 'tag'),
1404 (r'[+-]?([a-zA-Z]{1,3})?\$\d+(\.\d+)?', Number.Float), # money
1405 (r'[+-]?\d+\:\d+(\:\d+)?(\.\d+)?', String.Other), # time
1406 (r'\d+\-[0-9a-zA-Z]+\-\d+(\/\d+\:\d+(\:\d+)?'
1407 r'([\.\d+]?([+-]?\d+:\d+)?)?)?', String.Other), # date
1408 (r'\d+(\.\d+)+\.\d+', Keyword.Constant), # tuple
1409 (r'\d+[xX]\d+', Keyword.Constant), # pair
1410 (r'[+-]?\d+(\'\d+)?([\.,]\d*)?[eE][+-]?\d+', Number.Float),
1411 (r'[+-]?\d+(\'\d+)?[\.,]\d*', Number.Float),
1412 (r'[+-]?\d+(\'\d+)?', Number),
1413 (r'[\[\]\(\)]', Generic.Strong),
1414 (r'[a-zA-Z]+[^(\^{"\s:)]*://[^(\^{"\s)]*', Name.Decorator), # url
1415 (r'mailto:[^(\^{"@\s)]+@[^(\^{"@\s)]+', Name.Decorator), # url
1416 (r'[^(\^{"@\s)]+@[^(\^{"@\s)]+', Name.Decorator), # email
1417 (r'comment\s', Comment, 'comment'),
1418 (r'/[^(\^{^")\s/[\]]*', Name.Attribute),
1419 (r'([^(\^{^")\s/[\]]+)(?=[:({"\s/\[\]])', word_callback),
1420 (r'([^(\^{^")\s]+)', Text),
1421 ],
1422 'string': [
1423 (r'[^(\^")]+', String),
1424 (escape_re, String.Escape),
1425 (r'[\(|\)]+', String),
1426 (r'\^.', String.Escape),
1427 (r'"', String, '#pop'),
1428 ],
1429 'string2': [
1430 (r'[^(\^{^})]+', String),
1431 (escape_re, String.Escape),
1432 (r'[\(|\)]+', String),
1433 (r'\^.', String.Escape),
1434 (r'{', String, '#push'),
1435 (r'}', String, '#pop'),
1436 ],
1437 'stringFile': [
1438 (r'[^(\^")]+', Name.Decorator),
1439 (escape_re, Name.Decorator),
1440 (r'\^.', Name.Decorator),
1441 (r'"', Name.Decorator, '#pop'),
1442 ],
1443 'char': [
1444 (escape_re + '"', String.Char, '#pop'),
1445 (r'\^."', String.Char, '#pop'),
1446 (r'."', String.Char, '#pop'),
1447 ],
1448 'tag': [
1449 (escape_re, Name.Tag),
1450 (r'"', Name.Tag, 'tagString'),
1451 (r'[^(<>\r\n")]+', Name.Tag),
1452 (r'>', Name.Tag, '#pop'),
1453 ],
1454 'tagString': [
1455 (r'[^(\^")]+', Name.Tag),
1456 (escape_re, Name.Tag),
1457 (r'[\(|\)]+', Name.Tag),
1458 (r'\^.', Name.Tag),
1459 (r'"', Name.Tag, '#pop'),
1460 ],
1461 'tuple': [
1462 (r'(\d+\.)+', Keyword.Constant),
1463 (r'\d+', Keyword.Constant, '#pop'),
1464 ],
1465 'bin2': [
1466 (r'\s+', Number.Hex),
1467 (r'([0-1]\s*){8}', Number.Hex),
1468 (r'}', Number.Hex, '#pop'),
1469 ],
1470 'comment': [
1471 (r'"', Comment, 'commentString1'),
1472 (r'{', Comment, 'commentString2'),
1473 (r'\[', Comment, 'commentBlock'),
1474 (r'[^(\s{\"\[]+', Comment, '#pop'),
1475 ],
1476 'commentString1': [
1477 (r'[^(\^")]+', Comment),
1478 (escape_re, Comment),
1479 (r'[\(|\)]+', Comment),
1480 (r'\^.', Comment),
1481 (r'"', Comment, '#pop'),
1482 ],
1483 'commentString2': [
1484 (r'[^(\^{^})]+', Comment),
1485 (escape_re, Comment),
1486 (r'[\(|\)]+', Comment),
1487 (r'\^.', Comment),
1488 (r'{', Comment, '#push'),
1489 (r'}', Comment, '#pop'),
1490 ],
1491 'commentBlock': [
1492 (r'\[', Comment, '#push'),
1493 (r'\]', Comment, '#pop'),
1494 (r'[^(\[\])]+', Comment),
1495 ],
1496 }
1497
1498
1499 class ABAPLexer(RegexLexer):
1500 """
1501 Lexer for ABAP, SAP's integrated language.
1502
1503 *New in Pygments 1.1.*
1504 """
1505 name = 'ABAP'
1506 aliases = ['abap']
1507 filenames = ['*.abap']
1508 mimetypes = ['text/x-abap']
1509
1510 flags = re.IGNORECASE | re.MULTILINE
1511
1512 tokens = {
1513 'common': [
1514 (r'\s+', Text),
1515 (r'^\*.*$', Comment.Single),
1516 (r'\".*?\n', Comment.Single),
1517 ],
1518 'variable-names': [
1519 (r'<[\S_]+>', Name.Variable),
1520 (r'\w[\w~]*(?:(\[\])|->\*)?', Name.Variable),
1521 ],
1522 'root': [
1523 include('common'),
1524 #function calls
1525 (r'(CALL\s+(?:BADI|CUSTOMER-FUNCTION|FUNCTION))(\s+)(\'?\S+\'?)',
1526 bygroups(Keyword, Text, Name.Function)),
1527 (r'(CALL\s+(?:DIALOG|SCREEN|SUBSCREEN|SELECTION-SCREEN|'
1528 r'TRANSACTION|TRANSFORMATION))\b',
1529 Keyword),
1530 (r'(FORM|PERFORM)(\s+)(\w+)',
1531 bygroups(Keyword, Text, Name.Function)),
1532 (r'(PERFORM)(\s+)(\()(\w+)(\))',
1533 bygroups(Keyword, Text, Punctuation, Name.Variable, Punctuation )),
1534 (r'(MODULE)(\s+)(\S+)(\s+)(INPUT|OUTPUT)',
1535 bygroups(Keyword, Text, Name.Function, Text, Keyword)),
1536
1537 # method implementation
1538 (r'(METHOD)(\s+)([\w~]+)',
1539 bygroups(Keyword, Text, Name.Function)),
1540 # method calls
1541 (r'(\s+)([\w\-]+)([=\-]>)([\w\-~]+)',
1542 bygroups(Text, Name.Variable, Operator, Name.Function)),
1543 # call methodnames returning style
1544 (r'(?<=(=|-)>)([\w\-~]+)(?=\()', Name.Function),
1545
1546 # keywords with dashes in them.
1547 # these need to be first, because for instance the -ID part
1548 # of MESSAGE-ID wouldn't get highlighted if MESSAGE was
1549 # first in the list of keywords.
1550 (r'(ADD-CORRESPONDING|AUTHORITY-CHECK|'
1551 r'CLASS-DATA|CLASS-EVENTS|CLASS-METHODS|CLASS-POOL|'
1552 r'DELETE-ADJACENT|DIVIDE-CORRESPONDING|'
1553 r'EDITOR-CALL|ENHANCEMENT-POINT|ENHANCEMENT-SECTION|EXIT-COMMAND|'
1554 r'FIELD-GROUPS|FIELD-SYMBOLS|FUNCTION-POOL|'
1555 r'INTERFACE-POOL|INVERTED-DATE|'
1556 r'LOAD-OF-PROGRAM|LOG-POINT|'
1557 r'MESSAGE-ID|MOVE-CORRESPONDING|MULTIPLY-CORRESPONDING|'
1558 r'NEW-LINE|NEW-PAGE|NEW-SECTION|NO-EXTENSION|'
1559 r'OUTPUT-LENGTH|PRINT-CONTROL|'
1560 r'SELECT-OPTIONS|START-OF-SELECTION|SUBTRACT-CORRESPONDING|'
1561 r'SYNTAX-CHECK|SYSTEM-EXCEPTIONS|'
1562 r'TYPE-POOL|TYPE-POOLS'
1563 r')\b', Keyword),
1564
1565 # keyword kombinations
1566 (r'CREATE\s+(PUBLIC|PRIVATE|DATA|OBJECT)|'
1567 r'((PUBLIC|PRIVATE|PROTECTED)\s+SECTION|'
1568 r'(TYPE|LIKE)(\s+(LINE\s+OF|REF\s+TO|'
1569 r'(SORTED|STANDARD|HASHED)\s+TABLE\s+OF))?|'
1570 r'FROM\s+(DATABASE|MEMORY)|CALL\s+METHOD|'
1571 r'(GROUP|ORDER) BY|HAVING|SEPARATED BY|'
1572 r'GET\s+(BADI|BIT|CURSOR|DATASET|LOCALE|PARAMETER|'
1573 r'PF-STATUS|(PROPERTY|REFERENCE)\s+OF|'
1574 r'RUN\s+TIME|TIME\s+(STAMP)?)?|'
1575 r'SET\s+(BIT|BLANK\s+LINES|COUNTRY|CURSOR|DATASET|EXTENDED\s+CHECK|'
1576 r'HANDLER|HOLD\s+DATA|LANGUAGE|LEFT\s+SCROLL-BOUNDARY|'
1577 r'LOCALE|MARGIN|PARAMETER|PF-STATUS|PROPERTY\s+OF|'
1578 r'RUN\s+TIME\s+(ANALYZER|CLOCK\s+RESOLUTION)|SCREEN|'
1579 r'TITLEBAR|UPADTE\s+TASK\s+LOCAL|USER-COMMAND)|'
1580 r'CONVERT\s+((INVERTED-)?DATE|TIME|TIME\s+STAMP|TEXT)|'
1581 r'(CLOSE|OPEN)\s+(DATASET|CURSOR)|'
1582 r'(TO|FROM)\s+(DATA BUFFER|INTERNAL TABLE|MEMORY ID|'
1583 r'DATABASE|SHARED\s+(MEMORY|BUFFER))|'
1584 r'DESCRIBE\s+(DISTANCE\s+BETWEEN|FIELD|LIST|TABLE)|'
1585 r'FREE\s(MEMORY|OBJECT)?|'
1586 r'PROCESS\s+(BEFORE\s+OUTPUT|AFTER\s+INPUT|'
1587 r'ON\s+(VALUE-REQUEST|HELP-REQUEST))|'
1588 r'AT\s+(LINE-SELECTION|USER-COMMAND|END\s+OF|NEW)|'
1589 r'AT\s+SELECTION-SCREEN(\s+(ON(\s+(BLOCK|(HELP|VALUE)-REQUEST\s+FOR|'
1590 r'END\s+OF|RADIOBUTTON\s+GROUP))?|OUTPUT))?|'
1591 r'SELECTION-SCREEN:?\s+((BEGIN|END)\s+OF\s+((TABBED\s+)?BLOCK|LINE|'
1592 r'SCREEN)|COMMENT|FUNCTION\s+KEY|'
1593 r'INCLUDE\s+BLOCKS|POSITION|PUSHBUTTON|'
1594 r'SKIP|ULINE)|'
1595 r'LEAVE\s+(LIST-PROCESSING|PROGRAM|SCREEN|'
1596 r'TO LIST-PROCESSING|TO TRANSACTION)'
1597 r'(ENDING|STARTING)\s+AT|'
1598 r'FORMAT\s+(COLOR|INTENSIFIED|INVERSE|HOTSPOT|INPUT|FRAMES|RESET)|'
1599 r'AS\s+(CHECKBOX|SUBSCREEN|WINDOW)|'
1600 r'WITH\s+(((NON-)?UNIQUE)?\s+KEY|FRAME)|'
1601 r'(BEGIN|END)\s+OF|'
1602 r'DELETE(\s+ADJACENT\s+DUPLICATES\sFROM)?|'
1603 r'COMPARING(\s+ALL\s+FIELDS)?|'
1604 r'INSERT(\s+INITIAL\s+LINE\s+INTO|\s+LINES\s+OF)?|'
1605 r'IN\s+((BYTE|CHARACTER)\s+MODE|PROGRAM)|'
1606 r'END-OF-(DEFINITION|PAGE|SELECTION)|'
1607 r'WITH\s+FRAME(\s+TITLE)|'
1608
1609 # simple kombinations
1610 r'AND\s+(MARK|RETURN)|CLIENT\s+SPECIFIED|CORRESPONDING\s+FIELDS\s+OF|'
1611 r'IF\s+FOUND|FOR\s+EVENT|INHERITING\s+FROM|LEAVE\s+TO\s+SCREEN|'
1612 r'LOOP\s+AT\s+(SCREEN)?|LOWER\s+CASE|MATCHCODE\s+OBJECT|MODIF\s+ID|'
1613 r'MODIFY\s+SCREEN|NESTING\s+LEVEL|NO\s+INTERVALS|OF\s+STRUCTURE|'
1614 r'RADIOBUTTON\s+GROUP|RANGE\s+OF|REF\s+TO|SUPPRESS DIALOG|'
1615 r'TABLE\s+OF|UPPER\s+CASE|TRANSPORTING\s+NO\s+FIELDS|'
1616 r'VALUE\s+CHECK|VISIBLE\s+LENGTH|HEADER\s+LINE)\b', Keyword),
1617
1618 # single word keywords.
1619 (r'(^|(?<=(\s|\.)))(ABBREVIATED|ADD|ALIASES|APPEND|ASSERT|'
1620 r'ASSIGN(ING)?|AT(\s+FIRST)?|'
1621 r'BACK|BLOCK|BREAK-POINT|'
1622 r'CASE|CATCH|CHANGING|CHECK|CLASS|CLEAR|COLLECT|COLOR|COMMIT|'
1623 r'CREATE|COMMUNICATION|COMPONENTS?|COMPUTE|CONCATENATE|CONDENSE|'
1624 r'CONSTANTS|CONTEXTS|CONTINUE|CONTROLS|'
1625 r'DATA|DECIMALS|DEFAULT|DEFINE|DEFINITION|DEFERRED|DEMAND|'
1626 r'DETAIL|DIRECTORY|DIVIDE|DO|'
1627 r'ELSE(IF)?|ENDAT|ENDCASE|ENDCLASS|ENDDO|ENDFORM|ENDFUNCTION|'
1628 r'ENDIF|ENDLOOP|ENDMETHOD|ENDMODULE|ENDSELECT|ENDTRY|'
1629 r'ENHANCEMENT|EVENTS|EXCEPTIONS|EXIT|EXPORT|EXPORTING|EXTRACT|'
1630 r'FETCH|FIELDS?|FIND|FOR|FORM|FORMAT|FREE|FROM|'
1631 r'HIDE|'
1632 r'ID|IF|IMPORT|IMPLEMENTATION|IMPORTING|IN|INCLUDE|INCLUDING|'
1633 r'INDEX|INFOTYPES|INITIALIZATION|INTERFACE|INTERFACES|INTO|'
1634 r'LENGTH|LINES|LOAD|LOCAL|'
1635 r'JOIN|'
1636 r'KEY|'
1637 r'MAXIMUM|MESSAGE|METHOD[S]?|MINIMUM|MODULE|MODIFY|MOVE|MULTIPLY|'
1638 r'NODES|'
1639 r'OBLIGATORY|OF|OFF|ON|OVERLAY|'
1640 r'PACK|PARAMETERS|PERCENTAGE|POSITION|PROGRAM|PROVIDE|PUBLIC|PUT|'
1641 r'RAISE|RAISING|RANGES|READ|RECEIVE|REFRESH|REJECT|REPORT|RESERVE|'
1642 r'RESUME|RETRY|RETURN|RETURNING|RIGHT|ROLLBACK|'
1643 r'SCROLL|SEARCH|SELECT|SHIFT|SINGLE|SKIP|SORT|SPLIT|STATICS|STOP|'
1644 r'SUBMIT|SUBTRACT|SUM|SUMMARY|SUMMING|SUPPLY|'
1645 r'TABLE|TABLES|TIMES|TITLE|TO|TOP-OF-PAGE|TRANSFER|TRANSLATE|TRY|TYPES|'
1646 r'ULINE|UNDER|UNPACK|UPDATE|USING|'
1647 r'VALUE|VALUES|VIA|'
1648 r'WAIT|WHEN|WHERE|WHILE|WITH|WINDOW|WRITE)\b', Keyword),
1649
1650 # builtins
1651 (r'(abs|acos|asin|atan|'
1652 r'boolc|boolx|bit_set|'
1653 r'char_off|charlen|ceil|cmax|cmin|condense|contains|'
1654 r'contains_any_of|contains_any_not_of|concat_lines_of|cos|cosh|'
1655 r'count|count_any_of|count_any_not_of|'
1656 r'dbmaxlen|distance|'
1657 r'escape|exp|'
1658 r'find|find_end|find_any_of|find_any_not_of|floor|frac|from_mixed|'
1659 r'insert|'
1660 r'lines|log|log10|'
1661 r'match|matches|'
1662 r'nmax|nmin|numofchar|'
1663 r'repeat|replace|rescale|reverse|round|'
1664 r'segment|shift_left|shift_right|sign|sin|sinh|sqrt|strlen|'
1665 r'substring|substring_after|substring_from|substring_before|substring_to|'
1666 r'tan|tanh|to_upper|to_lower|to_mixed|translate|trunc|'
1667 r'xstrlen)(\()\b', bygroups(Name.Builtin, Punctuation)),
1668
1669 (r'&[0-9]', Name),
1670 (r'[0-9]+', Number.Integer),
1671
1672 # operators which look like variable names before
1673 # parsing variable names.
1674 (r'(?<=(\s|.))(AND|EQ|NE|GT|LT|GE|LE|CO|CN|CA|NA|CS|NOT|NS|CP|NP|'
1675 r'BYTE-CO|BYTE-CN|BYTE-CA|BYTE-NA|BYTE-CS|BYTE-NS|'
1676 r'IS\s+(NOT\s+)?(INITIAL|ASSIGNED|REQUESTED|BOUND))\b', Operator),
1677
1678 include('variable-names'),
1679
1680 # standard oparators after variable names,
1681 # because < and > are part of field symbols.
1682 (r'[?*<>=\-+]', Operator),
1683 (r"'(''|[^'])*'", String.Single),
1684 (r'[/;:()\[\],\.]', Punctuation)
1685 ],
1686 }
1687
1688
1689 class NewspeakLexer(RegexLexer):
1690 """
1691 For `Newspeak <http://newspeaklanguage.org/>` syntax.
1692 """
1693 name = 'Newspeak'
1694 filenames = ['*.ns2']
1695 aliases = ['newspeak', ]
1696 mimetypes = ['text/x-newspeak']
1697
1698 tokens = {
1699 'root' : [
1700 (r'\b(Newsqueak2)\b',Keyword.Declaration),
1701 (r"'[^']*'",String),
1702 (r'\b(class)(\s+)([a-zA-Z0-9_]+)(\s*)',
1703 bygroups(Keyword.Declaration,Text,Name.Class,Text)),
1704 (r'\b(mixin|self|super|private|public|protected|nil|true|false)\b',
1705 Keyword),
1706 (r'([a-zA-Z0-9_]+\:)(\s*)([a-zA-Z_]\w+)',
1707 bygroups(Name.Function,Text,Name.Variable)),
1708 (r'([a-zA-Z0-9_]+)(\s*)(=)',
1709 bygroups(Name.Attribute,Text,Operator)),
1710 (r'<[a-zA-Z0-9_]+>', Comment.Special),
1711 include('expressionstat'),
1712 include('whitespace')
1713 ],
1714
1715 'expressionstat': [
1716 (r'(\d+\.\d*|\.\d+|\d+[fF])[fF]?', Number.Float),
1717 (r'\d+', Number.Integer),
1718 (r':\w+',Name.Variable),
1719 (r'(\w+)(::)', bygroups(Name.Variable, Operator)),
1720 (r'\w+:', Name.Function),
1721 (r'\w+', Name.Variable),
1722 (r'\(|\)', Punctuation),
1723 (r'\[|\]', Punctuation),
1724 (r'\{|\}', Punctuation),
1725
1726 (r'(\^|\+|\/|~|\*|<|>|=|@|%|\||&|\?|!|,|-|:)', Operator),
1727 (r'\.|;', Punctuation),
1728 include('whitespace'),
1729 include('literals'),
1730 ],
1731 'literals': [
1732 (r'\$.', String),
1733 (r"'[^']*'", String),
1734 (r"#'[^']*'", String.Symbol),
1735 (r"#\w+:?", String.Symbol),
1736 (r"#(\+|\/|~|\*|<|>|=|@|%|\||&|\?|!|,|-)+", String.Symbol)
1737
1738 ],
1739 'whitespace' : [
1740 (r'\s+', Text),
1741 (r'"[^"]*"', Comment)
1742 ]
1743 }
1744
1745
1746 class GherkinLexer(RegexLexer):
1747 """
1748 For `Gherkin <http://github.com/aslakhellesoy/gherkin/>` syntax.
1749
1750 *New in Pygments 1.2.*
1751 """
1752 name = 'Gherkin'
1753 aliases = ['Cucumber', 'cucumber', 'Gherkin', 'gherkin']
1754 filenames = ['*.feature']
1755 mimetypes = ['text/x-gherkin']
1756
1757 feature_keywords = r'^(기능|機能|功能|フィーチャ|خاصية|תכונה|Функціонал|Функционалност|Функционал|Фича|Особина|Могућност|Özellik|Właściwość|Tính năng|Trajto|Savybė|Požiadavka|Požadavek|Osobina|Ominaisuus|Omadus|OH HAI|Mogućnost|Mogucnost|Jellemző|Fīča|Funzionalità|Funktionalität|Funkcionalnost|Funkcionalitāte|Funcționalitate|Functionaliteit|Functionalitate|Funcionalitat|Funcionalidade|Fonctionnalité|Fitur|Feature|Egenskap|Egenskab|Crikey|Característica|Arwedd)(:)(.*)$'
1758 feature_element_keywords = r'^(\s*)(시나리오 개요|시나리오|배경|背景|場景大綱|場景|场景大纲|场景|劇本大綱|劇本|テンプレ|シナリオテンプレート|シナリオテンプレ|シナリオアウトライン|シナリオ|سيناريو مخطط|سيناريو|الخلفية|תרחיש|תבנית תרחיש|רקע|Тарих|Сценарій|Сценарио|Сценарий структураси|Сценарий|Структура сценарію|Структура сценарија|Структура сценария|Скица|Рамка на сценарий|Пример|Предыстория|Предистория|Позадина|Передумова|Основа|Концепт|Контекст|Założenia|Wharrimean is|Tình huống|The thing of it is|Tausta|Taust|Tapausaihio|Tapaus|Szenariogrundriss|Szenario|Szablon scenariusza|Stsenaarium|Struktura scenarija|Skica|Skenario konsep|Skenario|Situācija|Senaryo taslağı|Senaryo|Scénář|Scénario|Schema dello scenario|Scenārijs pēc parauga|Scenārijs|Scenár|Scenaro|Scenariusz|Scenariul de şablon|Scenariul de sablon|Scenariu|Scenario Outline|Scenario Amlinellol|Scenario|Scenarijus|Scenarijaus šablonas|Scenarij|Scenarie|Rerefons|Raamstsenaarium|Primer|Pozadí|Pozadina|Pozadie|Plan du scénario|Plan du Scénario|Osnova scénáře|Osnova|Náčrt Scénáře|Náčrt Scenáru|Mate|MISHUN SRSLY|MISHUN|Kịch bản|Konturo de la scenaro|Kontext|Konteksts|Kontekstas|Kontekst|Koncept|Khung tình huống|Khung kịch bản|Háttér|Grundlage|Geçmiş|Forgatókönyv vázlat|Forgatókönyv|Fono|Esquema do Cenário|Esquema do Cenario|Esquema del escenario|Esquema de l\'escenari|Escenario|Escenari|Dis is what went down|Dasar|Contexto|Contexte|Contesto|Condiţii|Conditii|Cenário|Cenario|Cefndir|Bối cảnh|Blokes|Bakgrunn|Bakgrund|Baggrund|Background|B4|Antecedents|Antecedentes|All y\'all|Achtergrond|Abstrakt Scenario|Abstract Scenario)(:)(.*)$'
1759 examples_keywords = r'^(\s*)(예|例子|例|サンプル|امثلة|דוגמאות|Сценарији|Примери|Приклади|Мисоллар|Значения|Örnekler|Voorbeelden|Variantai|Tapaukset|Scenarios|Scenariji|Scenarijai|Příklady|Példák|Príklady|Przykłady|Primjeri|Primeri|Piemēri|Pavyzdžiai|Paraugs|Juhtumid|Exemplos|Exemples|Exemplele|Exempel|Examples|Esempi|Enghreifftiau|Ekzemploj|Eksempler|Ejemplos|EXAMPLZ|Dữ liệu|Contoh|Cobber|Beispiele)(:)(.*)$'
1760 step_keywords = r'^(\s*)(하지만|조건|먼저|만일|만약|단|그리고|그러면|那麼|那么|而且|當|当|前提|假設|假如|但是|但し|並且|もし|ならば|ただし|しかし|かつ|و |متى |لكن |عندما |ثم |بفرض |اذاً |כאשר |וגם |בהינתן |אזי |אז |אבל |Якщо |Унда |То |Припустимо, що |Припустимо |Онда |Но |Нехай |Лекин |Когато |Када |Кад |К тому же |И |Задато |Задати |Задате |Если |Допустим |Дадено |Ва |Бирок |Аммо |Али |Але |Агар |А |І |Și |És |Zatati |Zakładając |Zadato |Zadate |Zadano |Zadani |Zadan |Youse know when youse got |Youse know like when |Yna |Ya know how |Ya gotta |Y |Wun |Wtedy |When y\'all |When |Wenn |WEN |Và |Ve |Und |Un |Thì |Then y\'all |Then |Tapi |Tak |Tada |Tad |Så |Stel |Soit |Siis |Si |Sed |Se |Quando |Quand |Quan |Pryd |Pokud |Pokiaľ |Però |Pero |Pak |Oraz |Onda |Ond |Oletetaan |Og |Och |O zaman |Når |När |Niin |Nhưng |N |Mutta |Men |Mas |Maka |Majd |Mais |Maar |Ma |Lorsque |Lorsqu\'|Kun |Kuid |Kui |Khi |Keď |Ketika |Když |Kaj |Kai |Kada |Kad |Jeżeli |Ja |Ir |I CAN HAZ |I |Ha |Givun |Givet |Given y\'all |Given |Gitt |Gegeven |Gegeben sei |Fakat |Eğer ki |Etant donné |Et |Então |Entonces |Entao |En |Eeldades |E |Duota |Dun |Donitaĵo |Donat |Donada |Do |Diyelim ki |Dengan |Den youse gotta |De |Dato |Dar |Dann |Dan |Dado |Dacă |Daca |DEN |Când |Cuando |Cho |Cept |Cand |Cal |But y\'all |But |Buh |Biết |Bet |BUT |Atès |Atunci |Atesa |Anrhegedig a |Angenommen |And y\'all |And |An |Ama |Als |Alors |Allora |Ali |Aleshores |Ale |Akkor |Aber |AN |A také |A |\* )'
1761
1762 tokens = {
1763 'comments': [
1764 (r'#.*$', Comment),
1765 ],
1766 'feature_elements' : [
1767 (step_keywords, Keyword, "step_content_stack"),
1768 include('comments'),
1769 (r"(\s|.)", Name.Function),
1770 ],
1771 'feature_elements_on_stack' : [
1772 (step_keywords, Keyword, "#pop:2"),
1773 include('comments'),
1774 (r"(\s|.)", Name.Function),
1775 ],
1776 'examples_table': [
1777 (r"\s+\|", Keyword, 'examples_table_header'),
1778 include('comments'),
1779 (r"(\s|.)", Name.Function),
1780 ],
1781 'examples_table_header': [
1782 (r"\s+\|\s*$", Keyword, "#pop:2"),
1783 include('comments'),
1784 (r"\s*\|", Keyword),
1785 (r"[^\|]", Name.Variable),
1786 ],
1787 'scenario_sections_on_stack': [
1788 (feature_element_keywords, bygroups(Name.Function, Keyword, Keyword, Name.Function), "feature_elements_on_stack"),
1789 ],
1790 'narrative': [
1791 include('scenario_sections_on_stack'),
1792 (r"(\s|.)", Name.Function),
1793 ],
1794 'table_vars': [
1795 (r'(<[^>]+>)', Name.Variable),
1796 ],
1797 'numbers': [
1798 (r'(\d+\.?\d*|\d*\.\d+)([eE][+-]?[0-9]+)?', String),
1799 ],
1800 'string': [
1801 include('table_vars'),
1802 (r'(\s|.)', String),
1803 ],
1804 'py_string': [
1805 (r'"""', Keyword, "#pop"),
1806 include('string'),
1807 ],
1808 'step_content_root':[
1809 (r"$", Keyword, "#pop"),
1810 include('step_content'),
1811 ],
1812 'step_content_stack':[
1813 (r"$", Keyword, "#pop:2"),
1814 include('step_content'),
1815 ],
1816 'step_content':[
1817 (r'"', Name.Function, "double_string"),
1818 include('table_vars'),
1819 include('numbers'),
1820 include('comments'),
1821 (r'(\s|.)', Name.Function),
1822 ],
1823 'table_content': [
1824 (r"\s+\|\s*$", Keyword, "#pop"),
1825 include('comments'),
1826 (r"\s*\|", Keyword),
1827 include('string'),
1828 ],
1829 'double_string': [
1830 (r'"', Name.Function, "#pop"),
1831 include('string'),
1832 ],
1833 'root': [
1834 (r'\n', Name.Function),
1835 include('comments'),
1836 (r'"""', Keyword, "py_string"),
1837 (r'\s+\|', Keyword, 'table_content'),
1838 (r'"', Name.Function, "double_string"),
1839 include('table_vars'),
1840 include('numbers'),
1841 (r'(\s*)(@[^@\r\n\t ]+)', bygroups(Name.Function, Name.Tag)),
1842 (step_keywords, bygroups(Name.Function, Keyword),
1843 'step_content_root'),
1844 (feature_keywords, bygroups(Keyword, Keyword, Name.Function),
1845 'narrative'),
1846 (feature_element_keywords,
1847 bygroups(Name.Function, Keyword, Keyword, Name.Function),
1848 'feature_elements'),
1849 (examples_keywords,
1850 bygroups(Name.Function, Keyword, Keyword, Name.Function),
1851 'examples_table'),
1852 (r'(\s|.)', Name.Function),
1853 ]
1854 }
1855
1856 class AsymptoteLexer(RegexLexer):
1857 """
1858 For `Asymptote <http://asymptote.sf.net/>`_ source code.
1859
1860 *New in Pygments 1.2.*
1861 """
1862 name = 'Asymptote'
1863 aliases = ['asy', 'asymptote']
1864 filenames = ['*.asy']
1865 mimetypes = ['text/x-asymptote']
1866
1867 #: optional Comment or Whitespace
1868 _ws = r'(?:\s|//.*?\n|/\*.*?\*/)+'
1869
1870 tokens = {
1871 'whitespace': [
1872 (r'\n', Text),
1873 (r'\s+', Text),
1874 (r'\\\n', Text), # line continuation
1875 (r'//(\n|(.|\n)*?[^\\]\n)', Comment),
1876 (r'/(\\\n)?\*(.|\n)*?\*(\\\n)?/', Comment),
1877 ],
1878 'statements': [
1879 # simple string (TeX friendly)
1880 (r'"(\\\\|\\"|[^"])*"', String),
1881 # C style string (with character escapes)
1882 (r"'", String, 'string'),
1883 (r'(\d+\.\d*|\.\d+|\d+)[eE][+-]?\d+[lL]?', Number.Float),
1884 (r'(\d+\.\d*|\.\d+|\d+[fF])[fF]?', Number.Float),
1885 (r'0x[0-9a-fA-F]+[Ll]?', Number.Hex),
1886 (r'0[0-7]+[Ll]?', Number.Oct),
1887 (r'\d+[Ll]?', Number.Integer),
1888 (r'[~!%^&*+=|?:<>/-]', Operator),
1889 (r'[()\[\],.]', Punctuation),
1890 (r'\b(case)(.+?)(:)', bygroups(Keyword, using(this), Text)),
1891 (r'(and|controls|tension|atleast|curl|if|else|while|for|do|'
1892 r'return|break|continue|struct|typedef|new|access|import|'
1893 r'unravel|from|include|quote|static|public|private|restricted|'
1894 r'this|explicit|true|false|null|cycle|newframe|operator)\b', Keyword),
1895 # Since an asy-type-name can be also an asy-function-name,
1896 # in the following we test if the string " [a-zA-Z]" follows
1897 # the Keyword.Type.
1898 # Of course it is not perfect !
1899 (r'(Braid|FitResult|Label|Legend|TreeNode|abscissa|arc|arrowhead|'
1900 r'binarytree|binarytreeNode|block|bool|bool3|bounds|bqe|circle|'
1901 r'conic|coord|coordsys|cputime|ellipse|file|filltype|frame|grid3|'
1902 r'guide|horner|hsv|hyperbola|indexedTransform|int|inversion|key|'
1903 r'light|line|linefit|marginT|marker|mass|object|pair|parabola|path|'
1904 r'path3|pen|picture|point|position|projection|real|revolution|'
1905 r'scaleT|scientific|segment|side|slice|splitface|string|surface|'
1906 r'tensionSpecifier|ticklocate|ticksgridT|tickvalues|transform|'
1907 r'transformation|tree|triangle|trilinear|triple|vector|'
1908 r'vertex|void)(?=([ ]{1,}[a-zA-Z]))', Keyword.Type),
1909 # Now the asy-type-name which are not asy-function-name
1910 # except yours !
1911 # Perhaps useless
1912 (r'(Braid|FitResult|TreeNode|abscissa|arrowhead|block|bool|bool3|'
1913 r'bounds|coord|frame|guide|horner|int|linefit|marginT|pair|pen|'
1914 r'picture|position|real|revolution|slice|splitface|ticksgridT|'
1915 r'tickvalues|tree|triple|vertex|void)\b', Keyword.Type),
1916 ('[a-zA-Z_][a-zA-Z0-9_]*:(?!:)', Name.Label),
1917 ('[a-zA-Z_][a-zA-Z0-9_]*', Name),
1918 ],
1919 'root': [
1920 include('whitespace'),
1921 # functions
1922 (r'((?:[a-zA-Z0-9_*\s])+?(?:\s|\*))' # return arguments
1923 r'([a-zA-Z_][a-zA-Z0-9_]*)' # method name
1924 r'(\s*\([^;]*?\))' # signature
1925 r'(' + _ws + r')({)',
1926 bygroups(using(this), Name.Function, using(this), using(this),
1927 Punctuation),
1928 'function'),
1929 # function declarations
1930 (r'((?:[a-zA-Z0-9_*\s])+?(?:\s|\*))' # return arguments
1931 r'([a-zA-Z_][a-zA-Z0-9_]*)' # method name
1932 r'(\s*\([^;]*?\))' # signature
1933 r'(' + _ws + r')(;)',
1934 bygroups(using(this), Name.Function, using(this), using(this),
1935 Punctuation)),
1936 ('', Text, 'statement'),
1937 ],
1938 'statement' : [
1939 include('whitespace'),
1940 include('statements'),
1941 ('[{}]', Punctuation),
1942 (';', Punctuation, '#pop'),
1943 ],
1944 'function': [
1945 include('whitespace'),
1946 include('statements'),
1947 (';', Punctuation),
1948 ('{', Punctuation, '#push'),
1949 ('}', Punctuation, '#pop'),
1950 ],
1951 'string': [
1952 (r"'", String, '#pop'),
1953 (r'\\([\\abfnrtv"\'?]|x[a-fA-F0-9]{2,4}|[0-7]{1,3})', String.Escape),
1954 (r'\n', String),
1955 (r"[^\\'\n]+", String), # all other characters
1956 (r'\\\n', String),
1957 (r'\\n', String), # line continuation
1958 (r'\\', String), # stray backslash
1959 ]
1960 }
1961
1962 def get_tokens_unprocessed(self, text):
1963 from pygments.lexers._asybuiltins import ASYFUNCNAME, ASYVARNAME
1964 for index, token, value in \
1965 RegexLexer.get_tokens_unprocessed(self, text):
1966 if token is Name and value in ASYFUNCNAME:
1967 token = Name.Function
1968 elif token is Name and value in ASYVARNAME:
1969 token = Name.Variable
1970 yield index, token, value
1971
1972
1973 class PostScriptLexer(RegexLexer):
1974 """
1975 Lexer for PostScript files.
1976
1977 The PostScript Language Reference published by Adobe at
1978 <http://partners.adobe.com/public/developer/en/ps/PLRM.pdf>
1979 is the authority for this.
1980
1981 *New in Pygments 1.4.*
1982 """
1983 name = 'PostScript'
1984 aliases = ['postscript']
1985 filenames = ['*.ps', '*.eps']
1986 mimetypes = ['application/postscript']
1987
1988 delimiter = r'\(\)\<\>\[\]\{\}\/\%\s'
1989 delimiter_end = r'(?=[%s])' % delimiter
1990
1991 valid_name_chars = r'[^%s]' % delimiter
1992 valid_name = r"%s+%s" % (valid_name_chars, delimiter_end)
1993
1994 tokens = {
1995 'root': [
1996 # All comment types
1997 (r'^%!.+\n', Comment.Preproc),
1998 (r'%%.*\n', Comment.Special),
1999 (r'(^%.*\n){2,}', Comment.Multiline),
2000 (r'%.*\n', Comment.Single),
2001
2002 # String literals are awkward; enter separate state.
2003 (r'\(', String, 'stringliteral'),
2004
2005 (r'[\{\}(\<\<)(\>\>)\[\]]', Punctuation),
2006
2007 # Numbers
2008 (r'<[0-9A-Fa-f]+>' + delimiter_end, Number.Hex),
2009 # Slight abuse: use Oct to signify any explicit base system
2010 (r'[0-9]+\#(\-|\+)?([0-9]+\.?|[0-9]*\.[0-9]+|[0-9]+\.[0-9]*)'
2011 r'((e|E)[0-9]+)?' + delimiter_end, Number.Oct),
2012 (r'(\-|\+)?([0-9]+\.?|[0-9]*\.[0-9]+|[0-9]+\.[0-9]*)((e|E)[0-9]+)?'
2013 + delimiter_end, Number.Float),
2014 (r'(\-|\+)?[0-9]+' + delimiter_end, Number.Integer),
2015
2016 # References
2017 (r'\/%s' % valid_name, Name.Variable),
2018
2019 # Names
2020 (valid_name, Name.Function), # Anything else is executed
2021
2022 # These keywords taken from
2023 # <http://www.math.ubc.ca/~cass/graphics/manual/pdf/a1.pdf>
2024 # Is there an authoritative list anywhere that doesn't involve
2025 # trawling documentation?
2026
2027 (r'(false|true)' + delimiter_end, Keyword.Constant),
2028
2029 # Conditionals / flow control
2030 (r'(eq|ne|ge|gt|le|lt|and|or|not|if|ifelse|for|forall)'
2031 + delimiter_end, Keyword.Reserved),
2032
2033 ('(abs|add|aload|arc|arcn|array|atan|begin|bind|ceiling|charpath|'
2034 'clip|closepath|concat|concatmatrix|copy|cos|currentlinewidth|'
2035 'currentmatrix|currentpoint|curveto|cvi|cvs|def|defaultmatrix|'
2036 'dict|dictstackoverflow|div|dtransform|dup|end|exch|exec|exit|exp|'
2037 'fill|findfont|floor|get|getinterval|grestore|gsave|gt|'
2038 'identmatrix|idiv|idtransform|index|invertmatrix|itransform|'
2039 'length|lineto|ln|load|log|loop|matrix|mod|moveto|mul|neg|newpath|'
2040 'pathforall|pathbbox|pop|print|pstack|put|quit|rand|rangecheck|'
2041 'rcurveto|repeat|restore|rlineto|rmoveto|roll|rotate|round|run|'
2042 'save|scale|scalefont|setdash|setfont|setgray|setlinecap|'
2043 'setlinejoin|setlinewidth|setmatrix|setrgbcolor|shfill|show|'
2044 'showpage|sin|sqrt|stack|stringwidth|stroke|strokepath|sub|'
2045 'syntaxerror|transform|translate|truncate|typecheck|undefined|'
2046 'undefinedfilename|undefinedresult)' + delimiter_end,
2047 Name.Builtin),
2048
2049 (r'\s+', Text),
2050 ],
2051
2052 'stringliteral': [
2053 (r'[^\(\)\\]+', String),
2054 (r'\\', String.Escape, 'escape'),
2055 (r'\(', String, '#push'),
2056 (r'\)', String, '#pop'),
2057 ],
2058
2059 'escape': [
2060 (r'([0-8]{3}|n|r|t|b|f|\\|\(|\))?', String.Escape, '#pop'),
2061 ],
2062 }
2063
2064
2065 class AutohotkeyLexer(RegexLexer):
2066 """
2067 For `autohotkey <http://www.autohotkey.com/>`_ source code.
2068
2069 *New in Pygments 1.4.*
2070 """
2071 name = 'autohotkey'
2072 aliases = ['ahk']
2073 filenames = ['*.ahk', '*.ahkl']
2074 mimetypes = ['text/x-autohotkey']
2075
2076 tokens = {
2077 'root': [
2078 (r'^(\s*)(/\*)', bygroups(Text, Comment.Multiline),
2079 'incomment'),
2080 (r'^(\s*)(\()', bygroups(Text, Generic), 'incontinuation'),
2081 (r'\s+;.*?$', Comment.Singleline),
2082 (r'^;.*?$', Comment.Singleline),
2083 (r'[]{}(),;[]', Punctuation),
2084 (r'(in|is|and|or|not)\b', Operator.Word),
2085 (r'\%[a-zA-Z_#@$][a-zA-Z0-9_#@$]*\%', Name.Variable),
2086 (r'!=|==|:=|\.=|<<|>>|[-~+/*%=<>&^|?:!.]', Operator),
2087 include('commands'),
2088 include('labels'),
2089 include('builtInFunctions'),
2090 include('builtInVariables'),
2091 (r'"', String, combined('stringescape', 'dqs')),
2092 include('numbers'),
2093 (r'[a-zA-Z_#@$][a-zA-Z0-9_#@$]*', Name),
2094 (r'\\|\'', Text),
2095 (r'\`([\,\%\`abfnrtv\-\+;])', String.Escape),
2096 include('garbage'),
2097 ],
2098 'incomment': [
2099 (r'^\s*\*/', Comment.Multiline, '#pop'),
2100 (r'[^*/]', Comment.Multiline),
2101 (r'[*/]', Comment.Multiline)
2102 ],
2103 'incontinuation': [
2104 (r'^\s*\)', Generic, '#pop'),
2105 (r'[^)]', Generic),
2106 (r'[)]', Generic),
2107 ],
2108 'commands': [
2109 (r'(?i)^(\s*)(global|local|static|'
2110 r'#AllowSameLineComments|#ClipboardTimeout|#CommentFlag|'
2111 r'#ErrorStdOut|#EscapeChar|#HotkeyInterval|#HotkeyModifierTimeout|'
2112 r'#Hotstring|#IfWinActive|#IfWinExist|#IfWinNotActive|'
2113 r'#IfWinNotExist|#IncludeAgain|#Include|#InstallKeybdHook|'
2114 r'#InstallMouseHook|#KeyHistory|#LTrim|#MaxHotkeysPerInterval|'
2115 r'#MaxMem|#MaxThreads|#MaxThreadsBuffer|#MaxThreadsPerHotkey|'
2116 r'#NoEnv|#NoTrayIcon|#Persistent|#SingleInstance|#UseHook|'
2117 r'#WinActivateForce|AutoTrim|BlockInput|Break|Click|ClipWait|'
2118 r'Continue|Control|ControlClick|ControlFocus|ControlGetFocus|'
2119 r'ControlGetPos|ControlGetText|ControlGet|ControlMove|ControlSend|'
2120 r'ControlSendRaw|ControlSetText|CoordMode|Critical|'
2121 r'DetectHiddenText|DetectHiddenWindows|Drive|DriveGet|'
2122 r'DriveSpaceFree|Edit|Else|EnvAdd|EnvDiv|EnvGet|EnvMult|EnvSet|'
2123 r'EnvSub|EnvUpdate|Exit|ExitApp|FileAppend|'
2124 r'FileCopy|FileCopyDir|FileCreateDir|FileCreateShortcut|'
2125 r'FileDelete|FileGetAttrib|FileGetShortcut|FileGetSize|'
2126 r'FileGetTime|FileGetVersion|FileInstall|FileMove|FileMoveDir|'
2127 r'FileRead|FileReadLine|FileRecycle|FileRecycleEmpty|'
2128 r'FileRemoveDir|FileSelectFile|FileSelectFolder|FileSetAttrib|'
2129 r'FileSetTime|FormatTime|GetKeyState|Gosub|Goto|GroupActivate|'
2130 r'GroupAdd|GroupClose|GroupDeactivate|Gui|GuiControl|'
2131 r'GuiControlGet|Hotkey|IfEqual|IfExist|IfGreaterOrEqual|IfGreater|'
2132 r'IfInString|IfLess|IfLessOrEqual|IfMsgBox|IfNotEqual|IfNotExist|'
2133 r'IfNotInString|IfWinActive|IfWinExist|IfWinNotActive|'
2134 r'IfWinNotExist|If |ImageSearch|IniDelete|IniRead|IniWrite|'
2135 r'InputBox|Input|KeyHistory|KeyWait|ListHotkeys|ListLines|'
2136 r'ListVars|Loop|Menu|MouseClickDrag|MouseClick|MouseGetPos|'
2137 r'MouseMove|MsgBox|OnExit|OutputDebug|Pause|PixelGetColor|'
2138 r'PixelSearch|PostMessage|Process|Progress|Random|RegDelete|'
2139 r'RegRead|RegWrite|Reload|Repeat|Return|RunAs|RunWait|Run|'
2140 r'SendEvent|SendInput|SendMessage|SendMode|SendPlay|SendRaw|Send|'
2141 r'SetBatchLines|SetCapslockState|SetControlDelay|'
2142 r'SetDefaultMouseSpeed|SetEnv|SetFormat|SetKeyDelay|'
2143 r'SetMouseDelay|SetNumlockState|SetScrollLockState|'
2144 r'SetStoreCapslockMode|SetTimer|SetTitleMatchMode|'
2145 r'SetWinDelay|SetWorkingDir|Shutdown|Sleep|Sort|SoundBeep|'
2146 r'SoundGet|SoundGetWaveVolume|SoundPlay|SoundSet|'
2147 r'SoundSetWaveVolume|SplashImage|SplashTextOff|SplashTextOn|'
2148 r'SplitPath|StatusBarGetText|StatusBarWait|StringCaseSense|'
2149 r'StringGetPos|StringLeft|StringLen|StringLower|StringMid|'
2150 r'StringReplace|StringRight|StringSplit|StringTrimLeft|'
2151 r'StringTrimRight|StringUpper|Suspend|SysGet|Thread|ToolTip|'
2152 r'Transform|TrayTip|URLDownloadToFile|While|WinActivate|'
2153 r'WinActivateBottom|WinClose|WinGetActiveStats|WinGetActiveTitle|'
2154 r'WinGetClass|WinGetPos|WinGetText|WinGetTitle|WinGet|WinHide|'
2155 r'WinKill|WinMaximize|WinMenuSelectItem|WinMinimizeAllUndo|'
2156 r'WinMinimizeAll|WinMinimize|WinMove|WinRestore|WinSetTitle|'
2157 r'WinSet|WinShow|WinWaitActive|WinWaitClose|WinWaitNotActive|'
2158 r'WinWait)\b', bygroups(Text, Name.Builtin)),
2159 ],
2160 'builtInFunctions': [
2161 (r'(?i)(Abs|ACos|Asc|ASin|ATan|Ceil|Chr|Cos|DllCall|Exp|FileExist|'
2162 r'Floor|GetKeyState|IL_Add|IL_Create|IL_Destroy|InStr|IsFunc|'
2163 r'IsLabel|Ln|Log|LV_Add|LV_Delete|LV_DeleteCol|LV_GetCount|'
2164 r'LV_GetNext|LV_GetText|LV_Insert|LV_InsertCol|LV_Modify|'
2165 r'LV_ModifyCol|LV_SetImageList|Mod|NumGet|NumPut|OnMessage|'
2166 r'RegExMatch|RegExReplace|RegisterCallback|Round|SB_SetIcon|'
2167 r'SB_SetParts|SB_SetText|Sin|Sqrt|StrLen|SubStr|Tan|TV_Add|'
2168 r'TV_Delete|TV_GetChild|TV_GetCount|TV_GetNext|TV_Get|'
2169 r'TV_GetParent|TV_GetPrev|TV_GetSelection|TV_GetText|TV_Modify|'
2170 r'VarSetCapacity|WinActive|WinExist|Object|ComObjActive|'
2171 r'ComObjArray|ComObjEnwrap|ComObjUnwrap|ComObjParameter|'
2172 r'ComObjType|ComObjConnect|ComObjCreate|ComObjGet|ComObjError|'
2173 r'ComObjValue|Insert|MinIndex|MaxIndex|Remove|SetCapacity|'
2174 r'GetCapacity|GetAddress|_NewEnum|FileOpen|Read|Write|ReadLine|'
2175 r'WriteLine|ReadNumType|WriteNumType|RawRead|RawWrite|Seek|Tell|'
2176 r'Close|Next|IsObject|StrPut|StrGet|Trim|LTrim|RTrim)\b',
2177 Name.Function),
2178 ],
2179 'builtInVariables': [
2180 (r'(?i)(A_AhkPath|A_AhkVersion|A_AppData|A_AppDataCommon|'
2181 r'A_AutoTrim|A_BatchLines|A_CaretX|A_CaretY|A_ComputerName|'
2182 r'A_ControlDelay|A_Cursor|A_DDDD|A_DDD|A_DD|A_DefaultMouseSpeed|'
2183 r'A_Desktop|A_DesktopCommon|A_DetectHiddenText|'
2184 r'A_DetectHiddenWindows|A_EndChar|A_EventInfo|A_ExitReason|'
2185 r'A_FormatFloat|A_FormatInteger|A_Gui|A_GuiEvent|A_GuiControl|'
2186 r'A_GuiControlEvent|A_GuiHeight|A_GuiWidth|A_GuiX|A_GuiY|A_Hour|'
2187 r'A_IconFile|A_IconHidden|A_IconNumber|A_IconTip|A_Index|'
2188 r'A_IPAddress1|A_IPAddress2|A_IPAddress3|A_IPAddress4|A_ISAdmin|'
2189 r'A_IsCompiled|A_IsCritical|A_IsPaused|A_IsSuspended|A_KeyDelay|'
2190 r'A_Language|A_LastError|A_LineFile|A_LineNumber|A_LoopField|'
2191 r'A_LoopFileAttrib|A_LoopFileDir|A_LoopFileExt|A_LoopFileFullPath|'
2192 r'A_LoopFileLongPath|A_LoopFileName|A_LoopFileShortName|'
2193 r'A_LoopFileShortPath|A_LoopFileSize|A_LoopFileSizeKB|'
2194 r'A_LoopFileSizeMB|A_LoopFileTimeAccessed|A_LoopFileTimeCreated|'
2195 r'A_LoopFileTimeModified|A_LoopReadLine|A_LoopRegKey|'
2196 r'A_LoopRegName|A_LoopRegSubkey|A_LoopRegTimeModified|'
2197 r'A_LoopRegType|A_MDAY|A_Min|A_MM|A_MMM|A_MMMM|A_Mon|A_MouseDelay|'
2198 r'A_MSec|A_MyDocuments|A_Now|A_NowUTC|A_NumBatchLines|A_OSType|'
2199 r'A_OSVersion|A_PriorHotkey|A_ProgramFiles|A_Programs|'
2200 r'A_ProgramsCommon|A_ScreenHeight|A_ScreenWidth|A_ScriptDir|'
2201 r'A_ScriptFullPath|A_ScriptName|A_Sec|A_Space|A_StartMenu|'
2202 r'A_StartMenuCommon|A_Startup|A_StartupCommon|A_StringCaseSense|'
2203 r'A_Tab|A_Temp|A_ThisFunc|A_ThisHotkey|A_ThisLabel|A_ThisMenu|'
2204 r'A_ThisMenuItem|A_ThisMenuItemPos|A_TickCount|A_TimeIdle|'
2205 r'A_TimeIdlePhysical|A_TimeSincePriorHotkey|A_TimeSinceThisHotkey|'
2206 r'A_TitleMatchMode|A_TitleMatchModeSpeed|A_UserName|A_WDay|'
2207 r'A_WinDelay|A_WinDir|A_WorkingDir|A_YDay|A_YEAR|A_YWeek|A_YYYY|'
2208 r'Clipboard|ClipboardAll|ComSpec|ErrorLevel|ProgramFiles|True|'
2209 r'False|A_IsUnicode|A_FileEncoding|A_OSVersion|A_PtrSize)\b',
2210 Name.Variable),
2211 ],
2212 'labels': [
2213 # hotkeys and labels
2214 # technically, hotkey names are limited to named keys and buttons
2215 (r'(^\s*)([^:\s\(\"]+?:{1,2})', bygroups(Text, Name.Label)),
2216 (r'(^\s*)(::[^:\s]+?::)', bygroups(Text, Name.Label)),
2217 ],
2218 'numbers': [
2219 (r'(\d+\.\d*|\d*\.\d+)([eE][+-]?[0-9]+)?', Number.Float),
2220 (r'\d+[eE][+-]?[0-9]+', Number.Float),
2221 (r'0\d+', Number.Oct),
2222 (r'0[xX][a-fA-F0-9]+', Number.Hex),
2223 (r'\d+L', Number.Integer.Long),
2224 (r'\d+', Number.Integer)
2225 ],
2226 'stringescape': [
2227 (r'\"\"|\`([\,\%\`abfnrtv])', String.Escape),
2228 ],
2229 'strings': [
2230 (r'[^"\n]+', String),
2231 ],
2232 'dqs': [
2233 (r'"', String, '#pop'),
2234 include('strings')
2235 ],
2236 'garbage': [
2237 (r'[^\S\n]', Text),
2238 # (r'.', Text), # no cheating
2239 ],
2240 }
2241
2242
2243 class MaqlLexer(RegexLexer):
2244 """
2245 Lexer for `GoodData MAQL
2246 <https://secure.gooddata.com/docs/html/advanced.metric.tutorial.html>`_
2247 scripts.
2248
2249 *New in Pygments 1.4.*
2250 """
2251
2252 name = 'MAQL'
2253 aliases = ['maql']
2254 filenames = ['*.maql']
2255 mimetypes = ['text/x-gooddata-maql','application/x-gooddata-maql']
2256
2257 flags = re.IGNORECASE
2258 tokens = {
2259 'root': [
2260 # IDENTITY
2261 (r'IDENTIFIER\b', Name.Builtin),
2262 # IDENTIFIER
2263 (r'\{[^}]+\}', Name.Variable),
2264 # NUMBER
2265 (r'[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]{1,3})?', Literal.Number),
2266 # STRING
2267 (r'"', Literal.String, 'string-literal'),
2268 # RELATION
2269 (r'\<\>|\!\=', Operator),
2270 (r'\=|\>\=|\>|\<\=|\<', Operator),
2271 # :=
2272 (r'\:\=', Operator),
2273 # OBJECT
2274 (r'\[[^]]+\]', Name.Variable.Class),
2275 # keywords
2276 (r'(DIMENSIONS?|BOTTOM|METRIC|COUNT|OTHER|FACT|WITH|TOP|OR|'
2277 r'ATTRIBUTE|CREATE|PARENT|FALSE|ROWS?|FROM|ALL|AS|PF|'
2278 r'COLUMNS?|DEFINE|REPORT|LIMIT|TABLE|LIKE|AND|BY|'
2279 r'BETWEEN|EXCEPT|SELECT|MATCH|WHERE|TRUE|FOR|IN|'
2280 r'WITHOUT|FILTER|ALIAS|ORDER|FACT|WHEN|NOT|ON|'
2281 r'KEYS|KEY|FULLSET|PRIMARY|LABELS|LABEL|VISUAL|'
2282 r'TITLE|DESCRIPTION|FOLDER|ALTER|DROP|ADD|DATASET|'
2283 r'DATATYPE|INT|BIGINT|DOUBLE|DATE|VARCHAR|DECIMAL|'
2284 r'SYNCHRONIZE|TYPE|DEFAULT|ORDER|ASC|DESC|HYPERLINK|'
2285 r'INCLUDE|TEMPLATE|MODIFY)\b', Keyword),
2286 # FUNCNAME
2287 (r'[a-zA-Z]\w*\b', Name.Function),
2288 # Comments
2289 (r'#.*', Comment.Single),
2290 # Punctuation
2291 (r'[,;\(\)]', Token.Punctuation),
2292 # Space is not significant
2293 (r'\s+', Text)
2294 ],
2295 'string-literal': [
2296 (r'\\[tnrfbae"\\]', String.Escape),
2297 (r'"', Literal.String, '#pop'),
2298 (r'[^\\"]+', Literal.String)
2299 ],
2300 }
2301
2302
2303 class GoodDataCLLexer(RegexLexer):
2304 """
2305 Lexer for `GoodData-CL <http://github.com/gooddata/GoodData-CL/raw/master/cli/src/main/resources/com/gooddata/processor/COMMANDS.txt>`_
2306 script files.
2307
2308 *New in Pygments 1.4.*
2309 """
2310
2311 name = 'GoodData-CL'
2312 aliases = ['gooddata-cl']
2313 filenames = ['*.gdc']
2314 mimetypes = ['text/x-gooddata-cl']
2315
2316 flags = re.IGNORECASE
2317 tokens = {
2318 'root': [
2319 # Comments
2320 (r'#.*', Comment.Single),
2321 # Function call
2322 (r'[a-zA-Z]\w*', Name.Function),
2323 # Argument list
2324 (r'\(', Token.Punctuation, 'args-list'),
2325 # Punctuation
2326 (r';', Token.Punctuation),
2327 # Space is not significant
2328 (r'\s+', Text)
2329 ],
2330 'args-list': [
2331 (r'\)', Token.Punctuation, '#pop'),
2332 (r',', Token.Punctuation),
2333 (r'[a-zA-Z]\w*', Name.Variable),
2334 (r'=', Operator),
2335 (r'"', Literal.String, 'string-literal'),
2336 (r'[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]{1,3})?', Literal.Number),
2337 # Space is not significant
2338 (r'\s', Text)
2339 ],
2340 'string-literal': [
2341 (r'\\[tnrfbae"\\]', String.Escape),
2342 (r'"', Literal.String, '#pop'),
2343 (r'[^\\"]+', Literal.String)
2344 ]
2345 }
2346
2347
2348 class ProtoBufLexer(RegexLexer):
2349 """
2350 Lexer for `Protocol Buffer <http://code.google.com/p/protobuf/>`_
2351 definition files.
2352
2353 *New in Pygments 1.4.*
2354 """
2355
2356 name = 'Protocol Buffer'
2357 aliases = ['protobuf']
2358 filenames = ['*.proto']
2359
2360 tokens = {
2361 'root': [
2362 (r'[ \t]+', Text),
2363 (r'[,;{}\[\]\(\)]', Punctuation),
2364 (r'/(\\\n)?/(\n|(.|\n)*?[^\\]\n)', Comment.Single),
2365 (r'/(\\\n)?\*(.|\n)*?\*(\\\n)?/', Comment.Multiline),
2366 (r'\b(import|option|optional|required|repeated|default|packed|'
2367 r'ctype|extensions|to|max|rpc|returns)\b', Keyword),
2368 (r'(int32|int64|uint32|uint64|sint32|sint64|'
2369 r'fixed32|fixed64|sfixed32|sfixed64|'
2370 r'float|double|bool|string|bytes)\b', Keyword.Type),
2371 (r'(true|false)\b', Keyword.Constant),
2372 (r'(package)(\s+)', bygroups(Keyword.Namespace, Text), 'package'),
2373 (r'(message|extend)(\s+)',
2374 bygroups(Keyword.Declaration, Text), 'message'),
2375 (r'(enum|group|service)(\s+)',
2376 bygroups(Keyword.Declaration, Text), 'type'),
2377 (r'\".*\"', String),
2378 (r'(\d+\.\d*|\.\d+|\d+)[eE][+-]?\d+[LlUu]*', Number.Float),
2379 (r'(\d+\.\d*|\.\d+|\d+[fF])[fF]?', Number.Float),
2380 (r'(\-?(inf|nan))', Number.Float),
2381 (r'0x[0-9a-fA-F]+[LlUu]*', Number.Hex),
2382 (r'0[0-7]+[LlUu]*', Number.Oct),
2383 (r'\d+[LlUu]*', Number.Integer),
2384 (r'[+-=]', Operator),
2385 (r'([a-zA-Z_][a-zA-Z0-9_\.]*)([ \t]*)(=)',
2386 bygroups(Name.Attribute, Text, Operator)),
2387 ('[a-zA-Z_][a-zA-Z0-9_\.]*', Name),
2388 ],
2389 'package': [
2390 (r'[a-zA-Z_][a-zA-Z0-9_]*', Name.Namespace, '#pop')
2391 ],
2392 'message': [
2393 (r'[a-zA-Z_][a-zA-Z0-9_]*', Name.Class, '#pop')
2394 ],
2395 'type': [
2396 (r'[a-zA-Z_][a-zA-Z0-9_]*', Name, '#pop')
2397 ],
2398 }
2399
2400
2401 class HybrisLexer(RegexLexer):
2402 """
2403 For `Hybris <http://www.hybris-lang.org>`_ source code.
2404
2405 *New in Pygments 1.4.*
2406 """
2407
2408 name = 'Hybris'
2409 aliases = ['hybris', 'hy']
2410 filenames = ['*.hy', '*.hyb']
2411 mimetypes = ['text/x-hybris', 'application/x-hybris']
2412
2413 flags = re.MULTILINE | re.DOTALL
2414
2415 tokens = {
2416 'root': [
2417 # method names
2418 (r'^(\s*(?:function|method|operator\s+)+?)'
2419 r'([a-zA-Z_][a-zA-Z0-9_]*)'
2420 r'(\s*)(\()', bygroups(Keyword, Name.Function, Text, Operator)),
2421 (r'[^\S\n]+', Text),
2422 (r'//.*?\n', Comment.Single),
2423 (r'/\*.*?\*/', Comment.Multiline),
2424 (r'@[a-zA-Z_][a-zA-Z0-9_\.]*', Name.Decorator),
2425 (r'(break|case|catch|next|default|do|else|finally|for|foreach|of|'
2426 r'unless|if|new|return|switch|me|throw|try|while)\b', Keyword),
2427 (r'(extends|private|protected|public|static|throws|function|method|'
2428 r'operator)\b', Keyword.Declaration),
2429 (r'(true|false|null|__FILE__|__LINE__|__VERSION__|__LIB_PATH__|'
2430 r'__INC_PATH__)\b', Keyword.Constant),
2431 (r'(class|struct)(\s+)',
2432 bygroups(Keyword.Declaration, Text), 'class'),
2433 (r'(import|include)(\s+)',
2434 bygroups(Keyword.Namespace, Text), 'import'),
2435 (r'(gc_collect|gc_mm_items|gc_mm_usage|gc_collect_threshold|'
2436 r'urlencode|urldecode|base64encode|base64decode|sha1|crc32|sha2|'
2437 r'md5|md5_file|acos|asin|atan|atan2|ceil|cos|cosh|exp|fabs|floor|'
2438 r'fmod|log|log10|pow|sin|sinh|sqrt|tan|tanh|isint|isfloat|ischar|'
2439 r'isstring|isarray|ismap|isalias|typeof|sizeof|toint|tostring|'
2440 r'fromxml|toxml|binary|pack|load|eval|var_names|var_values|'
2441 r'user_functions|dyn_functions|methods|call|call_method|mknod|'
2442 r'mkfifo|mount|umount2|umount|ticks|usleep|sleep|time|strtime|'
2443 r'strdate|dllopen|dlllink|dllcall|dllcall_argv|dllclose|env|exec|'
2444 r'fork|getpid|wait|popen|pclose|exit|kill|pthread_create|'
2445 r'pthread_create_argv|pthread_exit|pthread_join|pthread_kill|'
2446 r'smtp_send|http_get|http_post|http_download|socket|bind|listen|'
2447 r'accept|getsockname|getpeername|settimeout|connect|server|recv|'
2448 r'send|close|print|println|printf|input|readline|serial_open|'
2449 r'serial_fcntl|serial_get_attr|serial_get_ispeed|serial_get_ospeed|'
2450 r'serial_set_attr|serial_set_ispeed|serial_set_ospeed|serial_write|'
2451 r'serial_read|serial_close|xml_load|xml_parse|fopen|fseek|ftell|'
2452 r'fsize|fread|fwrite|fgets|fclose|file|readdir|pcre_replace|size|'
2453 r'pop|unmap|has|keys|values|length|find|substr|replace|split|trim|'
2454 r'remove|contains|join)\b', Name.Builtin),
2455 (r'(MethodReference|Runner|Dll|Thread|Pipe|Process|Runnable|'
2456 r'CGI|ClientSocket|Socket|ServerSocket|File|Console|Directory|'
2457 r'Exception)\b', Keyword.Type),
2458 (r'"(\\\\|\\"|[^"])*"', String),
2459 (r"'\\.'|'[^\\]'|'\\u[0-9a-f]{4}'", String.Char),
2460 (r'(\.)([a-zA-Z_][a-zA-Z0-9_]*)',
2461 bygroups(Operator, Name.Attribute)),
2462 (r'[a-zA-Z_][a-zA-Z0-9_]*:', Name.Label),
2463 (r'[a-zA-Z_\$][a-zA-Z0-9_]*', Name),
2464 (r'[~\^\*!%&\[\]\(\)\{\}<>\|+=:;,./?\-@]+', Operator),
2465 (r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float),
2466 (r'0x[0-9a-f]+', Number.Hex),
2467 (r'[0-9]+L?', Number.Integer),
2468 (r'\n', Text),
2469 ],
2470 'class': [
2471 (r'[a-zA-Z_][a-zA-Z0-9_]*', Name.Class, '#pop')
2472 ],
2473 'import': [
2474 (r'[a-zA-Z0-9_.]+\*?', Name.Namespace, '#pop')
2475 ],
2476 }
2477
2478
2479 class AwkLexer(RegexLexer):
2480 """
2481 For Awk scripts.
2482
2483 *New in Pygments 1.5.*
2484 """
2485
2486 name = 'Awk'
2487 aliases = ['awk', 'gawk', 'mawk', 'nawk']
2488 filenames = ['*.awk']
2489 mimetypes = ['application/x-awk']
2490
2491 tokens = {
2492 'commentsandwhitespace': [
2493 (r'\s+', Text),
2494 (r'#.*$', Comment.Single)
2495 ],
2496 'slashstartsregex': [
2497 include('commentsandwhitespace'),
2498 (r'/(\\.|[^[/\\\n]|\[(\\.|[^\]\\\n])*])+/'
2499 r'\B', String.Regex, '#pop'),
2500 (r'(?=/)', Text, ('#pop', 'badregex')),
2501 (r'', Text, '#pop')
2502 ],
2503 'badregex': [
2504 (r'\n', Text, '#pop')
2505 ],
2506 'root': [
2507 (r'^(?=\s|/)', Text, 'slashstartsregex'),
2508 include('commentsandwhitespace'),
2509 (r'\+\+|--|\|\||&&|in|\$|!?~|'
2510 r'(\*\*|[-<>+*%\^/!=])=?', Operator, 'slashstartsregex'),
2511 (r'[{(\[;,]', Punctuation, 'slashstartsregex'),
2512 (r'[})\].]', Punctuation),
2513 (r'(break|continue|do|while|exit|for|if|'
2514 r'return)\b', Keyword, 'slashstartsregex'),
2515 (r'function\b', Keyword.Declaration, 'slashstartsregex'),
2516 (r'(atan2|cos|exp|int|log|rand|sin|sqrt|srand|gensub|gsub|index|'
2517 r'length|match|split|sprintf|sub|substr|tolower|toupper|close|'
2518 r'fflush|getline|next|nextfile|print|printf|strftime|systime|'
2519 r'delete|system)\b', Keyword.Reserved),
2520 (r'(ARGC|ARGIND|ARGV|CONVFMT|ENVIRON|ERRNO|FIELDWIDTHS|FILENAME|FNR|FS|'
2521 r'IGNORECASE|NF|NR|OFMT|OFS|ORFS|RLENGTH|RS|RSTART|RT|'
2522 r'SUBSEP)\b', Name.Builtin),
2523 (r'[$a-zA-Z_][a-zA-Z0-9_]*', Name.Other),
2524 (r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float),
2525 (r'0x[0-9a-fA-F]+', Number.Hex),
2526 (r'[0-9]+', Number.Integer),
2527 (r'"(\\\\|\\"|[^"])*"', String.Double),
2528 (r"'(\\\\|\\'|[^'])*'", String.Single),
2529 ]
2530 }
2531
2532
2533 class Cfengine3Lexer(RegexLexer):
2534 """
2535 Lexer for `CFEngine3 <http://cfengine.org>`_ policy files.
2536
2537 *New in Pygments 1.5.*
2538 """
2539
2540 name = 'CFEngine3'
2541 aliases = ['cfengine3', 'cf3']
2542 filenames = ['*.cf']
2543 mimetypes = []
2544
2545 tokens = {
2546 'root': [
2547 (r'#.*?\n', Comment),
2548 (r'(body)(\s+)(\S+)(\s+)(control)',
2549 bygroups(Keyword, Text, Keyword, Text, Keyword)),
2550 (r'(body|bundle)(\s+)(\S+)(\s+)(\w+)(\()',
2551 bygroups(Keyword, Text, Keyword, Text, Name.Function, Punctuation),
2552 'arglist'),
2553 (r'(body|bundle)(\s+)(\S+)(\s+)(\w+)',
2554 bygroups(Keyword, Text, Keyword, Text, Name.Function)),
2555 (r'(")([^"]+)(")(\s+)(string|slist|int|real)(\s*)(=>)(\s*)',
2556 bygroups(Punctuation,Name.Variable,Punctuation,
2557 Text,Keyword.Type,Text,Operator,Text)),
2558 (r'(\S+)(\s*)(=>)(\s*)',
2559 bygroups(Keyword.Reserved,Text,Operator,Text)),
2560 (r'"', String, 'string'),
2561 (r'(\w+)(\()', bygroups(Name.Function, Punctuation)),
2562 (r'([\w.!&|\(\)]+)(::)', bygroups(Name.Class, Punctuation)),
2563 (r'(\w+)(:)', bygroups(Keyword.Declaration,Punctuation)),
2564 (r'@[\{\(][^\)\}]+[\}\)]', Name.Variable),
2565 (r'[(){},;]', Punctuation),
2566 (r'=>', Operator),
2567 (r'->', Operator),
2568 (r'\d+\.\d+', Number.Float),
2569 (r'\d+', Number.Integer),
2570 (r'\w+', Name.Function),
2571 (r'\s+', Text),
2572 ],
2573 'string': [
2574 (r'\$[\{\(]', String.Interpol, 'interpol'),
2575 (r'\\.', String.Escape),
2576 (r'"', String, '#pop'),
2577 (r'\n', String),
2578 (r'.', String),
2579 ],
2580 'interpol': [
2581 (r'\$[\{\(]', String.Interpol, '#push'),
2582 (r'[\}\)]', String.Interpol, '#pop'),
2583 (r'[^\$\{\(\)\}]+', String.Interpol),
2584 ],
2585 'arglist': [
2586 (r'\)', Punctuation, '#pop'),
2587 (r',', Punctuation),
2588 (r'\w+', Name.Variable),
2589 (r'\s+', Text),
2590 ],
2591 }
2592
2593
2594 class SnobolLexer(RegexLexer):
2595 """
2596 Lexer for the SNOBOL4 programming language.
2597
2598 Recognizes the common ASCII equivalents of the original SNOBOL4 operators.
2599 Does not require spaces around binary operators.
2600
2601 *New in Pygments 1.5.*
2602 """
2603
2604 name = "Snobol"
2605 aliases = ["snobol"]
2606 filenames = ['*.snobol']
2607 mimetypes = ['text/x-snobol']
2608
2609 tokens = {
2610 # root state, start of line
2611 # comments, continuation lines, and directives start in column 1
2612 # as do labels
2613 'root': [
2614 (r'\*.*\n', Comment),
2615 (r'[\+\.] ', Punctuation, 'statement'),
2616 (r'-.*\n', Comment),
2617 (r'END\s*\n', Name.Label, 'heredoc'),
2618 (r'[A-Za-z\$][\w$]*', Name.Label, 'statement'),
2619 (r'\s+', Text, 'statement'),
2620 ],
2621 # statement state, line after continuation or label
2622 'statement': [
2623 (r'\s*\n', Text, '#pop'),
2624 (r'\s+', Text),
2625 (r'(?<=[^\w.])(LT|LE|EQ|NE|GE|GT|INTEGER|IDENT|DIFFER|LGT|SIZE|'
2626 r'REPLACE|TRIM|DUPL|REMDR|DATE|TIME|EVAL|APPLY|OPSYN|LOAD|UNLOAD|'
2627 r'LEN|SPAN|BREAK|ANY|NOTANY|TAB|RTAB|REM|POS|RPOS|FAIL|FENCE|'
2628 r'ABORT|ARB|ARBNO|BAL|SUCCEED|INPUT|OUTPUT|TERMINAL)(?=[^\w.])',
2629 Name.Builtin),
2630 (r'[A-Za-z][\w\.]*', Name),
2631 # ASCII equivalents of original operators
2632 # | for the EBCDIC equivalent, ! likewise
2633 # \ for EBCDIC negation
2634 (r'\*\*|[\?\$\.!%\*/#+\-@\|&\\=]', Operator),
2635 (r'"[^"]*"', String),
2636 (r"'[^']*'", String),
2637 # Accept SPITBOL syntax for real numbers
2638 # as well as Macro SNOBOL4
2639 (r'[0-9]+(?=[^\.EeDd])', Number.Integer),
2640 (r'[0-9]+(\.[0-9]*)?([EDed][-+]?[0-9]+)?', Number.Float),
2641 # Goto
2642 (r':', Punctuation, 'goto'),
2643 (r'[\(\)<>,;]', Punctuation),
2644 ],
2645 # Goto block
2646 'goto': [
2647 (r'\s*\n', Text, "#pop:2"),
2648 (r'\s+', Text),
2649 (r'F|S', Keyword),
2650 (r'(\()([A-Za-z][\w.]*)(\))',
2651 bygroups(Punctuation, Name.Label, Punctuation))
2652 ],
2653 # everything after the END statement is basically one
2654 # big heredoc.
2655 'heredoc': [
2656 (r'.*\n', String.Heredoc)
2657 ]
2658 }
2659
2660
2661 class UrbiscriptLexer(ExtendedRegexLexer):
2662 """
2663 For UrbiScript source code.
2664
2665 *New in Pygments 1.5.*
2666 """
2667
2668 name = 'UrbiScript'
2669 aliases = ['urbiscript']
2670 filenames = ['*.u']
2671 mimetypes = ['application/x-urbiscript']
2672
2673 flags = re.DOTALL
2674
2675 ## TODO
2676 # - handle Experimental and deprecated tags with specific tokens
2677 # - handle Angles and Durations with specific tokens
2678
2679 def blob_callback(lexer, match, ctx):
2680 text_before_blob = match.group(1)
2681 blob_start = match.group(2)
2682 blob_size_str = match.group(3)
2683 blob_size = int(blob_size_str)
2684 yield match.start(), String, text_before_blob
2685 ctx.pos += len(text_before_blob)
2686
2687 # if blob size doesn't match blob format (example : "\B(2)(aaa)")
2688 # yield blob as a string
2689 if ctx.text[match.end() + blob_size] != ")":
2690 result = "\\B(" + blob_size_str + ")("
2691 yield match.start(), String, result
2692 ctx.pos += len(result)
2693 return
2694
2695 # if blob is well formated, yield as Escape
2696 blob_text = blob_start + ctx.text[match.end():match.end()+blob_size] + ")"
2697 yield match.start(), String.Escape, blob_text
2698 ctx.pos = match.end() + blob_size + 1 # +1 is the ending ")"
2699
2700 tokens = {
2701 'root': [
2702 (r'\s+', Text),
2703 # comments
2704 (r'//.*?\n', Comment),
2705 (r'/\*', Comment.Multiline, 'comment'),
2706 (r'(?:every|for|loop|while)(?:;|&|\||,)',Keyword),
2707 (r'(?:assert|at|break|case|catch|closure|compl|continue|'
2708 r'default|else|enum|every|external|finally|for|freezeif|if|new|'
2709 r'onleave|return|stopif|switch|this|throw|timeout|try|'
2710 r'waituntil|whenever|while)\b', Keyword),
2711 (r'(?:asm|auto|bool|char|const_cast|delete|double|dynamic_cast|'
2712 r'explicit|export|extern|float|friend|goto|inline|int|'
2713 r'long|mutable|namespace|register|reinterpret_cast|short|'
2714 r'signed|sizeof|static_cast|struct|template|typedef|typeid|'
2715 r'typename|union|unsigned|using|virtual|volatile|'
2716 r'wchar_t)\b', Keyword.Reserved),
2717 # deprecated keywords, use a meaningfull token when available
2718 (r'(?:emit|foreach|internal|loopn|static)\b', Keyword),
2719 # ignored keywords, use a meaningfull token when available
2720 (r'(?:private|protected|public)\b', Keyword),
2721 (r'(?:var|do|const|function|class)\b', Keyword.Declaration),
2722 (r'(?:true|false|nil|void)\b', Keyword.Constant),
2723 (r'(?:Barrier|Binary|Boolean|CallMessage|Channel|Code|'
2724 r'Comparable|Container|Control|Date|Dictionary|Directory|'
2725 r'Duration|Enumeration|Event|Exception|Executable|File|Finalizable|'
2726 r'Float|FormatInfo|Formatter|Global|Group|Hash|InputStream|'
2727 r'IoService|Job|Kernel|Lazy|List|Loadable|Lobby|Location|Logger|Math|'
2728 r'Mutex|nil|Object|Orderable|OutputStream|Pair|Path|Pattern|Position|'
2729 r'Primitive|Process|Profile|PseudoLazy|PubSub|RangeIterable|Regexp|'
2730 r'Semaphore|Server|Singleton|Socket|StackFrame|Stream|String|System|'
2731 r'Tag|Timeout|Traceable|TrajectoryGenerator|Triplet|Tuple'
2732 r'|UObject|UValue|UVar)\b', Name.Builtin),
2733 (r'(?:this)\b', Name.Builtin.Pseudo),
2734 # don't match single | and &
2735 (r'(?:[-=+*%/<>~^:]+|\.&?|\|\||&&)', Operator),
2736 (r'(?:and_eq|and|bitand|bitor|in|not|not_eq|or_eq|or|xor_eq|xor)\b',
2737 Operator.Word),
2738 (r'[{}\[\]()]+', Punctuation),
2739 (r'(?:;|\||,|&|\?|!)+', Punctuation),
2740 (r'[$a-zA-Z_][a-zA-Z0-9_]*', Name.Other),
2741 (r'0x[0-9a-fA-F]+', Number.Hex),
2742 # Float, Integer, Angle and Duration
2743 (r'(?:[0-9]+(?:(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?)?'
2744 r'((?:rad|deg|grad)|(?:ms|s|min|h|d))?)\b', Number.Float),
2745 # handle binary blob in strings
2746 (r'"', String.Double, "string.double"),
2747 (r"'", String.Single, "string.single"),
2748 ],
2749 'string.double': [
2750 (r'((?:\\\\|\\"|[^"])*?)(\\B\((\d+)\)\()', blob_callback),
2751 (r'(\\\\|\\"|[^"])*?"', String.Double, '#pop'),
2752 ],
2753 'string.single': [
2754 (r"((?:\\\\|\\'|[^'])*?)(\\B\((\d+)\)\()", blob_callback),
2755 (r"(\\\\|\\'|[^'])*?'", String.Single, '#pop'),
2756 ],
2757 # from http://pygments.org/docs/lexerdevelopment/#changing-states
2758 'comment': [
2759 (r'[^*/]', Comment.Multiline),
2760 (r'/\*', Comment.Multiline, '#push'),
2761 (r'\*/', Comment.Multiline, '#pop'),
2762 (r'[*/]', Comment.Multiline),
2763 ]
2764 }
2765
2766
2767 class OpenEdgeLexer(RegexLexer):
2768 """
2769 Lexer for `OpenEdge ABL (formerly Progress)
2770 <http://web.progress.com/en/openedge/abl.html>`_ source code.
2771
2772 *New in Pygments 1.5.*
2773 """
2774 name = 'OpenEdge ABL'
2775 aliases = ['openedge', 'abl', 'progress']
2776 filenames = ['*.p', '*.cls']
2777 mimetypes = ['text/x-openedge', 'application/x-openedge']
2778
2779 types = (r'(?i)(^|(?<=[^0-9a-z_\-]))(CHARACTER|CHAR|CHARA|CHARAC|CHARACT|CHARACTE|'
2780 r'COM-HANDLE|DATE|DATETIME|DATETIME-TZ|'
2781 r'DECIMAL|DEC|DECI|DECIM|DECIMA|HANDLE|'
2782 r'INT64|INTEGER|INT|INTE|INTEG|INTEGE|'
2783 r'LOGICAL|LONGCHAR|MEMPTR|RAW|RECID|ROWID)\s*($|(?=[^0-9a-z_\-]))')
2784
2785 keywords = (r'(?i)(^|(?<=[^0-9a-z_\-]))(' +
2786 r'|'.join(OPENEDGEKEYWORDS) +
2787 r')\s*($|(?=[^0-9a-z_\-]))')
2788 tokens = {
2789 'root': [
2790 (r'/\*', Comment.Multiline, 'comment'),
2791 (r'\{', Comment.Preproc, 'preprocessor'),
2792 (r'\s*&.*', Comment.Preproc),
2793 (r'0[xX][0-9a-fA-F]+[LlUu]*', Number.Hex),
2794 (r'(?i)(DEFINE|DEF|DEFI|DEFIN)\b', Keyword.Declaration),
2795 (types, Keyword.Type),
2796 (keywords, Name.Builtin),
2797 (r'"(\\\\|\\"|[^"])*"', String.Double),
2798 (r"'(\\\\|\\'|[^'])*'", String.Single),
2799 (r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float),
2800 (r'[0-9]+', Number.Integer),
2801 (r'\s+', Text),
2802 (r'[+*/=-]', Operator),
2803 (r'[.:()]', Punctuation),
2804 (r'.', Name.Variable), # Lazy catch-all
2805 ],
2806 'comment': [
2807 (r'[^*/]', Comment.Multiline),
2808 (r'/\*', Comment.Multiline, '#push'),
2809 (r'\*/', Comment.Multiline, '#pop'),
2810 (r'[*/]', Comment.Multiline)
2811 ],
2812 'preprocessor': [
2813 (r'[^{}]', Comment.Preproc),
2814 (r'{', Comment.Preproc, '#push'),
2815 (r'}', Comment.Preproc, '#pop'),
2816 ],
2817 }
2818
2819
2820 class BroLexer(RegexLexer):
2821 """
2822 For `Bro <http://bro-ids.org/>`_ scripts.
2823
2824 *New in Pygments 1.5.*
2825 """
2826 name = 'Bro'
2827 aliases = ['bro']
2828 filenames = ['*.bro']
2829
2830 _hex = r'[0-9a-fA-F_]+'
2831 _float = r'((\d*\.?\d+)|(\d+\.?\d*))([eE][-+]?\d+)?'
2832 _h = r'[A-Za-z0-9][-A-Za-z0-9]*'
2833
2834 tokens = {
2835 'root': [
2836 # Whitespace
2837 (r'^@.*?\n', Comment.Preproc),
2838 (r'#.*?\n', Comment.Single),
2839 (r'\n', Text),
2840 (r'\s+', Text),
2841 (r'\\\n', Text),
2842 # Keywords
2843 (r'(add|alarm|break|case|const|continue|delete|do|else|enum|event'
2844 r'|export|for|function|if|global|local|module|next'
2845 r'|of|print|redef|return|schedule|type|when|while)\b', Keyword),
2846 (r'(addr|any|bool|count|counter|double|file|int|interval|net'
2847 r'|pattern|port|record|set|string|subnet|table|time|timer'
2848 r'|vector)\b', Keyword.Type),
2849 (r'(T|F)\b', Keyword.Constant),
2850 (r'(&)((?:add|delete|expire)_func|attr|(?:create|read|write)_expire'
2851 r'|default|disable_print_hook|raw_output|encrypt|group|log'
2852 r'|mergeable|optional|persistent|priority|redef'
2853 r'|rotate_(?:interval|size)|synchronized)\b', bygroups(Punctuation,
2854 Keyword)),
2855 (r'\s+module\b', Keyword.Namespace),
2856 # Addresses, ports and networks
2857 (r'\d+/(tcp|udp|icmp|unknown)\b', Number),
2858 (r'(\d+\.){3}\d+', Number),
2859 (r'(' + _hex + r'){7}' + _hex, Number),
2860 (r'0x' + _hex + r'(' + _hex + r'|:)*::(' + _hex + r'|:)*', Number),
2861 (r'((\d+|:)(' + _hex + r'|:)*)?::(' + _hex + r'|:)*', Number),
2862 (r'(\d+\.\d+\.|(\d+\.){2}\d+)', Number),
2863 # Hostnames
2864 (_h + r'(\.' + _h + r')+', String),
2865 # Numeric
2866 (_float + r'\s+(day|hr|min|sec|msec|usec)s?\b', Literal.Date),
2867 (r'0[xX]' + _hex, Number.Hex),
2868 (_float, Number.Float),
2869 (r'\d+', Number.Integer),
2870 (r'/', String.Regex, 'regex'),
2871 (r'"', String, 'string'),
2872 # Operators
2873 (r'[!%*/+:<=>?~|-]', Operator),
2874 (r'([-+=&|]{2}|[+=!><-]=)', Operator),
2875 (r'(in|match)\b', Operator.Word),
2876 (r'[{}()\[\]$.,;]', Punctuation),
2877 # Identfier
2878 (r'([_a-zA-Z]\w*)(::)', bygroups(Name, Name.Namespace)),
2879 (r'[a-zA-Z_][a-zA-Z_0-9]*', Name)
2880 ],
2881 'string': [
2882 (r'"', String, '#pop'),
2883 (r'\\([\\abfnrtv"\']|x[a-fA-F0-9]{2,4}|[0-7]{1,3})', String.Escape),
2884 (r'[^\\"\n]+', String),
2885 (r'\\\n', String),
2886 (r'\\', String)
2887 ],
2888 'regex': [
2889 (r'/', String.Regex, '#pop'),
2890 (r'\\[\\nt/]', String.Regex), # String.Escape is too intense here.
2891 (r'[^\\/\n]+', String.Regex),
2892 (r'\\\n', String.Regex),
2893 (r'\\', String.Regex)
2894 ]
2895 }
2896
2897
2898 class CbmBasicV2Lexer(RegexLexer):
2899 """
2900 For CBM BASIC V2 sources.
2901
2902 *New in Pygments 1.6.*
2903 """
2904 name = 'CBM BASIC V2'
2905 aliases = ['cbmbas']
2906 filenames = ['*.bas']
2907
2908 flags = re.IGNORECASE
2909
2910 tokens = {
2911 'root': [
2912 (r'rem.*\n', Comment.Single),
2913 (r'\s+', Text),
2914 (r'new|run|end|for|to|next|step|go(to|sub)?|on|return|stop|cont'
2915 r'|if|then|input#?|read|wait|load|save|verify|poke|sys|print#?'
2916 r'|list|clr|cmd|open|close|get#?', Keyword.Reserved),
2917 (r'data|restore|dim|let|def|fn', Keyword.Declaration),
2918 (r'tab|spc|sgn|int|abs|usr|fre|pos|sqr|rnd|log|exp|cos|sin|tan|atn'
2919 r'|peek|len|val|asc|(str|chr|left|right|mid)\$', Name.Builtin),
2920 (r'[-+*/^<>=]', Operator),
2921 (r'not|and|or', Operator.Word),
2922 (r'"[^"\n]*.', String),
2923 (r'\d+|[-+]?\d*\.\d*(e[-+]?\d+)?', Number.Float),
2924 (r'[\(\),:;]', Punctuation),
2925 (r'\w+[$%]?', Name),
2926 ]
2927 }
2928
2929 def analyse_text(self, text):
2930 # if it starts with a line number, it shouldn't be a "modern" Basic
2931 # like VB.net
2932 if re.match(r'\d+', text):
2933 return True
2934
2935
2936 class MscgenLexer(RegexLexer):
2937 """
2938 For `Mscgen <http://www.mcternan.me.uk/mscgen/>`_ files.
2939
2940 *New in Pygments 1.6.*
2941 """
2942 name = 'Mscgen'
2943 aliases = ['mscgen', 'msc']
2944 filenames = ['*.msc']
2945
2946 _var = r'([a-zA-Z0-9_]+|"(?:\\"|[^"])*")'
2947
2948 tokens = {
2949 'root': [
2950 (r'msc\b', Keyword.Type),
2951 # Options
2952 (r'(hscale|HSCALE|width|WIDTH|wordwraparcs|WORDWRAPARCS'
2953 r'|arcgradient|ARCGRADIENT)\b', Name.Property),
2954 # Operators
2955 (r'(abox|ABOX|rbox|RBOX|box|BOX|note|NOTE)\b', Operator.Word),
2956 (r'(\.|-|\|){3}', Keyword),
2957 (r'(?:-|=|\.|:){2}'
2958 r'|<<=>>|<->|<=>|<<>>|<:>'
2959 r'|->|=>>|>>|=>|:>|-x|-X'
2960 r'|<-|<<=|<<|<=|<:|x-|X-|=', Operator),
2961 # Names
2962 (r'\*', Name.Builtin),
2963 (_var, Name.Variable),
2964 # Other
2965 (r'\[', Punctuation, 'attrs'),
2966 (r'\{|\}|,|;', Punctuation),
2967 include('comments')
2968 ],
2969 'attrs': [
2970 (r'\]', Punctuation, '#pop'),
2971 (_var + r'(\s*)(=)(\s*)' + _var,
2972 bygroups(Name.Attribute, Text.Whitespace, Operator, Text.Whitespace,
2973 String)),
2974 (r',', Punctuation),
2975 include('comments')
2976 ],
2977 'comments': [
2978 (r'(?://|#).*?\n', Comment.Single),
2979 (r'/\*(?:.|\n)*?\*/', Comment.Multiline),
2980 (r'[ \t\r\n]+', Text.Whitespace)
2981 ]
2982 }
2983
2984
2985 def _rx_indent(level):
2986 # Kconfig *always* interprets a tab as 8 spaces, so this is the default.
2987 # Edit this if you are in an environment where KconfigLexer gets expanded
2988 # input (tabs expanded to spaces) and the expansion tab width is != 8,
2989 # e.g. in connection with Trac (trac.ini, [mimeviewer], tab_width).
2990 # Value range here is 2 <= {tab_width} <= 8.
2991 tab_width = 8
2992 # Regex matching a given indentation {level}, assuming that indentation is
2993 # a multiple of {tab_width}. In other cases there might be problems.
2994 return r'(?:\t| {1,%s}\t| {%s}){%s}.*\n' % (tab_width-1, tab_width, level)
2995
2996
2997 class KconfigLexer(RegexLexer):
2998 """
2999 For Linux-style Kconfig files.
3000
3001 *New in Pygments 1.6.*
3002 """
3003
3004 name = 'Kconfig'
3005 aliases = ['kconfig', 'menuconfig', 'linux-config', 'kernel-config']
3006 # Adjust this if new kconfig file names appear in your environment
3007 filenames = ['Kconfig', '*Config.in*', 'external.in*',
3008 'standard-modules.in']
3009 mimetypes = ['text/x-kconfig']
3010 # No re.MULTILINE, indentation-aware help text needs line-by-line handling
3011 flags = 0
3012
3013 def call_indent(level):
3014 # If indentation >= {level} is detected, enter state 'indent{level}'
3015 return (_rx_indent(level), String.Doc, 'indent%s' % level)
3016
3017 def do_indent(level):
3018 # Print paragraphs of indentation level >= {level} as String.Doc,
3019 # ignoring blank lines. Then return to 'root' state.
3020 return [
3021 (_rx_indent(level), String.Doc),
3022 (r'\s*\n', Text),
3023 (r'', Generic, '#pop:2')
3024 ]
3025
3026 tokens = {
3027 'root': [
3028 (r'\s+', Text),
3029 (r'#.*?\n', Comment.Single),
3030 (r'(mainmenu|config|menuconfig|choice|endchoice|comment|menu|'
3031 r'endmenu|visible if|if|endif|source|prompt|select|depends on|'
3032 r'default|range|option)\b', Keyword),
3033 (r'(---help---|help)[\t ]*\n', Keyword, 'help'),
3034 (r'(bool|tristate|string|hex|int|defconfig_list|modules|env)\b',
3035 Name.Builtin),
3036 (r'[!=&|]', Operator),
3037 (r'[()]', Punctuation),
3038 (r'[0-9]+', Number.Integer),
3039 (r"'(''|[^'])*'", String.Single),
3040 (r'"(""|[^"])*"', String.Double),
3041 (r'\S+', Text),
3042 ],
3043 # Help text is indented, multi-line and ends when a lower indentation
3044 # level is detected.
3045 'help': [
3046 # Skip blank lines after help token, if any
3047 (r'\s*\n', Text),
3048 # Determine the first help line's indentation level heuristically(!).
3049 # Attention: this is not perfect, but works for 99% of "normal"
3050 # indentation schemes up to a max. indentation level of 7.
3051 call_indent(7),
3052 call_indent(6),
3053 call_indent(5),
3054 call_indent(4),
3055 call_indent(3),
3056 call_indent(2),
3057 call_indent(1),
3058 ('', Text, '#pop'), # for incomplete help sections without text
3059 ],
3060 # Handle text for indentation levels 7 to 1
3061 'indent7': do_indent(7),
3062 'indent6': do_indent(6),
3063 'indent5': do_indent(5),
3064 'indent4': do_indent(4),
3065 'indent3': do_indent(3),
3066 'indent2': do_indent(2),
3067 'indent1': do_indent(1),
3068 }
3069
3070
3071 class VGLLexer(RegexLexer):
3072 """
3073 For `SampleManager VGL <http://www.thermoscientific.com/samplemanager>`_
3074 source code.
3075
3076 *New in Pygments 1.6.*
3077 """
3078 name = 'VGL'
3079 aliases = ['vgl']
3080 filenames = ['*.rpf']
3081
3082 flags = re.MULTILINE | re.DOTALL | re.IGNORECASE
3083
3084 tokens = {
3085 'root': [
3086 (r'\{[^\}]*\}', Comment.Multiline),
3087 (r'declare', Keyword.Constant),
3088 (r'(if|then|else|endif|while|do|endwhile|and|or|prompt|object'
3089 r'|create|on|line|with|global|routine|value|endroutine|constant'
3090 r'|global|set|join|library|compile_option|file|exists|create|copy'
3091 r'|delete|enable|windows|name|notprotected)(?! *[=<>.,()])',
3092 Keyword),
3093 (r'(true|false|null|empty|error|locked)', Keyword.Constant),
3094 (r'[~\^\*\#!%&\[\]\(\)<>\|+=:;,./?-]', Operator),
3095 (r'"[^"]*"', String),
3096 (r'(\.)([a-z_\$][a-z0-9_\$]*)', bygroups(Operator, Name.Attribute)),
3097 (r'[0-9][0-9]*(\.[0-9]+(e[+\-]?[0-9]+)?)?', Number),
3098 (r'[a-z_\$][a-z0-9_\$]*', Name),
3099 (r'[\r\n]+', Text),
3100 (r'\s+', Text)
3101 ]
3102 }
3103
3104
3105 class SourcePawnLexer(RegexLexer):
3106 """
3107 For SourcePawn source code with preprocessor directives.
3108
3109 *New in Pygments 1.6.*
3110 """
3111 name = 'SourcePawn'
3112 aliases = ['sp']
3113 filenames = ['*.sp']
3114 mimetypes = ['text/x-sourcepawn']
3115
3116 #: optional Comment or Whitespace
3117 _ws = r'(?:\s|//.*?\n|/\*.*?\*/)+'
3118
3119 tokens = {
3120 'root': [
3121 # preprocessor directives: without whitespace
3122 ('^#if\s+0', Comment.Preproc, 'if0'),
3123 ('^#', Comment.Preproc, 'macro'),
3124 # or with whitespace
3125 ('^' + _ws + r'#if\s+0', Comment.Preproc, 'if0'),
3126 ('^' + _ws + '#', Comment.Preproc, 'macro'),
3127 (r'\n', Text),
3128 (r'\s+', Text),
3129 (r'\\\n', Text), # line continuation
3130 (r'/(\\\n)?/(\n|(.|\n)*?[^\\]\n)', Comment.Single),
3131 (r'/(\\\n)?\*(.|\n)*?\*(\\\n)?/', Comment.Multiline),
3132 (r'[{}]', Punctuation),
3133 (r'L?"', String, 'string'),
3134 (r"L?'(\\.|\\[0-7]{1,3}|\\x[a-fA-F0-9]{1,2}|[^\\\'\n])'", String.Char),
3135 (r'(\d+\.\d*|\.\d+|\d+)[eE][+-]?\d+[LlUu]*', Number.Float),
3136 (r'(\d+\.\d*|\.\d+|\d+[fF])[fF]?', Number.Float),
3137 (r'0x[0-9a-fA-F]+[LlUu]*', Number.Hex),
3138 (r'0[0-7]+[LlUu]*', Number.Oct),
3139 (r'\d+[LlUu]*', Number.Integer),
3140 (r'\*/', Error),
3141 (r'[~!%^&*+=|?:<>/-]', Operator),
3142 (r'[()\[\],.;]', Punctuation),
3143 (r'(case|const|continue|native|'
3144 r'default|else|enum|for|if|new|operator|'
3145 r'public|return|sizeof|static|decl|struct|switch)\b', Keyword),
3146 (r'(bool|Float)\b', Keyword.Type),
3147 (r'(true|false)\b', Keyword.Constant),
3148 ('[a-zA-Z_][a-zA-Z0-9_]*', Name),
3149 ],
3150 'string': [
3151 (r'"', String, '#pop'),
3152 (r'\\([\\abfnrtv"\']|x[a-fA-F0-9]{2,4}|[0-7]{1,3})', String.Escape),
3153 (r'[^\\"\n]+', String), # all other characters
3154 (r'\\\n', String), # line continuation
3155 (r'\\', String), # stray backslash
3156 ],
3157 'macro': [
3158 (r'[^/\n]+', Comment.Preproc),
3159 (r'/\*(.|\n)*?\*/', Comment.Multiline),
3160 (r'//.*?\n', Comment.Single, '#pop'),
3161 (r'/', Comment.Preproc),
3162 (r'(?<=\\)\n', Comment.Preproc),
3163 (r'\n', Comment.Preproc, '#pop'),
3164 ],
3165 'if0': [
3166 (r'^\s*#if.*?(?<!\\)\n', Comment.Preproc, '#push'),
3167 (r'^\s*#endif.*?(?<!\\)\n', Comment.Preproc, '#pop'),
3168 (r'.*?\n', Comment),
3169 ]
3170 }
3171
3172 SM_TYPES = ['Action', 'bool', 'Float', 'Plugin', 'String', 'any',
3173 'AdminFlag', 'OverrideType', 'OverrideRule', 'ImmunityType',
3174 'GroupId', 'AdminId', 'AdmAccessMode', 'AdminCachePart',
3175 'CookieAccess', 'CookieMenu', 'CookieMenuAction', 'NetFlow',
3176 'ConVarBounds', 'QueryCookie', 'ReplySource',
3177 'ConVarQueryResult', 'ConVarQueryFinished', 'Function',
3178 'Action', 'Identity', 'PluginStatus', 'PluginInfo', 'DBResult',
3179 'DBBindType', 'DBPriority', 'PropType', 'PropFieldType',
3180 'MoveType', 'RenderMode', 'RenderFx', 'EventHookMode',
3181 'EventHook', 'FileType', 'FileTimeMode', 'PathType',
3182 'ParamType', 'ExecType', 'DialogType', 'Handle', 'KvDataTypes',
3183 'NominateResult', 'MapChange', 'MenuStyle', 'MenuAction',
3184 'MenuSource', 'RegexError', 'SDKCallType', 'SDKLibrary',
3185 'SDKFuncConfSource', 'SDKType', 'SDKPassMethod', 'RayType',
3186 'TraceEntityFilter', 'ListenOverride', 'SortOrder', 'SortType',
3187 'SortFunc2D', 'APLRes', 'FeatureType', 'FeatureStatus',
3188 'SMCResult', 'SMCError', 'TFClassType', 'TFTeam', 'TFCond',
3189 'TFResourceType', 'Timer', 'TopMenuAction', 'TopMenuObjectType',
3190 'TopMenuPosition', 'TopMenuObject', 'UserMsg']
3191
3192 def __init__(self, **options):
3193 self.smhighlighting = get_bool_opt(options,
3194 'sourcemod', True)
3195
3196 self._functions = []
3197 if self.smhighlighting:
3198 from pygments.lexers._sourcemodbuiltins import FUNCTIONS
3199 self._functions.extend(FUNCTIONS)
3200 RegexLexer.__init__(self, **options)
3201
3202 def get_tokens_unprocessed(self, text):
3203 for index, token, value in \
3204 RegexLexer.get_tokens_unprocessed(self, text):
3205 if token is Name:
3206 if self.smhighlighting:
3207 if value in self.SM_TYPES:
3208 token = Keyword.Type
3209 elif value in self._functions:
3210 token = Name.Builtin
3211 yield index, token, value
3212
3213
3214 class PuppetLexer(RegexLexer):
3215 """
3216 For `Puppet <http://puppetlabs.com/>`__ configuration DSL.
3217
3218 *New in Pygments 1.6.*
3219 """
3220 name = 'Puppet'
3221 aliases = ['puppet']
3222 filenames = ['*.pp']
3223
3224 tokens = {
3225 'root': [
3226 include('comments'),
3227 include('keywords'),
3228 include('names'),
3229 include('numbers'),
3230 include('operators'),
3231 include('strings'),
3232
3233 (r'[]{}:(),;[]', Punctuation),
3234 (r'[^\S\n]+', Text),
3235 ],
3236
3237 'comments': [
3238 (r'\s*#.*$', Comment),
3239 (r'/(\\\n)?[*](.|\n)*?[*](\\\n)?/', Comment.Multiline),
3240 ],
3241
3242 'operators': [
3243 (r'(=>|\?|<|>|=|\+|-|/|\*|~|!|\|)', Operator),
3244 (r'(in|and|or|not)\b', Operator.Word),
3245 ],
3246
3247 'names': [
3248 ('[a-zA-Z_][a-zA-Z0-9_]*', Name.Attribute),
3249 (r'(\$\S+)(\[)(\S+)(\])', bygroups(Name.Variable, Punctuation,
3250 String, Punctuation)),
3251 (r'\$\S+', Name.Variable),
3252 ],
3253
3254 'numbers': [
3255 # Copypasta from the Python lexer
3256 (r'(\d+\.\d*|\d*\.\d+)([eE][+-]?[0-9]+)?j?', Number.Float),
3257 (r'\d+[eE][+-]?[0-9]+j?', Number.Float),
3258 (r'0[0-7]+j?', Number.Oct),
3259 (r'0[xX][a-fA-F0-9]+', Number.Hex),
3260 (r'\d+L', Number.Integer.Long),
3261 (r'\d+j?', Number.Integer)
3262 ],
3263
3264 'keywords': [
3265 # Left out 'group' and 'require'
3266 # Since they're often used as attributes
3267 (r'(?i)(absent|alert|alias|audit|augeas|before|case|check|class|'
3268 r'computer|configured|contained|create_resources|crit|cron|debug|'
3269 r'default|define|defined|directory|else|elsif|emerg|err|exec|'
3270 r'extlookup|fail|false|file|filebucket|fqdn_rand|generate|host|if|'
3271 r'import|include|info|inherits|inline_template|installed|'
3272 r'interface|k5login|latest|link|loglevel|macauthorization|'
3273 r'mailalias|maillist|mcx|md5|mount|mounted|nagios_command|'
3274 r'nagios_contact|nagios_contactgroup|nagios_host|'
3275 r'nagios_hostdependency|nagios_hostescalation|nagios_hostextinfo|'
3276 r'nagios_hostgroup|nagios_service|nagios_servicedependency|'
3277 r'nagios_serviceescalation|nagios_serviceextinfo|'
3278 r'nagios_servicegroup|nagios_timeperiod|node|noop|notice|notify|'
3279 r'package|present|purged|realize|regsubst|resources|role|router|'
3280 r'running|schedule|scheduled_task|search|selboolean|selmodule|'
3281 r'service|sha1|shellquote|split|sprintf|ssh_authorized_key|sshkey|'
3282 r'stage|stopped|subscribe|tag|tagged|template|tidy|true|undef|'
3283 r'unmounted|user|versioncmp|vlan|warning|yumrepo|zfs|zone|'
3284 r'zpool)\b', Keyword),
3285 ],
3286
3287 'strings': [
3288 (r'"([^"])*"', String),
3289 (r'\'([^\'])*\'', String),
3290 ],
3291
3292 }
3293
3294
3295 class NSISLexer(RegexLexer):
3296 """
3297 For `NSIS <http://nsis.sourceforge.net/>`_ scripts.
3298
3299 *New in Pygments 1.6.*
3300 """
3301 name = 'NSIS'
3302 aliases = ['nsis', 'nsi', 'nsh']
3303 filenames = ['*.nsi', '*.nsh']
3304 mimetypes = ['text/x-nsis']
3305
3306 flags = re.IGNORECASE
3307
3308 tokens = {
3309 'root': [
3310 (r'[;\#].*\n', Comment),
3311 (r"'.*'", String.Single),
3312 (r'"', String.Double, 'str_double'),
3313 (r'`', String.Backtick, 'str_backtick'),
3314 include('macro'),
3315 include('interpol'),
3316 include('basic'),
3317 (r'\$\{[a-z_|][\w|]*\}', Keyword.Pseudo),
3318 (r'/[a-z_]\w*', Name.Attribute),
3319 ('.', Text),
3320 ],
3321 'basic': [
3322 (r'(\n)(Function)(\s+)([._a-z][.\w]*)\b',
3323 bygroups(Text, Keyword, Text, Name.Function)),
3324 (r'\b([_a-z]\w*)(::)([a-z][a-z0-9]*)\b',
3325 bygroups(Keyword.Namespace, Punctuation, Name.Function)),
3326 (r'\b([_a-z]\w*)(:)', bygroups(Name.Label, Punctuation)),
3327 (r'(\b[ULS]|\B)([\!\<\>=]?=|\<\>?|\>)\B', Operator),
3328 (r'[|+-]', Operator),
3329 (r'\\', Punctuation),
3330 (r'\b(Abort|Add(?:BrandingImage|Size)|'
3331 r'Allow(?:RootDirInstall|SkipFiles)|AutoCloseWindow|'
3332 r'BG(?:Font|Gradient)|BrandingText|BringToFront|Call(?:InstDLL)?|'
3333 r'(?:Sub)?Caption|ChangeUI|CheckBitmap|ClearErrors|CompletedText|'
3334 r'ComponentText|CopyFiles|CRCCheck|'
3335 r'Create(?:Directory|Font|Shortcut)|Delete(?:INI(?:Sec|Str)|'
3336 r'Reg(?:Key|Value))?|DetailPrint|DetailsButtonText|'
3337 r'Dir(?:Show|Text|Var|Verify)|(?:Disabled|Enabled)Bitmap|'
3338 r'EnableWindow|EnumReg(?:Key|Value)|Exch|Exec(?:Shell|Wait)?|'
3339 r'ExpandEnvStrings|File(?:BufSize|Close|ErrorText|Open|'
3340 r'Read(?:Byte)?|Seek|Write(?:Byte)?)?|'
3341 r'Find(?:Close|First|Next|Window)|FlushINI|Function(?:End)?|'
3342 r'Get(?:CurInstType|CurrentAddress|DlgItem|DLLVersion(?:Local)?|'
3343 r'ErrorLevel|FileTime(?:Local)?|FullPathName|FunctionAddress|'
3344 r'InstDirError|LabelAddress|TempFileName)|'
3345 r'Goto|HideWindow|Icon|'
3346 r'If(?:Abort|Errors|FileExists|RebootFlag|Silent)|'
3347 r'InitPluginsDir|Install(?:ButtonText|Colors|Dir(?:RegKey)?)|'
3348 r'Inst(?:ProgressFlags|Type(?:[GS]etText)?)|Int(?:CmpU?|Fmt|Op)|'
3349 r'IsWindow|LangString(?:UP)?|'
3350 r'License(?:BkColor|Data|ForceSelection|LangString|Text)|'
3351 r'LoadLanguageFile|LockWindow|Log(?:Set|Text)|MessageBox|'
3352 r'MiscButtonText|Name|Nop|OutFile|(?:Uninst)?Page(?:Ex(?:End)?)?|'
3353 r'PluginDir|Pop|Push|Quit|Read(?:(?:Env|INI|Reg)Str|RegDWORD)|'
3354 r'Reboot|(?:Un)?RegDLL|Rename|RequestExecutionLevel|ReserveFile|'
3355 r'Return|RMDir|SearchPath|Section(?:Divider|End|'
3356 r'(?:(?:Get|Set)(?:Flags|InstTypes|Size|Text))|Group(?:End)?|In)?|'
3357 r'SendMessage|Set(?:AutoClose|BrandingImage|Compress(?:ionLevel|'
3358 r'or(?:DictSize)?)?|CtlColors|CurInstType|DatablockOptimize|'
3359 r'DateSave|Details(?:Print|View)|Error(?:s|Level)|FileAttributes|'
3360 r'Font|OutPath|Overwrite|PluginUnload|RebootFlag|ShellVarContext|'
3361 r'Silent|StaticBkColor)|'
3362 r'Show(?:(?:I|Uni)nstDetails|Window)|Silent(?:Un)?Install|Sleep|'
3363 r'SpaceTexts|Str(?:CmpS?|Cpy|Len)|SubSection(?:End)?|'
3364 r'Uninstall(?:ButtonText|(?:Sub)?Caption|EXEName|Icon|Text)|'
3365 r'UninstPage|Var|VI(?:AddVersionKey|ProductVersion)|WindowIcon|'
3366 r'Write(?:INIStr|Reg(:?Bin|DWORD|(?:Expand)?Str)|Uninstaller)|'
3367 r'XPStyle)\b', Keyword),
3368 (r'\b(CUR|END|(?:FILE_ATTRIBUTE_)?'
3369 r'(?:ARCHIVE|HIDDEN|NORMAL|OFFLINE|READONLY|SYSTEM|TEMPORARY)|'
3370 r'HK(CC|CR|CU|DD|LM|PD|U)|'
3371 r'HKEY_(?:CLASSES_ROOT|CURRENT_(?:CONFIG|USER)|DYN_DATA|'
3372 r'LOCAL_MACHINE|PERFORMANCE_DATA|USERS)|'
3373 r'ID(?:ABORT|CANCEL|IGNORE|NO|OK|RETRY|YES)|'
3374 r'MB_(?:ABORTRETRYIGNORE|DEFBUTTON[1-4]|'
3375 r'ICON(?:EXCLAMATION|INFORMATION|QUESTION|STOP)|'
3376 r'OK(?:CANCEL)?|RETRYCANCEL|RIGHT|SETFOREGROUND|TOPMOST|USERICON|'
3377 r'YESNO(?:CANCEL)?)|SET|SHCTX|'
3378 r'SW_(?:HIDE|SHOW(?:MAXIMIZED|MINIMIZED|NORMAL))|'
3379 r'admin|all|auto|both|bottom|bzip2|checkbox|colored|current|false|'
3380 r'force|hide|highest|if(?:diff|newer)|lastused|leave|left|'
3381 r'listonly|lzma|nevershow|none|normal|off|on|pop|push|'
3382 r'radiobuttons|right|show|silent|silentlog|smooth|textonly|top|'
3383 r'true|try|user|zlib)\b', Name.Constant),
3384 ],
3385 'macro': [
3386 (r'\!(addincludedir(?:dir)?|addplugindir|appendfile|cd|define|'
3387 r'delfilefile|echo(?:message)?|else|endif|error|execute|'
3388 r'if(?:macro)?n?(?:def)?|include|insertmacro|macro(?:end)?|packhdr|'
3389 r'search(?:parse|replace)|system|tempfilesymbol|undef|verbose|'
3390 r'warning)\b', Comment.Preproc),
3391 ],
3392 'interpol': [
3393 (r'\$(R?[0-9])', Name.Builtin.Pseudo), # registers
3394 (r'\$(ADMINTOOLS|APPDATA|CDBURN_AREA|COOKIES|COMMONFILES(?:32|64)|'
3395 r'DESKTOP|DOCUMENTS|EXE(?:DIR|FILE|PATH)|FAVORITES|FONTS|HISTORY|'
3396 r'HWNDPARENT|INTERNET_CACHE|LOCALAPPDATA|MUSIC|NETHOOD|PICTURES|'
3397 r'PLUGINSDIR|PRINTHOOD|PROFILE|PROGRAMFILES(?:32|64)|QUICKLAUNCH|'
3398 r'RECENT|RESOURCES(?:_LOCALIZED)?|SENDTO|SM(?:PROGRAMS|STARTUP)|'
3399 r'STARTMENU|SYSDIR|TEMP(?:LATES)?|VIDEOS|WINDIR|\{NSISDIR\})',
3400 Name.Builtin),
3401 (r'\$(CMDLINE|INSTDIR|OUTDIR|LANGUAGE)', Name.Variable.Global),
3402 (r'\$[a-z_]\w*', Name.Variable),
3403 ],
3404 'str_double': [
3405 (r'"', String, '#pop'),
3406 (r'\$(\\[nrt"]|\$)', String.Escape),
3407 include('interpol'),
3408 (r'.', String.Double),
3409 ],
3410 'str_backtick': [
3411 (r'`', String, '#pop'),
3412 (r'\$(\\[nrt"]|\$)', String.Escape),
3413 include('interpol'),
3414 (r'.', String.Double),
3415 ],
3416 }
3417
3418
3419 class RPMSpecLexer(RegexLexer):
3420 """
3421 For RPM *.spec files
3422
3423 *New in Pygments 1.6.*
3424 """
3425
3426 name = 'RPMSpec'
3427 aliases = ['spec']
3428 filenames = ['*.spec']
3429 mimetypes = ['text/x-rpm-spec']
3430
3431 _directives = ('(?:package|prep|build|install|clean|check|pre[a-z]*|'
3432 'post[a-z]*|trigger[a-z]*|files)')
3433
3434 tokens = {
3435 'root': [
3436 (r'#.*\n', Comment),
3437 include('basic'),
3438 ],
3439 'description': [
3440 (r'^(%' + _directives + ')(.*)$',
3441 bygroups(Name.Decorator, Text), '#pop'),
3442 (r'\n', Text),
3443 (r'.', Text),
3444 ],
3445 'changelog': [
3446 (r'\*.*\n', Generic.Subheading),
3447 (r'^(%' + _directives + ')(.*)$',
3448 bygroups(Name.Decorator, Text), '#pop'),
3449 (r'\n', Text),
3450 (r'.', Text),
3451 ],
3452 'string': [
3453 (r'"', String.Double, '#pop'),
3454 (r'\\([\\abfnrtv"\']|x[a-fA-F0-9]{2,4}|[0-7]{1,3})', String.Escape),
3455 include('interpol'),
3456 (r'.', String.Double),
3457 ],
3458 'basic': [
3459 include('macro'),
3460 (r'(?i)^(Name|Version|Release|Epoch|Summary|Group|License|Packager|'
3461 r'Vendor|Icon|URL|Distribution|Prefix|Patch[0-9]*|Source[0-9]*|'
3462 r'Requires\(?[a-z]*\)?|[a-z]+Req|Obsoletes|Provides|Conflicts|'
3463 r'Build[a-z]+|[a-z]+Arch|Auto[a-z]+)(:)(.*)$',
3464 bygroups(Generic.Heading, Punctuation, using(this))),
3465 (r'^%description', Name.Decorator, 'description'),
3466 (r'^%changelog', Name.Decorator, 'changelog'),
3467 (r'^(%' + _directives + ')(.*)$', bygroups(Name.Decorator, Text)),
3468 (r'%(attr|defattr|dir|doc(?:dir)?|setup|config(?:ure)?|'
3469 r'make(?:install)|ghost|patch[0-9]+|find_lang|exclude|verify)',
3470 Keyword),
3471 include('interpol'),
3472 (r"'.*'", String.Single),
3473 (r'"', String.Double, 'string'),
3474 (r'.', Text),
3475 ],
3476 'macro': [
3477 (r'%define.*\n', Comment.Preproc),
3478 (r'%\{\!\?.*%define.*\}', Comment.Preproc),
3479 (r'(%(?:if(?:n?arch)?|else(?:if)?|endif))(.*)$',
3480 bygroups(Comment.Preproc, Text)),
3481 ],
3482 'interpol': [
3483 (r'%\{?__[a-z_]+\}?', Name.Function),
3484 (r'%\{?_([a-z_]+dir|[a-z_]+path|prefix)\}?', Keyword.Pseudo),
3485 (r'%\{\?[A-Za-z0-9_]+\}', Name.Variable),
3486 (r'\$\{?RPM_[A-Z0-9_]+\}?', Name.Variable.Global),
3487 (r'%\{[a-zA-Z][a-zA-Z0-9_]+\}', Keyword.Constant),
3488 ]
3489 }
3490
3491
3492 class AutoItLexer(RegexLexer):
3493 """
3494 For `AutoIt <http://www.autoitscript.com/site/autoit/>`_ files.
3495
3496 AutoIt is a freeware BASIC-like scripting language
3497 designed for automating the Windows GUI and general scripting
3498
3499 *New in Pygments 1.6.*
3500 """
3501 name = 'AutoIt'
3502 aliases = ['autoit', 'Autoit']
3503 filenames = ['*.au3']
3504 mimetypes = ['text/x-autoit']
3505
3506 # Keywords, functions, macros from au3.keywords.properties
3507 # which can be found in AutoIt installed directory, e.g.
3508 # c:\Program Files (x86)\AutoIt3\SciTE\au3.keywords.properties
3509
3510 keywords = """\
3511 #include-once #include #endregion #forcedef #forceref #region
3512 and byref case continueloop dim do else elseif endfunc endif
3513 endselect exit exitloop for func global
3514 if local next not or return select step
3515 then to until wend while exit""".split()
3516
3517 functions = """\
3518 abs acos adlibregister adlibunregister asc ascw asin assign atan
3519 autoitsetoption autoitwingettitle autoitwinsettitle beep binary binarylen
3520 binarymid binarytostring bitand bitnot bitor bitrotate bitshift bitxor
3521 blockinput break call cdtray ceiling chr chrw clipget clipput consoleread
3522 consolewrite consolewriteerror controlclick controlcommand controldisable
3523 controlenable controlfocus controlgetfocus controlgethandle controlgetpos
3524 controlgettext controlhide controllistview controlmove controlsend
3525 controlsettext controlshow controltreeview cos dec dircopy dircreate
3526 dirgetsize dirmove dirremove dllcall dllcalladdress dllcallbackfree
3527 dllcallbackgetptr dllcallbackregister dllclose dllopen dllstructcreate
3528 dllstructgetdata dllstructgetptr dllstructgetsize dllstructsetdata
3529 drivegetdrive drivegetfilesystem drivegetlabel drivegetserial drivegettype
3530 drivemapadd drivemapdel drivemapget drivesetlabel drivespacefree
3531 drivespacetotal drivestatus envget envset envupdate eval execute exp
3532 filechangedir fileclose filecopy filecreatentfslink filecreateshortcut
3533 filedelete fileexists filefindfirstfile filefindnextfile fileflush
3534 filegetattrib filegetencoding filegetlongname filegetpos filegetshortcut
3535 filegetshortname filegetsize filegettime filegetversion fileinstall filemove
3536 fileopen fileopendialog fileread filereadline filerecycle filerecycleempty
3537 filesavedialog fileselectfolder filesetattrib filesetpos filesettime
3538 filewrite filewriteline floor ftpsetproxy guicreate guictrlcreateavi
3539 guictrlcreatebutton guictrlcreatecheckbox guictrlcreatecombo
3540 guictrlcreatecontextmenu guictrlcreatedate guictrlcreatedummy
3541 guictrlcreateedit guictrlcreategraphic guictrlcreategroup guictrlcreateicon
3542 guictrlcreateinput guictrlcreatelabel guictrlcreatelist
3543 guictrlcreatelistview guictrlcreatelistviewitem guictrlcreatemenu
3544 guictrlcreatemenuitem guictrlcreatemonthcal guictrlcreateobj
3545 guictrlcreatepic guictrlcreateprogress guictrlcreateradio
3546 guictrlcreateslider guictrlcreatetab guictrlcreatetabitem
3547 guictrlcreatetreeview guictrlcreatetreeviewitem guictrlcreateupdown
3548 guictrldelete guictrlgethandle guictrlgetstate guictrlread guictrlrecvmsg
3549 guictrlregisterlistviewsort guictrlsendmsg guictrlsendtodummy
3550 guictrlsetbkcolor guictrlsetcolor guictrlsetcursor guictrlsetdata
3551 guictrlsetdefbkcolor guictrlsetdefcolor guictrlsetfont guictrlsetgraphic
3552 guictrlsetimage guictrlsetlimit guictrlsetonevent guictrlsetpos
3553 guictrlsetresizing guictrlsetstate guictrlsetstyle guictrlsettip guidelete
3554 guigetcursorinfo guigetmsg guigetstyle guiregistermsg guisetaccelerators
3555 guisetbkcolor guisetcoord guisetcursor guisetfont guisethelp guiseticon
3556 guisetonevent guisetstate guisetstyle guistartgroup guiswitch hex hotkeyset
3557 httpsetproxy httpsetuseragent hwnd inetclose inetget inetgetinfo inetgetsize
3558 inetread inidelete iniread inireadsection inireadsectionnames
3559 inirenamesection iniwrite iniwritesection inputbox int isadmin isarray
3560 isbinary isbool isdeclared isdllstruct isfloat ishwnd isint iskeyword
3561 isnumber isobj isptr isstring log memgetstats mod mouseclick mouseclickdrag
3562 mousedown mousegetcursor mousegetpos mousemove mouseup mousewheel msgbox
3563 number objcreate objcreateinterface objevent objevent objget objname
3564 onautoitexitregister onautoitexitunregister opt ping pixelchecksum
3565 pixelgetcolor pixelsearch pluginclose pluginopen processclose processexists
3566 processgetstats processlist processsetpriority processwait processwaitclose
3567 progressoff progresson progressset ptr random regdelete regenumkey
3568 regenumval regread regwrite round run runas runaswait runwait send
3569 sendkeepactive seterror setextended shellexecute shellexecutewait shutdown
3570 sin sleep soundplay soundsetwavevolume splashimageon splashoff splashtexton
3571 sqrt srandom statusbargettext stderrread stdinwrite stdioclose stdoutread
3572 string stringaddcr stringcompare stringformat stringfromasciiarray
3573 stringinstr stringisalnum stringisalpha stringisascii stringisdigit
3574 stringisfloat stringisint stringislower stringisspace stringisupper
3575 stringisxdigit stringleft stringlen stringlower stringmid stringregexp
3576 stringregexpreplace stringreplace stringright stringsplit stringstripcr
3577 stringstripws stringtoasciiarray stringtobinary stringtrimleft
3578 stringtrimright stringupper tan tcpaccept tcpclosesocket tcpconnect
3579 tcplisten tcpnametoip tcprecv tcpsend tcpshutdown tcpstartup timerdiff
3580 timerinit tooltip traycreateitem traycreatemenu traygetmsg trayitemdelete
3581 trayitemgethandle trayitemgetstate trayitemgettext trayitemsetonevent
3582 trayitemsetstate trayitemsettext traysetclick trayseticon traysetonevent
3583 traysetpauseicon traysetstate traysettooltip traytip ubound udpbind
3584 udpclosesocket udpopen udprecv udpsend udpshutdown udpstartup vargettype
3585 winactivate winactive winclose winexists winflash wingetcaretpos
3586 wingetclasslist wingetclientsize wingethandle wingetpos wingetprocess
3587 wingetstate wingettext wingettitle winkill winlist winmenuselectitem
3588 winminimizeall winminimizeallundo winmove winsetontop winsetstate
3589 winsettitle winsettrans winwait winwaitactive winwaitclose
3590 winwaitnotactive""".split()
3591
3592 macros = """\
3593 @appdatacommondir @appdatadir @autoitexe @autoitpid @autoitversion
3594 @autoitx64 @com_eventobj @commonfilesdir @compiled @computername @comspec
3595 @cpuarch @cr @crlf @desktopcommondir @desktopdepth @desktopdir
3596 @desktopheight @desktoprefresh @desktopwidth @documentscommondir @error
3597 @exitcode @exitmethod @extended @favoritescommondir @favoritesdir
3598 @gui_ctrlhandle @gui_ctrlid @gui_dragfile @gui_dragid @gui_dropid
3599 @gui_winhandle @homedrive @homepath @homeshare @hotkeypressed @hour
3600 @ipaddress1 @ipaddress2 @ipaddress3 @ipaddress4 @kblayout @lf
3601 @logondnsdomain @logondomain @logonserver @mday @min @mon @msec @muilang
3602 @mydocumentsdir @numparams @osarch @osbuild @oslang @osservicepack @ostype
3603 @osversion @programfilesdir @programscommondir @programsdir @scriptdir
3604 @scriptfullpath @scriptlinenumber @scriptname @sec @startmenucommondir
3605 @startmenudir @startupcommondir @startupdir @sw_disable @sw_enable @sw_hide
3606 @sw_lock @sw_maximize @sw_minimize @sw_restore @sw_show @sw_showdefault
3607 @sw_showmaximized @sw_showminimized @sw_showminnoactive @sw_showna
3608 @sw_shownoactivate @sw_shownormal @sw_unlock @systemdir @tab @tempdir
3609 @tray_id @trayiconflashing @trayiconvisible @username @userprofiledir @wday
3610 @windowsdir @workingdir @yday @year""".split()
3611
3612 tokens = {
3613 'root': [
3614 (r';.*\n', Comment.Single),
3615 (r'(#comments-start|#cs).*?(#comments-end|#ce)', Comment.Multiline),
3616 (r'[\[\]{}(),;]', Punctuation),
3617 (r'(and|or|not)\b', Operator.Word),
3618 (r'[\$|@][a-zA-Z_][a-zA-Z0-9_]*', Name.Variable),
3619 (r'!=|==|:=|\.=|<<|>>|[-~+/*%=<>&^|?:!.]', Operator),
3620 include('commands'),
3621 include('labels'),
3622 include('builtInFunctions'),
3623 include('builtInMarcros'),
3624 (r'"', String, combined('stringescape', 'dqs')),
3625 include('numbers'),
3626 (r'[a-zA-Z_#@$][a-zA-Z0-9_#@$]*', Name),
3627 (r'\\|\'', Text),
3628 (r'\`([\,\%\`abfnrtv\-\+;])', String.Escape),
3629 (r'_\n', Text), # Line continuation
3630 include('garbage'),
3631 ],
3632 'commands': [
3633 (r'(?i)(\s*)(%s)\b' % '|'.join(keywords),
3634 bygroups(Text, Name.Builtin)),
3635 ],
3636 'builtInFunctions': [
3637 (r'(?i)(%s)\b' % '|'.join(functions),
3638 Name.Function),
3639 ],
3640 'builtInMarcros': [
3641 (r'(?i)(%s)\b' % '|'.join(macros),
3642 Name.Variable.Global),
3643 ],
3644 'labels': [
3645 # sendkeys
3646 (r'(^\s*)({\S+?})', bygroups(Text, Name.Label)),
3647 ],
3648 'numbers': [
3649 (r'(\d+\.\d*|\d*\.\d+)([eE][+-]?[0-9]+)?', Number.Float),
3650 (r'\d+[eE][+-]?[0-9]+', Number.Float),
3651 (r'0\d+', Number.Oct),
3652 (r'0[xX][a-fA-F0-9]+', Number.Hex),
3653 (r'\d+L', Number.Integer.Long),
3654 (r'\d+', Number.Integer)
3655 ],
3656 'stringescape': [
3657 (r'\"\"|\`([\,\%\`abfnrtv])', String.Escape),
3658 ],
3659 'strings': [
3660 (r'[^"\n]+', String),
3661 ],
3662 'dqs': [
3663 (r'"', String, '#pop'),
3664 include('strings')
3665 ],
3666 'garbage': [
3667 (r'[^\S\n]', Text),
3668 ],
3669 }

eric ide

mercurial