pygmentize 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (101) hide show
  1. data/LICENSE +19 -0
  2. data/lib/pygments.rb +23 -0
  3. data/pygmentize.gemspec +11 -0
  4. data/test/pygments.rb +19 -0
  5. data/vendor/pygmentize.py +7 -0
  6. data/vendor/pygments/AUTHORS +73 -0
  7. data/vendor/pygments/LICENSE +25 -0
  8. data/vendor/pygments/__init__.py +91 -0
  9. data/vendor/pygments/__init__.pyc +0 -0
  10. data/vendor/pygments/cmdline.py +430 -0
  11. data/vendor/pygments/cmdline.pyc +0 -0
  12. data/vendor/pygments/console.py +74 -0
  13. data/vendor/pygments/console.pyc +0 -0
  14. data/vendor/pygments/filter.py +74 -0
  15. data/vendor/pygments/filter.pyc +0 -0
  16. data/vendor/pygments/filters/__init__.py +357 -0
  17. data/vendor/pygments/filters/__init__.pyc +0 -0
  18. data/vendor/pygments/formatter.py +92 -0
  19. data/vendor/pygments/formatter.pyc +0 -0
  20. data/vendor/pygments/formatters/__init__.py +68 -0
  21. data/vendor/pygments/formatters/__init__.pyc +0 -0
  22. data/vendor/pygments/formatters/_mapping.py +92 -0
  23. data/vendor/pygments/formatters/_mapping.pyc +0 -0
  24. data/vendor/pygments/formatters/bbcode.py +109 -0
  25. data/vendor/pygments/formatters/bbcode.pyc +0 -0
  26. data/vendor/pygments/formatters/html.py +723 -0
  27. data/vendor/pygments/formatters/html.pyc +0 -0
  28. data/vendor/pygments/formatters/img.py +553 -0
  29. data/vendor/pygments/formatters/img.pyc +0 -0
  30. data/vendor/pygments/formatters/latex.py +354 -0
  31. data/vendor/pygments/formatters/latex.pyc +0 -0
  32. data/vendor/pygments/formatters/other.py +117 -0
  33. data/vendor/pygments/formatters/other.pyc +0 -0
  34. data/vendor/pygments/formatters/rtf.py +136 -0
  35. data/vendor/pygments/formatters/rtf.pyc +0 -0
  36. data/vendor/pygments/formatters/svg.py +154 -0
  37. data/vendor/pygments/formatters/svg.pyc +0 -0
  38. data/vendor/pygments/formatters/terminal.py +109 -0
  39. data/vendor/pygments/formatters/terminal.pyc +0 -0
  40. data/vendor/pygments/formatters/terminal256.py +219 -0
  41. data/vendor/pygments/formatters/terminal256.pyc +0 -0
  42. data/vendor/pygments/lexer.py +660 -0
  43. data/vendor/pygments/lexer.pyc +0 -0
  44. data/vendor/pygments/lexers/__init__.py +226 -0
  45. data/vendor/pygments/lexers/__init__.pyc +0 -0
  46. data/vendor/pygments/lexers/_asybuiltins.py +1645 -0
  47. data/vendor/pygments/lexers/_clbuiltins.py +232 -0
  48. data/vendor/pygments/lexers/_luabuiltins.py +256 -0
  49. data/vendor/pygments/lexers/_mapping.py +234 -0
  50. data/vendor/pygments/lexers/_mapping.pyc +0 -0
  51. data/vendor/pygments/lexers/_phpbuiltins.py +3389 -0
  52. data/vendor/pygments/lexers/_vimbuiltins.py +3 -0
  53. data/vendor/pygments/lexers/agile.py +1485 -0
  54. data/vendor/pygments/lexers/agile.pyc +0 -0
  55. data/vendor/pygments/lexers/asm.py +353 -0
  56. data/vendor/pygments/lexers/compiled.py +2365 -0
  57. data/vendor/pygments/lexers/dotnet.py +355 -0
  58. data/vendor/pygments/lexers/functional.py +756 -0
  59. data/vendor/pygments/lexers/functional.pyc +0 -0
  60. data/vendor/pygments/lexers/math.py +461 -0
  61. data/vendor/pygments/lexers/other.py +2297 -0
  62. data/vendor/pygments/lexers/parsers.py +695 -0
  63. data/vendor/pygments/lexers/special.py +100 -0
  64. data/vendor/pygments/lexers/special.pyc +0 -0
  65. data/vendor/pygments/lexers/templates.py +1387 -0
  66. data/vendor/pygments/lexers/text.py +1586 -0
  67. data/vendor/pygments/lexers/web.py +1619 -0
  68. data/vendor/pygments/lexers/web.pyc +0 -0
  69. data/vendor/pygments/plugin.py +74 -0
  70. data/vendor/pygments/plugin.pyc +0 -0
  71. data/vendor/pygments/scanner.py +104 -0
  72. data/vendor/pygments/style.py +117 -0
  73. data/vendor/pygments/style.pyc +0 -0
  74. data/vendor/pygments/styles/__init__.py +68 -0
  75. data/vendor/pygments/styles/__init__.pyc +0 -0
  76. data/vendor/pygments/styles/autumn.py +65 -0
  77. data/vendor/pygments/styles/borland.py +51 -0
  78. data/vendor/pygments/styles/bw.py +49 -0
  79. data/vendor/pygments/styles/colorful.py +81 -0
  80. data/vendor/pygments/styles/default.py +73 -0
  81. data/vendor/pygments/styles/default.pyc +0 -0
  82. data/vendor/pygments/styles/emacs.py +72 -0
  83. data/vendor/pygments/styles/friendly.py +72 -0
  84. data/vendor/pygments/styles/fruity.py +43 -0
  85. data/vendor/pygments/styles/manni.py +75 -0
  86. data/vendor/pygments/styles/monokai.py +106 -0
  87. data/vendor/pygments/styles/murphy.py +80 -0
  88. data/vendor/pygments/styles/native.py +65 -0
  89. data/vendor/pygments/styles/pastie.py +75 -0
  90. data/vendor/pygments/styles/perldoc.py +69 -0
  91. data/vendor/pygments/styles/tango.py +141 -0
  92. data/vendor/pygments/styles/trac.py +63 -0
  93. data/vendor/pygments/styles/vim.py +63 -0
  94. data/vendor/pygments/styles/vs.py +38 -0
  95. data/vendor/pygments/token.py +198 -0
  96. data/vendor/pygments/token.pyc +0 -0
  97. data/vendor/pygments/unistring.py +130 -0
  98. data/vendor/pygments/unistring.pyc +0 -0
  99. data/vendor/pygments/util.py +226 -0
  100. data/vendor/pygments/util.pyc +0 -0
  101. metadata +166 -0
@@ -0,0 +1,2297 @@
1
+ # -*- coding: utf-8 -*-
2
+ """
3
+ pygments.lexers.other
4
+ ~~~~~~~~~~~~~~~~~~~~~
5
+
6
+ Lexers for other languages.
7
+
8
+ :copyright: Copyright 2006-2010 by the Pygments team, see AUTHORS.
9
+ :license: BSD, see LICENSE for details.
10
+ """
11
+
12
+ import re
13
+
14
+ from pygments.lexer import Lexer, RegexLexer, include, bygroups, using, \
15
+ this, do_insertions
16
+ from pygments.token import Error, Punctuation, \
17
+ Text, Comment, Operator, Keyword, Name, String, Number, Generic
18
+ from pygments.util import shebang_matches
19
+ from pygments.lexers.web import HtmlLexer
20
+
21
+
22
+ __all__ = ['SqlLexer', 'MySqlLexer', 'SqliteConsoleLexer', 'BrainfuckLexer',
23
+ 'BashLexer', 'BatchLexer', 'BefungeLexer', 'RedcodeLexer',
24
+ 'MOOCodeLexer', 'SmalltalkLexer', 'TcshLexer', 'LogtalkLexer',
25
+ 'GnuplotLexer', 'PovrayLexer', 'AppleScriptLexer',
26
+ 'BashSessionLexer', 'ModelicaLexer', 'RebolLexer', 'ABAPLexer',
27
+ 'NewspeakLexer', 'GherkinLexer', 'AsymptoteLexer']
28
+
29
+ line_re = re.compile('.*?\n')
30
+
31
+
32
+ class SqlLexer(RegexLexer):
33
+ """
34
+ Lexer for Structured Query Language. Currently, this lexer does
35
+ not recognize any special syntax except ANSI SQL.
36
+ """
37
+
38
+ name = 'SQL'
39
+ aliases = ['sql']
40
+ filenames = ['*.sql']
41
+ mimetypes = ['text/x-sql']
42
+
43
+ flags = re.IGNORECASE
44
+ tokens = {
45
+ 'root': [
46
+ (r'\s+', Text),
47
+ (r'--.*?\n', Comment.Single),
48
+ (r'/\*', Comment.Multiline, 'multiline-comments'),
49
+ (r'(ABORT|ABS|ABSOLUTE|ACCESS|ADA|ADD|ADMIN|AFTER|AGGREGATE|'
50
+ r'ALIAS|ALL|ALLOCATE|ALTER|ANALYSE|ANALYZE|AND|ANY|ARE|AS|'
51
+ r'ASC|ASENSITIVE|ASSERTION|ASSIGNMENT|ASYMMETRIC|AT|ATOMIC|'
52
+ r'AUTHORIZATION|AVG|BACKWARD|BEFORE|BEGIN|BETWEEN|BITVAR|'
53
+ r'BIT_LENGTH|BOTH|BREADTH|BY|C|CACHE|CALL|CALLED|CARDINALITY|'
54
+ r'CASCADE|CASCADED|CASE|CAST|CATALOG|CATALOG_NAME|CHAIN|'
55
+ r'CHARACTERISTICS|CHARACTER_LENGTH|CHARACTER_SET_CATALOG|'
56
+ r'CHARACTER_SET_NAME|CHARACTER_SET_SCHEMA|CHAR_LENGTH|CHECK|'
57
+ r'CHECKED|CHECKPOINT|CLASS|CLASS_ORIGIN|CLOB|CLOSE|CLUSTER|'
58
+ r'COALSECE|COBOL|COLLATE|COLLATION|COLLATION_CATALOG|'
59
+ r'COLLATION_NAME|COLLATION_SCHEMA|COLUMN|COLUMN_NAME|'
60
+ r'COMMAND_FUNCTION|COMMAND_FUNCTION_CODE|COMMENT|COMMIT|'
61
+ r'COMMITTED|COMPLETION|CONDITION_NUMBER|CONNECT|CONNECTION|'
62
+ r'CONNECTION_NAME|CONSTRAINT|CONSTRAINTS|CONSTRAINT_CATALOG|'
63
+ r'CONSTRAINT_NAME|CONSTRAINT_SCHEMA|CONSTRUCTOR|CONTAINS|'
64
+ r'CONTINUE|CONVERSION|CONVERT|COPY|CORRESPONTING|COUNT|'
65
+ r'CREATE|CREATEDB|CREATEUSER|CROSS|CUBE|CURRENT|CURRENT_DATE|'
66
+ r'CURRENT_PATH|CURRENT_ROLE|CURRENT_TIME|CURRENT_TIMESTAMP|'
67
+ r'CURRENT_USER|CURSOR|CURSOR_NAME|CYCLE|DATA|DATABASE|'
68
+ r'DATETIME_INTERVAL_CODE|DATETIME_INTERVAL_PRECISION|DAY|'
69
+ r'DEALLOCATE|DECLARE|DEFAULT|DEFAULTS|DEFERRABLE|DEFERRED|'
70
+ r'DEFINED|DEFINER|DELETE|DELIMITER|DELIMITERS|DEREF|DESC|'
71
+ r'DESCRIBE|DESCRIPTOR|DESTROY|DESTRUCTOR|DETERMINISTIC|'
72
+ r'DIAGNOSTICS|DICTIONARY|DISCONNECT|DISPATCH|DISTINCT|DO|'
73
+ r'DOMAIN|DROP|DYNAMIC|DYNAMIC_FUNCTION|DYNAMIC_FUNCTION_CODE|'
74
+ r'EACH|ELSE|ENCODING|ENCRYPTED|END|END-EXEC|EQUALS|ESCAPE|EVERY|'
75
+ r'EXCEPT|ESCEPTION|EXCLUDING|EXCLUSIVE|EXEC|EXECUTE|EXISTING|'
76
+ r'EXISTS|EXPLAIN|EXTERNAL|EXTRACT|FALSE|FETCH|FINAL|FIRST|FOR|'
77
+ r'FORCE|FOREIGN|FORTRAN|FORWARD|FOUND|FREE|FREEZE|FROM|FULL|'
78
+ r'FUNCTION|G|GENERAL|GENERATED|GET|GLOBAL|GO|GOTO|GRANT|GRANTED|'
79
+ r'GROUP|GROUPING|HANDLER|HAVING|HIERARCHY|HOLD|HOST|IDENTITY|'
80
+ r'IGNORE|ILIKE|IMMEDIATE|IMMUTABLE|IMPLEMENTATION|IMPLICIT|IN|'
81
+ r'INCLUDING|INCREMENT|INDEX|INDITCATOR|INFIX|INHERITS|INITIALIZE|'
82
+ r'INITIALLY|INNER|INOUT|INPUT|INSENSITIVE|INSERT|INSTANTIABLE|'
83
+ r'INSTEAD|INTERSECT|INTO|INVOKER|IS|ISNULL|ISOLATION|ITERATE|JOIN|'
84
+ r'KEY|KEY_MEMBER|KEY_TYPE|LANCOMPILER|LANGUAGE|LARGE|LAST|'
85
+ r'LATERAL|LEADING|LEFT|LENGTH|LESS|LEVEL|LIKE|LIMIT|LISTEN|LOAD|'
86
+ r'LOCAL|LOCALTIME|LOCALTIMESTAMP|LOCATION|LOCATOR|LOCK|LOWER|'
87
+ r'MAP|MATCH|MAX|MAXVALUE|MESSAGE_LENGTH|MESSAGE_OCTET_LENGTH|'
88
+ r'MESSAGE_TEXT|METHOD|MIN|MINUTE|MINVALUE|MOD|MODE|MODIFIES|'
89
+ r'MODIFY|MONTH|MORE|MOVE|MUMPS|NAMES|NATIONAL|NATURAL|NCHAR|'
90
+ r'NCLOB|NEW|NEXT|NO|NOCREATEDB|NOCREATEUSER|NONE|NOT|NOTHING|'
91
+ r'NOTIFY|NOTNULL|NULL|NULLABLE|NULLIF|OBJECT|OCTET_LENGTH|OF|OFF|'
92
+ r'OFFSET|OIDS|OLD|ON|ONLY|OPEN|OPERATION|OPERATOR|OPTION|OPTIONS|'
93
+ r'OR|ORDER|ORDINALITY|OUT|OUTER|OUTPUT|OVERLAPS|OVERLAY|OVERRIDING|'
94
+ r'OWNER|PAD|PARAMETER|PARAMETERS|PARAMETER_MODE|PARAMATER_NAME|'
95
+ r'PARAMATER_ORDINAL_POSITION|PARAMETER_SPECIFIC_CATALOG|'
96
+ r'PARAMETER_SPECIFIC_NAME|PARAMATER_SPECIFIC_SCHEMA|PARTIAL|'
97
+ r'PASCAL|PENDANT|PLACING|PLI|POSITION|POSTFIX|PRECISION|PREFIX|'
98
+ r'PREORDER|PREPARE|PRESERVE|PRIMARY|PRIOR|PRIVILEGES|PROCEDURAL|'
99
+ r'PROCEDURE|PUBLIC|READ|READS|RECHECK|RECURSIVE|REF|REFERENCES|'
100
+ r'REFERENCING|REINDEX|RELATIVE|RENAME|REPEATABLE|REPLACE|RESET|'
101
+ r'RESTART|RESTRICT|RESULT|RETURN|RETURNED_LENGTH|'
102
+ r'RETURNED_OCTET_LENGTH|RETURNED_SQLSTATE|RETURNS|REVOKE|RIGHT|'
103
+ r'ROLE|ROLLBACK|ROLLUP|ROUTINE|ROUTINE_CATALOG|ROUTINE_NAME|'
104
+ r'ROUTINE_SCHEMA|ROW|ROWS|ROW_COUNT|RULE|SAVE_POINT|SCALE|SCHEMA|'
105
+ r'SCHEMA_NAME|SCOPE|SCROLL|SEARCH|SECOND|SECURITY|SELECT|SELF|'
106
+ r'SENSITIVE|SERIALIZABLE|SERVER_NAME|SESSION|SESSION_USER|SET|'
107
+ r'SETOF|SETS|SHARE|SHOW|SIMILAR|SIMPLE|SIZE|SOME|SOURCE|SPACE|'
108
+ r'SPECIFIC|SPECIFICTYPE|SPECIFIC_NAME|SQL|SQLCODE|SQLERROR|'
109
+ r'SQLEXCEPTION|SQLSTATE|SQLWARNINIG|STABLE|START|STATE|STATEMENT|'
110
+ r'STATIC|STATISTICS|STDIN|STDOUT|STORAGE|STRICT|STRUCTURE|STYPE|'
111
+ r'SUBCLASS_ORIGIN|SUBLIST|SUBSTRING|SUM|SYMMETRIC|SYSID|SYSTEM|'
112
+ r'SYSTEM_USER|TABLE|TABLE_NAME| TEMP|TEMPLATE|TEMPORARY|TERMINATE|'
113
+ r'THAN|THEN|TIMESTAMP|TIMEZONE_HOUR|TIMEZONE_MINUTE|TO|TOAST|'
114
+ r'TRAILING|TRANSATION|TRANSACTIONS_COMMITTED|'
115
+ r'TRANSACTIONS_ROLLED_BACK|TRANSATION_ACTIVE|TRANSFORM|'
116
+ r'TRANSFORMS|TRANSLATE|TRANSLATION|TREAT|TRIGGER|TRIGGER_CATALOG|'
117
+ r'TRIGGER_NAME|TRIGGER_SCHEMA|TRIM|TRUE|TRUNCATE|TRUSTED|TYPE|'
118
+ r'UNCOMMITTED|UNDER|UNENCRYPTED|UNION|UNIQUE|UNKNOWN|UNLISTEN|'
119
+ r'UNNAMED|UNNEST|UNTIL|UPDATE|UPPER|USAGE|USER|'
120
+ r'USER_DEFINED_TYPE_CATALOG|USER_DEFINED_TYPE_NAME|'
121
+ r'USER_DEFINED_TYPE_SCHEMA|USING|VACUUM|VALID|VALIDATOR|VALUES|'
122
+ r'VARIABLE|VERBOSE|VERSION|VIEW|VOLATILE|WHEN|WHENEVER|WHERE|'
123
+ r'WITH|WITHOUT|WORK|WRITE|YEAR|ZONE)\b', Keyword),
124
+ (r'(ARRAY|BIGINT|BINARY|BIT|BLOB|BOOLEAN|CHAR|CHARACTER|DATE|'
125
+ r'DEC|DECIMAL|FLOAT|INT|INTEGER|INTERVAL|NUMBER|NUMERIC|REAL|'
126
+ r'SERIAL|SMALLINT|VARCHAR|VARYING|INT8|SERIAL8|TEXT)\b',
127
+ Name.Builtin),
128
+ (r'[+*/<>=~!@#%^&|`?^-]', Operator),
129
+ (r'[0-9]+', Number.Integer),
130
+ # TODO: Backslash escapes?
131
+ (r"'(''|[^'])*'", String.Single),
132
+ (r'"(""|[^"])*"', String.Symbol), # not a real string literal in ANSI SQL
133
+ (r'[a-zA-Z_][a-zA-Z0-9_]*', Name),
134
+ (r'[;:()\[\],\.]', Punctuation)
135
+ ],
136
+ 'multiline-comments': [
137
+ (r'/\*', Comment.Multiline, 'multiline-comments'),
138
+ (r'\*/', Comment.Multiline, '#pop'),
139
+ (r'[^/\*]+', Comment.Multiline),
140
+ (r'[/*]', Comment.Multiline)
141
+ ]
142
+ }
143
+
144
+
145
+ class MySqlLexer(RegexLexer):
146
+ """
147
+ Special lexer for MySQL.
148
+ """
149
+
150
+ name = 'MySQL'
151
+ aliases = ['mysql']
152
+ mimetypes = ['text/x-mysql']
153
+
154
+ flags = re.IGNORECASE
155
+ tokens = {
156
+ 'root': [
157
+ (r'\s+', Text),
158
+ (r'(#|--\s+).*?\n', Comment.Single),
159
+ (r'/\*', Comment.Multiline, 'multiline-comments'),
160
+ (r'[0-9]+', Number.Integer),
161
+ (r'[0-9]*\.[0-9]+(e[+-][0-9]+)', Number.Float),
162
+ # TODO: add backslash escapes
163
+ (r"'(''|[^'])*'", String.Single),
164
+ (r'"(""|[^"])*"', String.Double),
165
+ (r"`(``|[^`])*`", String.Symbol),
166
+ (r'[+*/<>=~!@#%^&|`?^-]', Operator),
167
+ (r'\b(tinyint|smallint|mediumint|int|integer|bigint|date|'
168
+ r'datetime|time|bit|bool|tinytext|mediumtext|longtext|text|'
169
+ r'tinyblob|mediumblob|longblob|blob|float|double|double\s+'
170
+ r'precision|real|numeric|dec|decimal|timestamp|year|char|'
171
+ r'varchar|varbinary|varcharacter|enum|set)(\b\s*)(\()?',
172
+ bygroups(Keyword.Type, Text, Punctuation)),
173
+ (r'\b(add|all|alter|analyze|and|as|asc|asensitive|before|between|'
174
+ r'bigint|binary|blob|both|by|call|cascade|case|change|char|'
175
+ r'character|check|collate|column|condition|constraint|continue|'
176
+ r'convert|create|cross|current_date|current_time|'
177
+ r'current_timestamp|current_user|cursor|database|databases|'
178
+ r'day_hour|day_microsecond|day_minute|day_second|dec|decimal|'
179
+ r'declare|default|delayed|delete|desc|describe|deterministic|'
180
+ r'distinct|distinctrow|div|double|drop|dual|each|else|elseif|'
181
+ r'enclosed|escaped|exists|exit|explain|fetch|float|float4|float8'
182
+ r'|for|force|foreign|from|fulltext|grant|group|having|'
183
+ r'high_priority|hour_microsecond|hour_minute|hour_second|if|'
184
+ r'ignore|in|index|infile|inner|inout|insensitive|insert|int|'
185
+ r'int1|int2|int3|int4|int8|integer|interval|into|is|iterate|'
186
+ r'join|key|keys|kill|leading|leave|left|like|limit|lines|load|'
187
+ r'localtime|localtimestamp|lock|long|loop|low_priority|match|'
188
+ r'minute_microsecond|minute_second|mod|modifies|natural|'
189
+ r'no_write_to_binlog|not|numeric|on|optimize|option|optionally|'
190
+ r'or|order|out|outer|outfile|precision|primary|procedure|purge|'
191
+ r'raid0|read|reads|real|references|regexp|release|rename|repeat|'
192
+ r'replace|require|restrict|return|revoke|right|rlike|schema|'
193
+ r'schemas|second_microsecond|select|sensitive|separator|set|'
194
+ r'show|smallint|soname|spatial|specific|sql|sql_big_result|'
195
+ r'sql_calc_found_rows|sql_small_result|sqlexception|sqlstate|'
196
+ r'sqlwarning|ssl|starting|straight_join|table|terminated|then|'
197
+ r'to|trailing|trigger|undo|union|unique|unlock|unsigned|update|'
198
+ r'usage|use|using|utc_date|utc_time|utc_timestamp|values|'
199
+ r'varying|when|where|while|with|write|x509|xor|year_month|'
200
+ r'zerofill)\b', Keyword),
201
+ # TODO: this list is not complete
202
+ (r'\b(auto_increment|engine|charset|tables)\b', Keyword.Pseudo),
203
+ (r'(true|false|null)', Name.Constant),
204
+ (r'([a-zA-Z_][a-zA-Z0-9_]*)(\s*)(\()',
205
+ bygroups(Name.Function, Text, Punctuation)),
206
+ (r'[a-zA-Z_][a-zA-Z0-9_]*', Name),
207
+ (r'@[A-Za-z0-9]*[._]*[A-Za-z0-9]*', Name.Variable),
208
+ (r'[;:()\[\],\.]', Punctuation)
209
+ ],
210
+ 'multiline-comments': [
211
+ (r'/\*', Comment.Multiline, 'multiline-comments'),
212
+ (r'\*/', Comment.Multiline, '#pop'),
213
+ (r'[^/\*]+', Comment.Multiline),
214
+ (r'[/*]', Comment.Multiline)
215
+ ]
216
+ }
217
+
218
+
219
+ class SqliteConsoleLexer(Lexer):
220
+ """
221
+ Lexer for example sessions using sqlite3.
222
+
223
+ *New in Pygments 0.11.*
224
+ """
225
+
226
+ name = 'sqlite3con'
227
+ aliases = ['sqlite3']
228
+ filenames = ['*.sqlite3-console']
229
+ mimetypes = ['text/x-sqlite3-console']
230
+
231
+ def get_tokens_unprocessed(self, data):
232
+ sql = SqlLexer(**self.options)
233
+
234
+ curcode = ''
235
+ insertions = []
236
+ for match in line_re.finditer(data):
237
+ line = match.group()
238
+ if line.startswith('sqlite> ') or line.startswith(' ...> '):
239
+ insertions.append((len(curcode),
240
+ [(0, Generic.Prompt, line[:8])]))
241
+ curcode += line[8:]
242
+ else:
243
+ if curcode:
244
+ for item in do_insertions(insertions,
245
+ sql.get_tokens_unprocessed(curcode)):
246
+ yield item
247
+ curcode = ''
248
+ insertions = []
249
+ if line.startswith('SQL error: '):
250
+ yield (match.start(), Generic.Traceback, line)
251
+ else:
252
+ yield (match.start(), Generic.Output, line)
253
+ if curcode:
254
+ for item in do_insertions(insertions,
255
+ sql.get_tokens_unprocessed(curcode)):
256
+ yield item
257
+
258
+
259
+ class BrainfuckLexer(RegexLexer):
260
+ """
261
+ Lexer for the esoteric `BrainFuck <http://www.muppetlabs.com/~breadbox/bf/>`_
262
+ language.
263
+ """
264
+
265
+ name = 'Brainfuck'
266
+ aliases = ['brainfuck', 'bf']
267
+ filenames = ['*.bf', '*.b']
268
+ mimetypes = ['application/x-brainfuck']
269
+
270
+ tokens = {
271
+ 'common': [
272
+ # use different colors for different instruction types
273
+ (r'[.,]+', Name.Tag),
274
+ (r'[+-]+', Name.Builtin),
275
+ (r'[<>]+', Name.Variable),
276
+ (r'[^.,+\-<>\[\]]+', Comment),
277
+ ],
278
+ 'root': [
279
+ (r'\[', Keyword, 'loop'),
280
+ (r'\]', Error),
281
+ include('common'),
282
+ ],
283
+ 'loop': [
284
+ (r'\[', Keyword, '#push'),
285
+ (r'\]', Keyword, '#pop'),
286
+ include('common'),
287
+ ]
288
+ }
289
+
290
+
291
+ class BefungeLexer(RegexLexer):
292
+ """
293
+ Lexer for the esoteric `Befunge <http://en.wikipedia.org/wiki/Befunge>`_
294
+ language.
295
+
296
+ *New in Pygments 0.7.*
297
+ """
298
+ name = 'Befunge'
299
+ aliases = ['befunge']
300
+ filenames = ['*.befunge']
301
+ mimetypes = ['application/x-befunge']
302
+
303
+ tokens = {
304
+ 'root': [
305
+ (r'[0-9a-f]', Number),
306
+ (r'[\+\*/%!`-]', Operator), # Traditional math
307
+ (r'[<>^v?\[\]rxjk]', Name.Variable), # Move, imperatives
308
+ (r'[:\\$.,n]', Name.Builtin), # Stack ops, imperatives
309
+ (r'[|_mw]', Keyword),
310
+ (r'[{}]', Name.Tag), # Befunge-98 stack ops
311
+ (r'".*?"', String.Double), # Strings don't appear to allow escapes
312
+ (r'\'.', String.Single), # Single character
313
+ (r'[#;]', Comment), # Trampoline... depends on direction hit
314
+ (r'[pg&~=@iotsy]', Keyword), # Misc
315
+ (r'[()A-Z]', Comment), # Fingerprints
316
+ (r'\s+', Text), # Whitespace doesn't matter
317
+ ],
318
+ }
319
+
320
+
321
+
322
+ class BashLexer(RegexLexer):
323
+ """
324
+ Lexer for (ba|k|)sh shell scripts.
325
+
326
+ *New in Pygments 0.6.*
327
+ """
328
+
329
+ name = 'Bash'
330
+ aliases = ['bash', 'sh', 'ksh']
331
+ filenames = ['*.sh', '*.ksh', '*.bash', '*.ebuild', '*.eclass']
332
+ mimetypes = ['application/x-sh', 'application/x-shellscript']
333
+
334
+ tokens = {
335
+ 'root': [
336
+ include('basic'),
337
+ (r'\$\(\(', Keyword, 'math'),
338
+ (r'\$\(', Keyword, 'paren'),
339
+ (r'\${#?', Keyword, 'curly'),
340
+ (r'`', String.Backtick, 'backticks'),
341
+ include('data'),
342
+ ],
343
+ 'basic': [
344
+ (r'\b(if|fi|else|while|do|done|for|then|return|function|case|'
345
+ r'select|continue|until|esac|elif)\s*\b',
346
+ Keyword),
347
+ (r'\b(alias|bg|bind|break|builtin|caller|cd|command|compgen|'
348
+ r'complete|declare|dirs|disown|echo|enable|eval|exec|exit|'
349
+ r'export|false|fc|fg|getopts|hash|help|history|jobs|kill|let|'
350
+ r'local|logout|popd|printf|pushd|pwd|read|readonly|set|shift|'
351
+ r'shopt|source|suspend|test|time|times|trap|true|type|typeset|'
352
+ r'ulimit|umask|unalias|unset|wait)\s*\b(?!\.)',
353
+ Name.Builtin),
354
+ (r'#.*\n', Comment),
355
+ (r'\\[\w\W]', String.Escape),
356
+ (r'(\b\w+)(\s*)(=)', bygroups(Name.Variable, Text, Operator)),
357
+ (r'[\[\]{}()=]', Operator),
358
+ (r'<<\s*(\'?)\\?(\w+)[\w\W]+?\2', String),
359
+ (r'&&|\|\|', Operator),
360
+ ],
361
+ 'data': [
362
+ (r'(?s)\$?"(\\\\|\\[0-7]+|\\.|[^"\\])*"', String.Double),
363
+ (r"(?s)\$?'(\\\\|\\[0-7]+|\\.|[^'\\])*'", String.Single),
364
+ (r';', Text),
365
+ (r'\s+', Text),
366
+ (r'[^=\s\n\[\]{}()$"\'`\\<]+', Text),
367
+ (r'\d+(?= |\Z)', Number),
368
+ (r'\$#?(\w+|.)', Name.Variable),
369
+ (r'<', Text),
370
+ ],
371
+ 'curly': [
372
+ (r'}', Keyword, '#pop'),
373
+ (r':-', Keyword),
374
+ (r'[a-zA-Z0-9_]+', Name.Variable),
375
+ (r'[^}:"\'`$]+', Punctuation),
376
+ (r':', Punctuation),
377
+ include('root'),
378
+ ],
379
+ 'paren': [
380
+ (r'\)', Keyword, '#pop'),
381
+ include('root'),
382
+ ],
383
+ 'math': [
384
+ (r'\)\)', Keyword, '#pop'),
385
+ (r'[-+*/%^|&]|\*\*|\|\|', Operator),
386
+ (r'\d+', Number),
387
+ include('root'),
388
+ ],
389
+ 'backticks': [
390
+ (r'`', String.Backtick, '#pop'),
391
+ include('root'),
392
+ ],
393
+ }
394
+
395
+ def analyse_text(text):
396
+ return shebang_matches(text, r'(ba|z|)sh')
397
+
398
+
399
+ class BashSessionLexer(Lexer):
400
+ """
401
+ Lexer for simplistic shell sessions.
402
+
403
+ *New in Pygments 1.1.*
404
+ """
405
+
406
+ name = 'Bash Session'
407
+ aliases = ['console']
408
+ filenames = ['*.sh-session']
409
+ mimetypes = ['application/x-shell-session']
410
+
411
+ def get_tokens_unprocessed(self, text):
412
+ bashlexer = BashLexer(**self.options)
413
+
414
+ pos = 0
415
+ curcode = ''
416
+ insertions = []
417
+
418
+ for match in line_re.finditer(text):
419
+ line = match.group()
420
+ m = re.match(r'^((?:|sh\S*?|\w+\S+[@:]\S+(?:\s+\S+)?|\[\S+[@:]'
421
+ r'[^\n]+\].+)[$#%])(.*\n?)', line)
422
+ if m:
423
+ # To support output lexers (say diff output), the output
424
+ # needs to be broken by prompts whenever the output lexer
425
+ # changes.
426
+ if not insertions:
427
+ pos = match.start()
428
+
429
+ insertions.append((len(curcode),
430
+ [(0, Generic.Prompt, m.group(1))]))
431
+ curcode += m.group(2)
432
+ elif line.startswith('>'):
433
+ insertions.append((len(curcode),
434
+ [(0, Generic.Prompt, line[:1])]))
435
+ curcode += line[1:]
436
+ else:
437
+ if insertions:
438
+ toks = bashlexer.get_tokens_unprocessed(curcode)
439
+ for i, t, v in do_insertions(insertions, toks):
440
+ yield pos+i, t, v
441
+ yield match.start(), Generic.Output, line
442
+ insertions = []
443
+ curcode = ''
444
+ if insertions:
445
+ for i, t, v in do_insertions(insertions,
446
+ bashlexer.get_tokens_unprocessed(curcode)):
447
+ yield pos+i, t, v
448
+
449
+
450
+ class BatchLexer(RegexLexer):
451
+ """
452
+ Lexer for the DOS/Windows Batch file format.
453
+
454
+ *New in Pygments 0.7.*
455
+ """
456
+ name = 'Batchfile'
457
+ aliases = ['bat']
458
+ filenames = ['*.bat', '*.cmd']
459
+ mimetypes = ['application/x-dos-batch']
460
+
461
+ flags = re.MULTILINE | re.IGNORECASE
462
+
463
+ tokens = {
464
+ 'root': [
465
+ # Lines can start with @ to prevent echo
466
+ (r'^\s*@', Punctuation),
467
+ (r'^(\s*)(rem\s.*)$', bygroups(Text, Comment)),
468
+ (r'".*?"', String.Double),
469
+ (r"'.*?'", String.Single),
470
+ # If made more specific, make sure you still allow expansions
471
+ # like %~$VAR:zlt
472
+ (r'%%?[~$:\w]+%?', Name.Variable),
473
+ (r'::.*', Comment), # Technically :: only works at BOL
474
+ (r'(set)(\s+)(\w+)', bygroups(Keyword, Text, Name.Variable)),
475
+ (r'(call)(\s+)(:\w+)', bygroups(Keyword, Text, Name.Label)),
476
+ (r'(goto)(\s+)(\w+)', bygroups(Keyword, Text, Name.Label)),
477
+ (r'\b(set|call|echo|on|off|endlocal|for|do|goto|if|pause|'
478
+ r'setlocal|shift|errorlevel|exist|defined|cmdextversion|'
479
+ r'errorlevel|else|cd|md|del|deltree|cls|choice)\b', Keyword),
480
+ (r'\b(equ|neq|lss|leq|gtr|geq)\b', Operator),
481
+ include('basic'),
482
+ (r'.', Text),
483
+ ],
484
+ 'echo': [
485
+ # Escapes only valid within echo args?
486
+ (r'\^\^|\^<|\^>|\^\|', String.Escape),
487
+ (r'\n', Text, '#pop'),
488
+ include('basic'),
489
+ (r'[^\'"^]+', Text),
490
+ ],
491
+ 'basic': [
492
+ (r'".*?"', String.Double),
493
+ (r"'.*?'", String.Single),
494
+ (r'`.*?`', String.Backtick),
495
+ (r'-?\d+', Number),
496
+ (r',', Punctuation),
497
+ (r'=', Operator),
498
+ (r'/\S+', Name),
499
+ (r':\w+', Name.Label),
500
+ (r'\w:\w+', Text),
501
+ (r'([<>|])(\s*)(\w+)', bygroups(Punctuation, Text, Name)),
502
+ ],
503
+ }
504
+
505
+
506
+ class RedcodeLexer(RegexLexer):
507
+ """
508
+ A simple Redcode lexer based on ICWS'94.
509
+ Contributed by Adam Blinkinsop <blinks@acm.org>.
510
+
511
+ *New in Pygments 0.8.*
512
+ """
513
+ name = 'Redcode'
514
+ aliases = ['redcode']
515
+ filenames = ['*.cw']
516
+
517
+ opcodes = ['DAT','MOV','ADD','SUB','MUL','DIV','MOD',
518
+ 'JMP','JMZ','JMN','DJN','CMP','SLT','SPL',
519
+ 'ORG','EQU','END']
520
+ modifiers = ['A','B','AB','BA','F','X','I']
521
+
522
+ tokens = {
523
+ 'root': [
524
+ # Whitespace:
525
+ (r'\s+', Text),
526
+ (r';.*$', Comment.Single),
527
+ # Lexemes:
528
+ # Identifiers
529
+ (r'\b(%s)\b' % '|'.join(opcodes), Name.Function),
530
+ (r'\b(%s)\b' % '|'.join(modifiers), Name.Decorator),
531
+ (r'[A-Za-z_][A-Za-z_0-9]+', Name),
532
+ # Operators
533
+ (r'[-+*/%]', Operator),
534
+ (r'[#$@<>]', Operator), # mode
535
+ (r'[.,]', Punctuation), # mode
536
+ # Numbers
537
+ (r'[-+]?\d+', Number.Integer),
538
+ ],
539
+ }
540
+
541
+
542
+ class MOOCodeLexer(RegexLexer):
543
+ """
544
+ For `MOOCode <http://www.moo.mud.org/>`_ (the MOO scripting
545
+ language).
546
+
547
+ *New in Pygments 0.9.*
548
+ """
549
+ name = 'MOOCode'
550
+ filenames = ['*.moo']
551
+ aliases = ['moocode']
552
+ mimetypes = ['text/x-moocode']
553
+
554
+ tokens = {
555
+ 'root' : [
556
+ # Numbers
557
+ (r'(0|[1-9][0-9_]*)', Number.Integer),
558
+ # Strings
559
+ (r'"(\\\\|\\"|[^"])*"', String),
560
+ # exceptions
561
+ (r'(E_PERM|E_DIV)', Name.Exception),
562
+ # db-refs
563
+ (r'((#[-0-9]+)|(\$[a-z_A-Z0-9]+))', Name.Entity),
564
+ # Keywords
565
+ (r'\b(if|else|elseif|endif|for|endfor|fork|endfork|while'
566
+ r'|endwhile|break|continue|return|try'
567
+ r'|except|endtry|finally|in)\b', Keyword),
568
+ # builtins
569
+ (r'(random|length)', Name.Builtin),
570
+ # special variables
571
+ (r'(player|caller|this|args)', Name.Variable.Instance),
572
+ # skip whitespace
573
+ (r'\s+', Text),
574
+ (r'\n', Text),
575
+ # other operators
576
+ (r'([!;=,{}&\|:\.\[\]@\(\)\<\>\?]+)', Operator),
577
+ # function call
578
+ (r'([a-z_A-Z0-9]+)(\()', bygroups(Name.Function, Operator)),
579
+ # variables
580
+ (r'([a-zA-Z_0-9]+)', Text),
581
+ ]
582
+ }
583
+
584
+
585
+ class SmalltalkLexer(RegexLexer):
586
+ """
587
+ For `Smalltalk <http://www.smalltalk.org/>`_ syntax.
588
+ Contributed by Stefan Matthias Aust.
589
+ Rewritten by Nils Winter.
590
+
591
+ *New in Pygments 0.10.*
592
+ """
593
+ name = 'Smalltalk'
594
+ filenames = ['*.st']
595
+ aliases = ['smalltalk', 'squeak']
596
+ mimetypes = ['text/x-smalltalk']
597
+
598
+ tokens = {
599
+ 'root' : [
600
+ (r'(<)(\w+:)(.*?)(>)', bygroups(Text, Keyword, Text, Text)),
601
+ include('squeak fileout'),
602
+ include('whitespaces'),
603
+ include('method definition'),
604
+ (r'(\|)([\w\s]*)(\|)', bygroups(Operator, Name.Variable, Operator)),
605
+ include('objects'),
606
+ (r'\^|\:=|\_', Operator),
607
+ # temporaries
608
+ (r'[\]({}.;!]', Text),
609
+
610
+ ],
611
+ 'method definition' : [
612
+ # Not perfect can't allow whitespaces at the beginning and the
613
+ # without breaking everything
614
+ (r'([a-zA-Z]+\w*:)(\s*)(\w+)',
615
+ bygroups(Name.Function, Text, Name.Variable)),
616
+ (r'^(\b[a-zA-Z]+\w*\b)(\s*)$', bygroups(Name.Function, Text)),
617
+ (r'^([-+*/\\~<>=|&!?,@%]+)(\s*)(\w+)(\s*)$',
618
+ bygroups(Name.Function, Text, Name.Variable, Text)),
619
+ ],
620
+ 'blockvariables' : [
621
+ include('whitespaces'),
622
+ (r'(:)(\s*)([A-Za-z\w]+)',
623
+ bygroups(Operator, Text, Name.Variable)),
624
+ (r'\|', Operator, '#pop'),
625
+ (r'', Text, '#pop'), # else pop
626
+ ],
627
+ 'literals' : [
628
+ (r'\'[^\']*\'', String, 'afterobject'),
629
+ (r'\$.', String.Char, 'afterobject'),
630
+ (r'#\(', String.Symbol, 'parenth'),
631
+ (r'\)', Text, 'afterobject'),
632
+ (r'(\d+r)?-?\d+(\.\d+)?(e-?\d+)?', Number, 'afterobject'),
633
+ ],
634
+ '_parenth_helper' : [
635
+ include('whitespaces'),
636
+ (r'(\d+r)?-?\d+(\.\d+)?(e-?\d+)?', Number),
637
+ (r'[-+*/\\~<>=|&#!?,@%\w+:]+', String.Symbol),
638
+ # literals
639
+ (r'\'[^\']*\'', String),
640
+ (r'\$.', String.Char),
641
+ (r'#*\(', String.Symbol, 'inner_parenth'),
642
+ ],
643
+ 'parenth' : [
644
+ # This state is a bit tricky since
645
+ # we can't just pop this state
646
+ (r'\)', String.Symbol, ('root','afterobject')),
647
+ include('_parenth_helper'),
648
+ ],
649
+ 'inner_parenth': [
650
+ (r'\)', String.Symbol, '#pop'),
651
+ include('_parenth_helper'),
652
+ ],
653
+ 'whitespaces' : [
654
+ # skip whitespace and comments
655
+ (r'\s+', Text),
656
+ (r'"[^"]*"', Comment),
657
+ ],
658
+ 'objects' : [
659
+ (r'\[', Text, 'blockvariables'),
660
+ (r'\]', Text, 'afterobject'),
661
+ (r'\b(self|super|true|false|nil|thisContext)\b',
662
+ Name.Builtin.Pseudo, 'afterobject'),
663
+ (r'\b[A-Z]\w*(?!:)\b', Name.Class, 'afterobject'),
664
+ (r'\b[a-z]\w*(?!:)\b', Name.Variable, 'afterobject'),
665
+ (r'#("[^"]*"|[-+*/\\~<>=|&!?,@%]+|[\w:]+)',
666
+ String.Symbol, 'afterobject'),
667
+ include('literals'),
668
+ ],
669
+ 'afterobject' : [
670
+ (r'! !$', Keyword , '#pop'), # squeak chunk delimeter
671
+ include('whitespaces'),
672
+ (r'\b(ifTrue:|ifFalse:|whileTrue:|whileFalse:|timesRepeat:)',
673
+ Name.Builtin, '#pop'),
674
+ (r'\b(new\b(?!:))', Name.Builtin),
675
+ (r'\:=|\_', Operator, '#pop'),
676
+ (r'\b[a-zA-Z]+\w*:', Name.Function, '#pop'),
677
+ (r'\b[a-zA-Z]+\w*', Name.Function),
678
+ (r'\w+:?|[-+*/\\~<>=|&!?,@%]+', Name.Function, '#pop'),
679
+ (r'\.', Punctuation, '#pop'),
680
+ (r';', Punctuation),
681
+ (r'[\])}]', Text),
682
+ (r'[\[({]', Text, '#pop'),
683
+ ],
684
+ 'squeak fileout' : [
685
+ # Squeak fileout format (optional)
686
+ (r'^"[^"]*"!', Keyword),
687
+ (r"^'[^']*'!", Keyword),
688
+ (r'^(!)(\w+)( commentStamp: )(.*?)( prior: .*?!\n)(.*?)(!)',
689
+ bygroups(Keyword, Name.Class, Keyword, String, Keyword, Text, Keyword)),
690
+ (r'^(!)(\w+(?: class)?)( methodsFor: )(\'[^\']*\')(.*?!)',
691
+ bygroups(Keyword, Name.Class, Keyword, String, Keyword)),
692
+ (r'^(\w+)( subclass: )(#\w+)'
693
+ r'(\s+instanceVariableNames: )(.*?)'
694
+ r'(\s+classVariableNames: )(.*?)'
695
+ r'(\s+poolDictionaries: )(.*?)'
696
+ r'(\s+category: )(.*?)(!)',
697
+ bygroups(Name.Class, Keyword, String.Symbol, Keyword, String, Keyword,
698
+ String, Keyword, String, Keyword, String, Keyword)),
699
+ (r'^(\w+(?: class)?)(\s+instanceVariableNames: )(.*?)(!)',
700
+ bygroups(Name.Class, Keyword, String, Keyword)),
701
+ (r'(!\n)(\].*)(! !)$', bygroups(Keyword, Text, Keyword)),
702
+ (r'! !$', Keyword),
703
+ ],
704
+ }
705
+
706
+
707
+ class TcshLexer(RegexLexer):
708
+ """
709
+ Lexer for tcsh scripts.
710
+
711
+ *New in Pygments 0.10.*
712
+ """
713
+
714
+ name = 'Tcsh'
715
+ aliases = ['tcsh', 'csh']
716
+ filenames = ['*.tcsh', '*.csh']
717
+ mimetypes = ['application/x-csh']
718
+
719
+ tokens = {
720
+ 'root': [
721
+ include('basic'),
722
+ (r'\$\(', Keyword, 'paren'),
723
+ (r'\${#?', Keyword, 'curly'),
724
+ (r'`', String.Backtick, 'backticks'),
725
+ include('data'),
726
+ ],
727
+ 'basic': [
728
+ (r'\b(if|endif|else|while|then|foreach|case|default|'
729
+ r'continue|goto|breaksw|end|switch|endsw)\s*\b',
730
+ Keyword),
731
+ (r'\b(alias|alloc|bg|bindkey|break|builtins|bye|caller|cd|chdir|'
732
+ r'complete|dirs|echo|echotc|eval|exec|exit|'
733
+ r'fg|filetest|getxvers|glob|getspath|hashstat|history|hup|inlib|jobs|kill|'
734
+ r'limit|log|login|logout|ls-F|migrate|newgrp|nice|nohup|notify|'
735
+ r'onintr|popd|printenv|pushd|rehash|repeat|rootnode|popd|pushd|set|shift|'
736
+ r'sched|setenv|setpath|settc|setty|setxvers|shift|source|stop|suspend|'
737
+ r'source|suspend|telltc|time|'
738
+ r'umask|unalias|uncomplete|unhash|universe|unlimit|unset|unsetenv|'
739
+ r'ver|wait|warp|watchlog|where|which)\s*\b',
740
+ Name.Builtin),
741
+ (r'#.*\n', Comment),
742
+ (r'\\[\w\W]', String.Escape),
743
+ (r'(\b\w+)(\s*)(=)', bygroups(Name.Variable, Text, Operator)),
744
+ (r'[\[\]{}()=]+', Operator),
745
+ (r'<<\s*(\'?)\\?(\w+)[\w\W]+?\2', String),
746
+ ],
747
+ 'data': [
748
+ (r'(?s)"(\\\\|\\[0-7]+|\\.|[^"\\])*"', String.Double),
749
+ (r"(?s)'(\\\\|\\[0-7]+|\\.|[^'\\])*'", String.Single),
750
+ (r'\s+', Text),
751
+ (r'[^=\s\n\[\]{}()$"\'`\\]+', Text),
752
+ (r'\d+(?= |\Z)', Number),
753
+ (r'\$#?(\w+|.)', Name.Variable),
754
+ ],
755
+ 'curly': [
756
+ (r'}', Keyword, '#pop'),
757
+ (r':-', Keyword),
758
+ (r'[a-zA-Z0-9_]+', Name.Variable),
759
+ (r'[^}:"\'`$]+', Punctuation),
760
+ (r':', Punctuation),
761
+ include('root'),
762
+ ],
763
+ 'paren': [
764
+ (r'\)', Keyword, '#pop'),
765
+ include('root'),
766
+ ],
767
+ 'backticks': [
768
+ (r'`', String.Backtick, '#pop'),
769
+ include('root'),
770
+ ],
771
+ }
772
+
773
+
774
+ class LogtalkLexer(RegexLexer):
775
+ """
776
+ For `Logtalk <http://logtalk.org/>`_ source code.
777
+
778
+ *New in Pygments 0.10.*
779
+ """
780
+
781
+ name = 'Logtalk'
782
+ aliases = ['logtalk']
783
+ filenames = ['*.lgt']
784
+ mimetypes = ['text/x-logtalk']
785
+
786
+ tokens = {
787
+ 'root': [
788
+ # Directives
789
+ (r'^\s*:-\s',Punctuation,'directive'),
790
+ # Comments
791
+ (r'%.*?\n', Comment),
792
+ (r'/\*(.|\n)*?\*/',Comment),
793
+ # Whitespace
794
+ (r'\n', Text),
795
+ (r'\s+', Text),
796
+ # Numbers
797
+ (r"0'.", Number),
798
+ (r'0b[01]+', Number),
799
+ (r'0o[0-7]+', Number),
800
+ (r'0x[0-9a-fA-F]+', Number),
801
+ (r'\d+\.?\d*((e|E)(\+|-)?\d+)?', Number),
802
+ # Variables
803
+ (r'([A-Z_][a-zA-Z0-9_]*)', Name.Variable),
804
+ # Event handlers
805
+ (r'(after|before)(?=[(])', Keyword),
806
+ # Execution-context methods
807
+ (r'(parameter|this|se(lf|nder))(?=[(])', Keyword),
808
+ # Reflection
809
+ (r'(current_predicate|predicate_property)(?=[(])', Keyword),
810
+ # DCGs and term expansion
811
+ (r'(expand_(goal|term)|(goal|term)_expansion|phrase)(?=[(])',
812
+ Keyword),
813
+ # Entity
814
+ (r'(abolish|c(reate|urrent))_(object|protocol|category)(?=[(])',
815
+ Keyword),
816
+ (r'(object|protocol|category)_property(?=[(])', Keyword),
817
+ # Entity relations
818
+ (r'complements_object(?=[(])', Keyword),
819
+ (r'extends_(object|protocol|category)(?=[(])', Keyword),
820
+ (r'imp(lements_protocol|orts_category)(?=[(])', Keyword),
821
+ (r'(instantiat|specializ)es_class(?=[(])', Keyword),
822
+ # Events
823
+ (r'(current_event|(abolish|define)_events)(?=[(])', Keyword),
824
+ # Flags
825
+ (r'(current|set)_logtalk_flag(?=[(])', Keyword),
826
+ # Compiling, loading, and library paths
827
+ (r'logtalk_(compile|l(ibrary_path|oad))(?=[(])', Keyword),
828
+ # Database
829
+ (r'(clause|retract(all)?)(?=[(])', Keyword),
830
+ (r'a(bolish|ssert(a|z))(?=[(])', Keyword),
831
+ # Control
832
+ (r'(ca(ll|tch)|throw)(?=[(])', Keyword),
833
+ (r'(fail|true)\b', Keyword),
834
+ # All solutions
835
+ (r'((bag|set)of|f(ind|or)all)(?=[(])', Keyword),
836
+ # Multi-threading meta-predicates
837
+ (r'threaded(_(call|once|ignore|exit|peek|wait|notify))?(?=[(])',
838
+ Keyword),
839
+ # Term unification
840
+ (r'unify_with_occurs_check(?=[(])', Keyword),
841
+ # Term creation and decomposition
842
+ (r'(functor|arg|copy_term)(?=[(])', Keyword),
843
+ # Evaluable functors
844
+ (r'(rem|mod|abs|sign)(?=[(])', Keyword),
845
+ (r'float(_(integer|fractional)_part)?(?=[(])', Keyword),
846
+ (r'(floor|truncate|round|ceiling)(?=[(])', Keyword),
847
+ # Other arithmetic functors
848
+ (r'(cos|atan|exp|log|s(in|qrt))(?=[(])', Keyword),
849
+ # Term testing
850
+ (r'(var|atom(ic)?|integer|float|compound|n(onvar|umber))(?=[(])',
851
+ Keyword),
852
+ # Stream selection and control
853
+ (r'(curren|se)t_(in|out)put(?=[(])', Keyword),
854
+ (r'(open|close)(?=[(])', Keyword),
855
+ (r'flush_output(?=[(])', Keyword),
856
+ (r'(at_end_of_stream|flush_output)\b', Keyword),
857
+ (r'(stream_property|at_end_of_stream|set_stream_position)(?=[(])',
858
+ Keyword),
859
+ # Character and byte input/output
860
+ (r'(nl|(get|peek|put)_(byte|c(har|ode)))(?=[(])', Keyword),
861
+ (r'\bnl\b', Keyword),
862
+ # Term input/output
863
+ (r'read(_term)?(?=[(])', Keyword),
864
+ (r'write(q|_(canonical|term))?(?=[(])', Keyword),
865
+ (r'(current_)?op(?=[(])', Keyword),
866
+ (r'(current_)?char_conversion(?=[(])', Keyword),
867
+ # Atomic term processing
868
+ (r'atom_(length|c(hars|o(ncat|des)))(?=[(])', Keyword),
869
+ (r'(char_code|sub_atom)(?=[(])', Keyword),
870
+ (r'number_c(har|ode)s(?=[(])', Keyword),
871
+ # Implementation defined hooks functions
872
+ (r'(se|curren)t_prolog_flag(?=[(])', Keyword),
873
+ (r'\bhalt\b', Keyword),
874
+ (r'halt(?=[(])', Keyword),
875
+ # Message sending operators
876
+ (r'(::|:|\^\^)', Operator),
877
+ # External call
878
+ (r'[{}]', Keyword),
879
+ # Logic and control
880
+ (r'\bonce(?=[(])', Keyword),
881
+ (r'\brepeat\b', Keyword),
882
+ # Bitwise functors
883
+ (r'(>>|<<|/\\|\\\\|\\)', Operator),
884
+ # Arithemtic evaluation
885
+ (r'\bis\b', Keyword),
886
+ # Arithemtic comparison
887
+ (r'(=:=|=\\=|<|=<|>=|>)', Operator),
888
+ # Term creation and decomposition
889
+ (r'=\.\.', Operator),
890
+ # Term unification
891
+ (r'(=|\\=)', Operator),
892
+ # Term comparison
893
+ (r'(==|\\==|@=<|@<|@>=|@>)', Operator),
894
+ # Evaluable functors
895
+ (r'(//|[-+*/])', Operator),
896
+ (r'\b(mod|rem)\b', Operator),
897
+ # Other arithemtic functors
898
+ (r'\b\*\*\b', Operator),
899
+ # DCG rules
900
+ (r'-->', Operator),
901
+ # Control constructs
902
+ (r'([!;]|->)', Operator),
903
+ # Logic and control
904
+ (r'\\+', Operator),
905
+ # Mode operators
906
+ (r'[?@]', Operator),
907
+ # Strings
908
+ (r'"(\\\\|\\"|[^"])*"', String),
909
+ # Ponctuation
910
+ (r'[()\[\],.|]', Text),
911
+ # Atoms
912
+ (r"[a-z][a-zA-Z0-9_]*", Text),
913
+ (r"[']", String, 'quoted_atom'),
914
+ ],
915
+
916
+ 'quoted_atom': [
917
+ (r"['][']", String),
918
+ (r"[']", String, '#pop'),
919
+ (r'\\([\\abfnrtv"\']|(x[a-fA-F0-9]+|[0-7]+)\\)', String.Escape),
920
+ (r"[^\\'\n]+", String),
921
+ (r'\\', String),
922
+ ],
923
+
924
+ 'directive': [
925
+ # Conditional compilation directives
926
+ (r'(el)?if(?=[(])', Keyword, 'root'),
927
+ (r'(e(lse|ndif))[.]', Keyword, 'root'),
928
+ # Entity directives
929
+ (r'(category|object|protocol)(?=[(])', Keyword, 'entityrelations'),
930
+ (r'(end_(category|object|protocol))[.]',Keyword, 'root'),
931
+ # Predicate scope directives
932
+ (r'(public|protected|private)(?=[(])', Keyword, 'root'),
933
+ # Other directives
934
+ (r'e(n(coding|sure_loaded)|xport)(?=[(])', Keyword, 'root'),
935
+ (r'in(fo|itialization)(?=[(])', Keyword, 'root'),
936
+ (r'(dynamic|synchronized|threaded)[.]', Keyword, 'root'),
937
+ (r'(alias|d(ynamic|iscontiguous)|m(eta_predicate|ode|ultifile)|'
938
+ r's(et_(logtalk|prolog)_flag|ynchronized))(?=[(])', Keyword, 'root'),
939
+ (r'op(?=[(])', Keyword, 'root'),
940
+ (r'(calls|reexport|use(s|_module))(?=[(])', Keyword, 'root'),
941
+ (r'[a-z][a-zA-Z0-9_]*(?=[(])', Text, 'root'),
942
+ (r'[a-z][a-zA-Z0-9_]*[.]', Text, 'root'),
943
+ ],
944
+
945
+ 'entityrelations': [
946
+ (r'(extends|i(nstantiates|mp(lements|orts))|specializes)(?=[(])',
947
+ Keyword),
948
+ # Numbers
949
+ (r"0'.", Number),
950
+ (r'0b[01]+', Number),
951
+ (r'0o[0-7]+', Number),
952
+ (r'0x[0-9a-fA-F]+', Number),
953
+ (r'\d+\.?\d*((e|E)(\+|-)?\d+)?', Number),
954
+ # Variables
955
+ (r'([A-Z_][a-zA-Z0-9_]*)', Name.Variable),
956
+ # Atoms
957
+ (r"[a-z][a-zA-Z0-9_]*", Text),
958
+ (r"[']", String, 'quoted_atom'),
959
+ # Strings
960
+ (r'"(\\\\|\\"|[^"])*"', String),
961
+ # End of entity-opening directive
962
+ (r'([)]\.)', Text, 'root'),
963
+ # Scope operator
964
+ (r'(::)', Operator),
965
+ # Ponctuation
966
+ (r'[()\[\],.|]', Text),
967
+ # Comments
968
+ (r'%.*?\n', Comment),
969
+ (r'/\*(.|\n)*?\*/',Comment),
970
+ # Whitespace
971
+ (r'\n', Text),
972
+ (r'\s+', Text),
973
+ ]
974
+ }
975
+
976
+ def analyse_text(text):
977
+ if ':- object(' in text:
978
+ return True
979
+ if ':- protocol(' in text:
980
+ return True
981
+ if ':- category(' in text:
982
+ return True
983
+ return False
984
+
985
+
986
+ def _shortened(word):
987
+ dpos = word.find('$')
988
+ return '|'.join([word[:dpos] + word[dpos+1:i] + r'\b'
989
+ for i in range(len(word), dpos, -1)])
990
+ def _shortened_many(*words):
991
+ return '|'.join(map(_shortened, words))
992
+
993
+ class GnuplotLexer(RegexLexer):
994
+ """
995
+ For `Gnuplot <http://gnuplot.info/>`_ plotting scripts.
996
+
997
+ *New in Pygments 0.11.*
998
+ """
999
+
1000
+ name = 'Gnuplot'
1001
+ aliases = ['gnuplot']
1002
+ filenames = ['*.plot', '*.plt']
1003
+ mimetypes = ['text/x-gnuplot']
1004
+
1005
+ tokens = {
1006
+ 'root': [
1007
+ include('whitespace'),
1008
+ (_shortened('bi$nd'), Keyword, 'bind'),
1009
+ (_shortened_many('ex$it', 'q$uit'), Keyword, 'quit'),
1010
+ (_shortened('f$it'), Keyword, 'fit'),
1011
+ (r'(if)(\s*)(\()', bygroups(Keyword, Text, Punctuation), 'if'),
1012
+ (r'else\b', Keyword),
1013
+ (_shortened('pa$use'), Keyword, 'pause'),
1014
+ (_shortened_many('p$lot', 'rep$lot', 'sp$lot'), Keyword, 'plot'),
1015
+ (_shortened('sa$ve'), Keyword, 'save'),
1016
+ (_shortened('se$t'), Keyword, ('genericargs', 'optionarg')),
1017
+ (_shortened_many('sh$ow', 'uns$et'),
1018
+ Keyword, ('noargs', 'optionarg')),
1019
+ (_shortened_many('low$er', 'ra$ise', 'ca$ll', 'cd$', 'cl$ear',
1020
+ 'h$elp', '\\?$', 'hi$story', 'l$oad', 'pr$int',
1021
+ 'pwd$', 're$read', 'res$et', 'scr$eendump',
1022
+ 'she$ll', 'sy$stem', 'up$date'),
1023
+ Keyword, 'genericargs'),
1024
+ (_shortened_many('pwd$', 're$read', 'res$et', 'scr$eendump',
1025
+ 'she$ll', 'test$'),
1026
+ Keyword, 'noargs'),
1027
+ ('([a-zA-Z_][a-zA-Z0-9_]*)(\s*)(=)',
1028
+ bygroups(Name.Variable, Text, Operator), 'genericargs'),
1029
+ ('([a-zA-Z_][a-zA-Z0-9_]*)(\s*\(.*?\)\s*)(=)',
1030
+ bygroups(Name.Function, Text, Operator), 'genericargs'),
1031
+ (r'@[a-zA-Z_][a-zA-Z0-9_]*', Name.Constant), # macros
1032
+ (r';', Keyword),
1033
+ ],
1034
+ 'comment': [
1035
+ (r'[^\\\n]', Comment),
1036
+ (r'\\\n', Comment),
1037
+ (r'\\', Comment),
1038
+ # don't add the newline to the Comment token
1039
+ ('', Comment, '#pop'),
1040
+ ],
1041
+ 'whitespace': [
1042
+ ('#', Comment, 'comment'),
1043
+ (r'[ \t\v\f]+', Text),
1044
+ ],
1045
+ 'noargs': [
1046
+ include('whitespace'),
1047
+ # semicolon and newline end the argument list
1048
+ (r';', Punctuation, '#pop'),
1049
+ (r'\n', Text, '#pop'),
1050
+ ],
1051
+ 'dqstring': [
1052
+ (r'"', String, '#pop'),
1053
+ (r'\\([\\abfnrtv"\']|x[a-fA-F0-9]{2,4}|[0-7]{1,3})', String.Escape),
1054
+ (r'[^\\"\n]+', String), # all other characters
1055
+ (r'\\\n', String), # line continuation
1056
+ (r'\\', String), # stray backslash
1057
+ (r'\n', String, '#pop'), # newline ends the string too
1058
+ ],
1059
+ 'sqstring': [
1060
+ (r"''", String), # escaped single quote
1061
+ (r"'", String, '#pop'),
1062
+ (r"[^\\'\n]+", String), # all other characters
1063
+ (r'\\\n', String), # line continuation
1064
+ (r'\\', String), # normal backslash
1065
+ (r'\n', String, '#pop'), # newline ends the string too
1066
+ ],
1067
+ 'genericargs': [
1068
+ include('noargs'),
1069
+ (r'"', String, 'dqstring'),
1070
+ (r"'", String, 'sqstring'),
1071
+ (r'(\d+\.\d*|\.\d+|\d+)[eE][+-]?\d+', Number.Float),
1072
+ (r'(\d+\.\d*|\.\d+)', Number.Float),
1073
+ (r'-?\d+', Number.Integer),
1074
+ ('[,.~!%^&*+=|?:<>/-]', Operator),
1075
+ ('[{}()\[\]]', Punctuation),
1076
+ (r'(eq|ne)\b', Operator.Word),
1077
+ (r'([a-zA-Z_][a-zA-Z0-9_]*)(\s*)(\()',
1078
+ bygroups(Name.Function, Text, Punctuation)),
1079
+ (r'[a-zA-Z_][a-zA-Z0-9_]*', Name),
1080
+ (r'@[a-zA-Z_][a-zA-Z0-9_]*', Name.Constant), # macros
1081
+ (r'\\\n', Text),
1082
+ ],
1083
+ 'optionarg': [
1084
+ include('whitespace'),
1085
+ (_shortened_many(
1086
+ "a$ll","an$gles","ar$row","au$toscale","b$ars","bor$der",
1087
+ "box$width","cl$abel","c$lip","cn$trparam","co$ntour","da$ta",
1088
+ "data$file","dg$rid3d","du$mmy","enc$oding","dec$imalsign",
1089
+ "fit$","font$path","fo$rmat","fu$nction","fu$nctions","g$rid",
1090
+ "hid$den3d","his$torysize","is$osamples","k$ey","keyt$itle",
1091
+ "la$bel","li$nestyle","ls$","loa$dpath","loc$ale","log$scale",
1092
+ "mac$ros","map$ping","map$ping3d","mar$gin","lmar$gin",
1093
+ "rmar$gin","tmar$gin","bmar$gin","mo$use","multi$plot",
1094
+ "mxt$ics","nomxt$ics","mx2t$ics","nomx2t$ics","myt$ics",
1095
+ "nomyt$ics","my2t$ics","nomy2t$ics","mzt$ics","nomzt$ics",
1096
+ "mcbt$ics","nomcbt$ics","of$fsets","or$igin","o$utput",
1097
+ "pa$rametric","pm$3d","pal$ette","colorb$ox","p$lot",
1098
+ "poi$ntsize","pol$ar","pr$int","obj$ect","sa$mples","si$ze",
1099
+ "st$yle","su$rface","table$","t$erminal","termo$ptions","ti$cs",
1100
+ "ticsc$ale","ticsl$evel","timef$mt","tim$estamp","tit$le",
1101
+ "v$ariables","ve$rsion","vi$ew","xyp$lane","xda$ta","x2da$ta",
1102
+ "yda$ta","y2da$ta","zda$ta","cbda$ta","xl$abel","x2l$abel",
1103
+ "yl$abel","y2l$abel","zl$abel","cbl$abel","xti$cs","noxti$cs",
1104
+ "x2ti$cs","nox2ti$cs","yti$cs","noyti$cs","y2ti$cs","noy2ti$cs",
1105
+ "zti$cs","nozti$cs","cbti$cs","nocbti$cs","xdti$cs","noxdti$cs",
1106
+ "x2dti$cs","nox2dti$cs","ydti$cs","noydti$cs","y2dti$cs",
1107
+ "noy2dti$cs","zdti$cs","nozdti$cs","cbdti$cs","nocbdti$cs",
1108
+ "xmti$cs","noxmti$cs","x2mti$cs","nox2mti$cs","ymti$cs",
1109
+ "noymti$cs","y2mti$cs","noy2mti$cs","zmti$cs","nozmti$cs",
1110
+ "cbmti$cs","nocbmti$cs","xr$ange","x2r$ange","yr$ange",
1111
+ "y2r$ange","zr$ange","cbr$ange","rr$ange","tr$ange","ur$ange",
1112
+ "vr$ange","xzeroa$xis","x2zeroa$xis","yzeroa$xis","y2zeroa$xis",
1113
+ "zzeroa$xis","zeroa$xis","z$ero"), Name.Builtin, '#pop'),
1114
+ ],
1115
+ 'bind': [
1116
+ ('!', Keyword, '#pop'),
1117
+ (_shortened('all$windows'), Name.Builtin),
1118
+ include('genericargs'),
1119
+ ],
1120
+ 'quit': [
1121
+ (r'gnuplot\b', Keyword),
1122
+ include('noargs'),
1123
+ ],
1124
+ 'fit': [
1125
+ (r'via\b', Name.Builtin),
1126
+ include('plot'),
1127
+ ],
1128
+ 'if': [
1129
+ (r'\)', Punctuation, '#pop'),
1130
+ include('genericargs'),
1131
+ ],
1132
+ 'pause': [
1133
+ (r'(mouse|any|button1|button2|button3)\b', Name.Builtin),
1134
+ (_shortened('key$press'), Name.Builtin),
1135
+ include('genericargs'),
1136
+ ],
1137
+ 'plot': [
1138
+ (_shortened_many('ax$es', 'axi$s', 'bin$ary', 'ev$ery', 'i$ndex',
1139
+ 'mat$rix', 's$mooth', 'thru$', 't$itle',
1140
+ 'not$itle', 'u$sing', 'w$ith'),
1141
+ Name.Builtin),
1142
+ include('genericargs'),
1143
+ ],
1144
+ 'save': [
1145
+ (_shortened_many('f$unctions', 's$et', 't$erminal', 'v$ariables'),
1146
+ Name.Builtin),
1147
+ include('genericargs'),
1148
+ ],
1149
+ }
1150
+
1151
+
1152
+ class PovrayLexer(RegexLexer):
1153
+ """
1154
+ For `Persistence of Vision Raytracer <http://www.povray.org/>`_ files.
1155
+
1156
+ *New in Pygments 0.11.*
1157
+ """
1158
+ name = 'POVRay'
1159
+ aliases = ['pov']
1160
+ filenames = ['*.pov', '*.inc']
1161
+ mimetypes = ['text/x-povray']
1162
+
1163
+ tokens = {
1164
+ 'root': [
1165
+ (r'/\*[\w\W]*?\*/', Comment.Multiline),
1166
+ (r'//.*\n', Comment.Single),
1167
+ (r'(?s)"(?:\\.|[^"\\])+"', String.Double),
1168
+ (r'#(debug|default|else|end|error|fclose|fopen|if|ifdef|ifndef|'
1169
+ r'include|range|read|render|statistics|switch|undef|version|'
1170
+ r'warning|while|write|define|macro|local|declare)',
1171
+ Comment.Preproc),
1172
+ (r'\b(aa_level|aa_threshold|abs|acos|acosh|adaptive|adc_bailout|'
1173
+ r'agate|agate_turb|all|alpha|ambient|ambient_light|angle|'
1174
+ r'aperture|arc_angle|area_light|asc|asin|asinh|assumed_gamma|'
1175
+ r'atan|atan2|atanh|atmosphere|atmospheric_attenuation|'
1176
+ r'attenuating|average|background|black_hole|blue|blur_samples|'
1177
+ r'bounded_by|box_mapping|bozo|break|brick|brick_size|'
1178
+ r'brightness|brilliance|bumps|bumpy1|bumpy2|bumpy3|bump_map|'
1179
+ r'bump_size|case|caustics|ceil|checker|chr|clipped_by|clock|'
1180
+ r'color|color_map|colour|colour_map|component|composite|concat|'
1181
+ r'confidence|conic_sweep|constant|control0|control1|cos|cosh|'
1182
+ r'count|crackle|crand|cube|cubic_spline|cylindrical_mapping|'
1183
+ r'debug|declare|default|degrees|dents|diffuse|direction|'
1184
+ r'distance|distance_maximum|div|dust|dust_type|eccentricity|'
1185
+ r'else|emitting|end|error|error_bound|exp|exponent|'
1186
+ r'fade_distance|fade_power|falloff|falloff_angle|false|'
1187
+ r'file_exists|filter|finish|fisheye|flatness|flip|floor|'
1188
+ r'focal_point|fog|fog_alt|fog_offset|fog_type|frequency|gif|'
1189
+ r'global_settings|glowing|gradient|granite|gray_threshold|'
1190
+ r'green|halo|hexagon|hf_gray_16|hierarchy|hollow|hypercomplex|'
1191
+ r'if|ifdef|iff|image_map|incidence|include|int|interpolate|'
1192
+ r'inverse|ior|irid|irid_wavelength|jitter|lambda|leopard|'
1193
+ r'linear|linear_spline|linear_sweep|location|log|looks_like|'
1194
+ r'look_at|low_error_factor|mandel|map_type|marble|material_map|'
1195
+ r'matrix|max|max_intersections|max_iteration|max_trace_level|'
1196
+ r'max_value|metallic|min|minimum_reuse|mod|mortar|'
1197
+ r'nearest_count|no|normal|normal_map|no_shadow|number_of_waves|'
1198
+ r'octaves|off|offset|omega|omnimax|on|once|onion|open|'
1199
+ r'orthographic|panoramic|pattern1|pattern2|pattern3|'
1200
+ r'perspective|pgm|phase|phong|phong_size|pi|pigment|'
1201
+ r'pigment_map|planar_mapping|png|point_at|pot|pow|ppm|'
1202
+ r'precision|pwr|quadratic_spline|quaternion|quick_color|'
1203
+ r'quick_colour|quilted|radial|radians|radiosity|radius|rainbow|'
1204
+ r'ramp_wave|rand|range|reciprocal|recursion_limit|red|'
1205
+ r'reflection|refraction|render|repeat|rgb|rgbf|rgbft|rgbt|'
1206
+ r'right|ripples|rotate|roughness|samples|scale|scallop_wave|'
1207
+ r'scattering|seed|shadowless|sin|sine_wave|sinh|sky|sky_sphere|'
1208
+ r'slice|slope_map|smooth|specular|spherical_mapping|spiral|'
1209
+ r'spiral1|spiral2|spotlight|spotted|sqr|sqrt|statistics|str|'
1210
+ r'strcmp|strength|strlen|strlwr|strupr|sturm|substr|switch|sys|'
1211
+ r't|tan|tanh|test_camera_1|test_camera_2|test_camera_3|'
1212
+ r'test_camera_4|texture|texture_map|tga|thickness|threshold|'
1213
+ r'tightness|tile2|tiles|track|transform|translate|transmit|'
1214
+ r'triangle_wave|true|ttf|turbulence|turb_depth|type|'
1215
+ r'ultra_wide_angle|up|use_color|use_colour|use_index|u_steps|'
1216
+ r'val|variance|vaxis_rotate|vcross|vdot|version|vlength|'
1217
+ r'vnormalize|volume_object|volume_rendered|vol_with_light|'
1218
+ r'vrotate|v_steps|warning|warp|water_level|waves|while|width|'
1219
+ r'wood|wrinkles|yes)\b', Keyword),
1220
+ (r'bicubic_patch|blob|box|camera|cone|cubic|cylinder|difference|'
1221
+ r'disc|height_field|intersection|julia_fractal|lathe|'
1222
+ r'light_source|merge|mesh|object|plane|poly|polygon|prism|'
1223
+ r'quadric|quartic|smooth_triangle|sor|sphere|superellipsoid|'
1224
+ r'text|torus|triangle|union', Name.Builtin),
1225
+ # TODO: <=, etc
1226
+ (r'[\[\](){}<>;,]', Punctuation),
1227
+ (r'[-+*/=]', Operator),
1228
+ (r'\b(x|y|z|u|v)\b', Name.Builtin.Pseudo),
1229
+ (r'[a-zA-Z_][a-zA-Z_0-9]*', Name),
1230
+ (r'[0-9]+\.[0-9]*', Number.Float),
1231
+ (r'\.[0-9]+', Number.Float),
1232
+ (r'[0-9]+', Number.Integer),
1233
+ (r'\s+', Text),
1234
+ ]
1235
+ }
1236
+
1237
+
1238
+ class AppleScriptLexer(RegexLexer):
1239
+ """
1240
+ For `AppleScript source code
1241
+ <http://developer.apple.com/documentation/AppleScript/
1242
+ Conceptual/AppleScriptLangGuide>`_,
1243
+ including `AppleScript Studio
1244
+ <http://developer.apple.com/documentation/AppleScript/
1245
+ Reference/StudioReference>`_.
1246
+ Contributed by Andreas Amann <aamann@mac.com>.
1247
+ """
1248
+
1249
+ name = 'AppleScript'
1250
+ aliases = ['applescript']
1251
+ filenames = ['*.applescript']
1252
+
1253
+ flags = re.MULTILINE | re.DOTALL
1254
+
1255
+ Identifiers = r'[a-zA-Z]\w*'
1256
+ Literals = ['AppleScript', 'current application', 'false', 'linefeed',
1257
+ 'missing value', 'pi','quote', 'result', 'return', 'space',
1258
+ 'tab', 'text item delimiters', 'true', 'version']
1259
+ Classes = ['alias ', 'application ', 'boolean ', 'class ', 'constant ',
1260
+ 'date ', 'file ', 'integer ', 'list ', 'number ', 'POSIX file ',
1261
+ 'real ', 'record ', 'reference ', 'RGB color ', 'script ',
1262
+ 'text ', 'unit types', '(Unicode )?text', 'string']
1263
+ BuiltIn = ['attachment', 'attribute run', 'character', 'day', 'month',
1264
+ 'paragraph', 'word', 'year']
1265
+ HandlerParams = ['about', 'above', 'against', 'apart from', 'around',
1266
+ 'aside from', 'at', 'below', 'beneath', 'beside',
1267
+ 'between', 'for', 'given', 'instead of', 'on', 'onto',
1268
+ 'out of', 'over', 'since']
1269
+ Commands = ['ASCII (character|number)', 'activate', 'beep', 'choose URL',
1270
+ 'choose application', 'choose color', 'choose file( name)?',
1271
+ 'choose folder', 'choose from list',
1272
+ 'choose remote application', 'clipboard info',
1273
+ 'close( access)?', 'copy', 'count', 'current date', 'delay',
1274
+ 'delete', 'display (alert|dialog)', 'do shell script',
1275
+ 'duplicate', 'exists', 'get eof', 'get volume settings',
1276
+ 'info for', 'launch', 'list (disks|folder)', 'load script',
1277
+ 'log', 'make', 'mount volume', 'new', 'offset',
1278
+ 'open( (for access|location))?', 'path to', 'print', 'quit',
1279
+ 'random number', 'read', 'round', 'run( script)?',
1280
+ 'say', 'scripting components',
1281
+ 'set (eof|the clipboard to|volume)', 'store script',
1282
+ 'summarize', 'system attribute', 'system info',
1283
+ 'the clipboard', 'time to GMT', 'write', 'quoted form']
1284
+ References = ['(in )?back of', '(in )?front of', '[0-9]+(st|nd|rd|th)',
1285
+ 'first', 'second', 'third', 'fourth', 'fifth', 'sixth',
1286
+ 'seventh', 'eighth', 'ninth', 'tenth', 'after', 'back',
1287
+ 'before', 'behind', 'every', 'front', 'index', 'last',
1288
+ 'middle', 'some', 'that', 'through', 'thru', 'where', 'whose']
1289
+ Operators = ["and", "or", "is equal", "equals", "(is )?equal to", "is not",
1290
+ "isn't", "isn't equal( to)?", "is not equal( to)?",
1291
+ "doesn't equal", "does not equal", "(is )?greater than",
1292
+ "comes after", "is not less than or equal( to)?",
1293
+ "isn't less than or equal( to)?", "(is )?less than",
1294
+ "comes before", "is not greater than or equal( to)?",
1295
+ "isn't greater than or equal( to)?",
1296
+ "(is )?greater than or equal( to)?", "is not less than",
1297
+ "isn't less than", "does not come before",
1298
+ "doesn't come before", "(is )?less than or equal( to)?",
1299
+ "is not greater than", "isn't greater than",
1300
+ "does not come after", "doesn't come after", "starts? with",
1301
+ "begins? with", "ends? with", "contains?", "does not contain",
1302
+ "doesn't contain", "is in", "is contained by", "is not in",
1303
+ "is not contained by", "isn't contained by", "div", "mod",
1304
+ "not", "(a )?(ref( to)?|reference to)", "is", "does"]
1305
+ Control = ['considering', 'else', 'error', 'exit', 'from', 'if',
1306
+ 'ignoring', 'in', 'repeat', 'tell', 'then', 'times', 'to',
1307
+ 'try', 'until', 'using terms from', 'while', 'whith',
1308
+ 'with timeout( of)?', 'with transaction', 'by', 'continue',
1309
+ 'end', 'its?', 'me', 'my', 'return', 'of' , 'as']
1310
+ Declarations = ['global', 'local', 'prop(erty)?', 'set', 'get']
1311
+ Reserved = ['but', 'put', 'returning', 'the']
1312
+ StudioClasses = ['action cell', 'alert reply', 'application', 'box',
1313
+ 'browser( cell)?', 'bundle', 'button( cell)?', 'cell',
1314
+ 'clip view', 'color well', 'color-panel',
1315
+ 'combo box( item)?', 'control',
1316
+ 'data( (cell|column|item|row|source))?', 'default entry',
1317
+ 'dialog reply', 'document', 'drag info', 'drawer',
1318
+ 'event', 'font(-panel)?', 'formatter',
1319
+ 'image( (cell|view))?', 'matrix', 'menu( item)?', 'item',
1320
+ 'movie( view)?', 'open-panel', 'outline view', 'panel',
1321
+ 'pasteboard', 'plugin', 'popup button',
1322
+ 'progress indicator', 'responder', 'save-panel',
1323
+ 'scroll view', 'secure text field( cell)?', 'slider',
1324
+ 'sound', 'split view', 'stepper', 'tab view( item)?',
1325
+ 'table( (column|header cell|header view|view))',
1326
+ 'text( (field( cell)?|view))?', 'toolbar( item)?',
1327
+ 'user-defaults', 'view', 'window']
1328
+ StudioEvents = ['accept outline drop', 'accept table drop', 'action',
1329
+ 'activated', 'alert ended', 'awake from nib', 'became key',
1330
+ 'became main', 'begin editing', 'bounds changed',
1331
+ 'cell value', 'cell value changed', 'change cell value',
1332
+ 'change item value', 'changed', 'child of item',
1333
+ 'choose menu item', 'clicked', 'clicked toolbar item',
1334
+ 'closed', 'column clicked', 'column moved',
1335
+ 'column resized', 'conclude drop', 'data representation',
1336
+ 'deminiaturized', 'dialog ended', 'document nib name',
1337
+ 'double clicked', 'drag( (entered|exited|updated))?',
1338
+ 'drop', 'end editing', 'exposed', 'idle', 'item expandable',
1339
+ 'item value', 'item value changed', 'items changed',
1340
+ 'keyboard down', 'keyboard up', 'launched',
1341
+ 'load data representation', 'miniaturized', 'mouse down',
1342
+ 'mouse dragged', 'mouse entered', 'mouse exited',
1343
+ 'mouse moved', 'mouse up', 'moved',
1344
+ 'number of browser rows', 'number of items',
1345
+ 'number of rows', 'open untitled', 'opened', 'panel ended',
1346
+ 'parameters updated', 'plugin loaded', 'prepare drop',
1347
+ 'prepare outline drag', 'prepare outline drop',
1348
+ 'prepare table drag', 'prepare table drop',
1349
+ 'read from file', 'resigned active', 'resigned key',
1350
+ 'resigned main', 'resized( sub views)?',
1351
+ 'right mouse down', 'right mouse dragged',
1352
+ 'right mouse up', 'rows changed', 'scroll wheel',
1353
+ 'selected tab view item', 'selection changed',
1354
+ 'selection changing', 'should begin editing',
1355
+ 'should close', 'should collapse item',
1356
+ 'should end editing', 'should expand item',
1357
+ 'should open( untitled)?',
1358
+ 'should quit( after last window closed)?',
1359
+ 'should select column', 'should select item',
1360
+ 'should select row', 'should select tab view item',
1361
+ 'should selection change', 'should zoom', 'shown',
1362
+ 'update menu item', 'update parameters',
1363
+ 'update toolbar item', 'was hidden', 'was miniaturized',
1364
+ 'will become active', 'will close', 'will dismiss',
1365
+ 'will display browser cell', 'will display cell',
1366
+ 'will display item cell', 'will display outline cell',
1367
+ 'will finish launching', 'will hide', 'will miniaturize',
1368
+ 'will move', 'will open', 'will pop up', 'will quit',
1369
+ 'will resign active', 'will resize( sub views)?',
1370
+ 'will select tab view item', 'will show', 'will zoom',
1371
+ 'write to file', 'zoomed']
1372
+ StudioCommands = ['animate', 'append', 'call method', 'center',
1373
+ 'close drawer', 'close panel', 'display',
1374
+ 'display alert', 'display dialog', 'display panel', 'go',
1375
+ 'hide', 'highlight', 'increment', 'item for',
1376
+ 'load image', 'load movie', 'load nib', 'load panel',
1377
+ 'load sound', 'localized string', 'lock focus', 'log',
1378
+ 'open drawer', 'path for', 'pause', 'perform action',
1379
+ 'play', 'register', 'resume', 'scroll', 'select( all)?',
1380
+ 'show', 'size to fit', 'start', 'step back',
1381
+ 'step forward', 'stop', 'synchronize', 'unlock focus',
1382
+ 'update']
1383
+ StudioProperties = ['accepts arrow key', 'action method', 'active',
1384
+ 'alignment', 'allowed identifiers',
1385
+ 'allows branch selection', 'allows column reordering',
1386
+ 'allows column resizing', 'allows column selection',
1387
+ 'allows customization',
1388
+ 'allows editing text attributes',
1389
+ 'allows empty selection', 'allows mixed state',
1390
+ 'allows multiple selection', 'allows reordering',
1391
+ 'allows undo', 'alpha( value)?', 'alternate image',
1392
+ 'alternate increment value', 'alternate title',
1393
+ 'animation delay', 'associated file name',
1394
+ 'associated object', 'auto completes', 'auto display',
1395
+ 'auto enables items', 'auto repeat',
1396
+ 'auto resizes( outline column)?',
1397
+ 'auto save expanded items', 'auto save name',
1398
+ 'auto save table columns', 'auto saves configuration',
1399
+ 'auto scroll', 'auto sizes all columns to fit',
1400
+ 'auto sizes cells', 'background color', 'bezel state',
1401
+ 'bezel style', 'bezeled', 'border rect', 'border type',
1402
+ 'bordered', 'bounds( rotation)?', 'box type',
1403
+ 'button returned', 'button type',
1404
+ 'can choose directories', 'can choose files',
1405
+ 'can draw', 'can hide',
1406
+ 'cell( (background color|size|type))?', 'characters',
1407
+ 'class', 'click count', 'clicked( data)? column',
1408
+ 'clicked data item', 'clicked( data)? row',
1409
+ 'closeable', 'collating', 'color( (mode|panel))',
1410
+ 'command key down', 'configuration',
1411
+ 'content(s| (size|view( margins)?))?', 'context',
1412
+ 'continuous', 'control key down', 'control size',
1413
+ 'control tint', 'control view',
1414
+ 'controller visible', 'coordinate system',
1415
+ 'copies( on scroll)?', 'corner view', 'current cell',
1416
+ 'current column', 'current( field)? editor',
1417
+ 'current( menu)? item', 'current row',
1418
+ 'current tab view item', 'data source',
1419
+ 'default identifiers', 'delta (x|y|z)',
1420
+ 'destination window', 'directory', 'display mode',
1421
+ 'displayed cell', 'document( (edited|rect|view))?',
1422
+ 'double value', 'dragged column', 'dragged distance',
1423
+ 'dragged items', 'draws( cell)? background',
1424
+ 'draws grid', 'dynamically scrolls', 'echos bullets',
1425
+ 'edge', 'editable', 'edited( data)? column',
1426
+ 'edited data item', 'edited( data)? row', 'enabled',
1427
+ 'enclosing scroll view', 'ending page',
1428
+ 'error handling', 'event number', 'event type',
1429
+ 'excluded from windows menu', 'executable path',
1430
+ 'expanded', 'fax number', 'field editor', 'file kind',
1431
+ 'file name', 'file type', 'first responder',
1432
+ 'first visible column', 'flipped', 'floating',
1433
+ 'font( panel)?', 'formatter', 'frameworks path',
1434
+ 'frontmost', 'gave up', 'grid color', 'has data items',
1435
+ 'has horizontal ruler', 'has horizontal scroller',
1436
+ 'has parent data item', 'has resize indicator',
1437
+ 'has shadow', 'has sub menu', 'has vertical ruler',
1438
+ 'has vertical scroller', 'header cell', 'header view',
1439
+ 'hidden', 'hides when deactivated', 'highlights by',
1440
+ 'horizontal line scroll', 'horizontal page scroll',
1441
+ 'horizontal ruler view', 'horizontally resizable',
1442
+ 'icon image', 'id', 'identifier',
1443
+ 'ignores multiple clicks',
1444
+ 'image( (alignment|dims when disabled|frame style|'
1445
+ 'scaling))?',
1446
+ 'imports graphics', 'increment value',
1447
+ 'indentation per level', 'indeterminate', 'index',
1448
+ 'integer value', 'intercell spacing', 'item height',
1449
+ 'key( (code|equivalent( modifier)?|window))?',
1450
+ 'knob thickness', 'label', 'last( visible)? column',
1451
+ 'leading offset', 'leaf', 'level', 'line scroll',
1452
+ 'loaded', 'localized sort', 'location', 'loop mode',
1453
+ 'main( (bunde|menu|window))?', 'marker follows cell',
1454
+ 'matrix mode', 'maximum( content)? size',
1455
+ 'maximum visible columns',
1456
+ 'menu( form representation)?', 'miniaturizable',
1457
+ 'miniaturized', 'minimized image', 'minimized title',
1458
+ 'minimum column width', 'minimum( content)? size',
1459
+ 'modal', 'modified', 'mouse down state',
1460
+ 'movie( (controller|file|rect))?', 'muted', 'name',
1461
+ 'needs display', 'next state', 'next text',
1462
+ 'number of tick marks', 'only tick mark values',
1463
+ 'opaque', 'open panel', 'option key down',
1464
+ 'outline table column', 'page scroll', 'pages across',
1465
+ 'pages down', 'palette label', 'pane splitter',
1466
+ 'parent data item', 'parent window', 'pasteboard',
1467
+ 'path( (names|separator))?', 'playing',
1468
+ 'plays every frame', 'plays selection only', 'position',
1469
+ 'preferred edge', 'preferred type', 'pressure',
1470
+ 'previous text', 'prompt', 'properties',
1471
+ 'prototype cell', 'pulls down', 'rate',
1472
+ 'released when closed', 'repeated',
1473
+ 'requested print time', 'required file type',
1474
+ 'resizable', 'resized column', 'resource path',
1475
+ 'returns records', 'reuses columns', 'rich text',
1476
+ 'roll over', 'row height', 'rulers visible',
1477
+ 'save panel', 'scripts path', 'scrollable',
1478
+ 'selectable( identifiers)?', 'selected cell',
1479
+ 'selected( data)? columns?', 'selected data items?',
1480
+ 'selected( data)? rows?', 'selected item identifier',
1481
+ 'selection by rect', 'send action on arrow key',
1482
+ 'sends action when done editing', 'separates columns',
1483
+ 'separator item', 'sequence number', 'services menu',
1484
+ 'shared frameworks path', 'shared support path',
1485
+ 'sheet', 'shift key down', 'shows alpha',
1486
+ 'shows state by', 'size( mode)?',
1487
+ 'smart insert delete enabled', 'sort case sensitivity',
1488
+ 'sort column', 'sort order', 'sort type',
1489
+ 'sorted( data rows)?', 'sound', 'source( mask)?',
1490
+ 'spell checking enabled', 'starting page', 'state',
1491
+ 'string value', 'sub menu', 'super menu', 'super view',
1492
+ 'tab key traverses cells', 'tab state', 'tab type',
1493
+ 'tab view', 'table view', 'tag', 'target( printer)?',
1494
+ 'text color', 'text container insert',
1495
+ 'text container origin', 'text returned',
1496
+ 'tick mark position', 'time stamp',
1497
+ 'title(d| (cell|font|height|position|rect))?',
1498
+ 'tool tip', 'toolbar', 'trailing offset', 'transparent',
1499
+ 'treat packages as directories', 'truncated labels',
1500
+ 'types', 'unmodified characters', 'update views',
1501
+ 'use sort indicator', 'user defaults',
1502
+ 'uses data source', 'uses ruler',
1503
+ 'uses threaded animation',
1504
+ 'uses title from previous column', 'value wraps',
1505
+ 'version',
1506
+ 'vertical( (line scroll|page scroll|ruler view))?',
1507
+ 'vertically resizable', 'view',
1508
+ 'visible( document rect)?', 'volume', 'width', 'window',
1509
+ 'windows menu', 'wraps', 'zoomable', 'zoomed']
1510
+
1511
+ tokens = {
1512
+ 'root': [
1513
+ (r'\s+', Text),
1514
+ (ur'¬\n', String.Escape),
1515
+ (r"'s\s+", Text), # This is a possessive, consider moving
1516
+ (r'(--|#).*?$', Comment),
1517
+ (r'\(\*', Comment.Multiline, 'comment'),
1518
+ (r'[\(\){}!,.:]', Punctuation),
1519
+ (ur'(«)([^»]+)(»)',
1520
+ bygroups(Text, Name.Builtin, Text)),
1521
+ (r'\b((?:considering|ignoring)\s*)'
1522
+ r'(application responses|case|diacriticals|hyphens|'
1523
+ r'numeric strings|punctuation|white space)',
1524
+ bygroups(Keyword, Name.Builtin)),
1525
+ (ur'(-|\*|\+|&|≠|>=?|<=?|=|≥|≤|/|÷|\^)', Operator),
1526
+ (r"\b(%s)\b" % '|'.join(Operators), Operator.Word),
1527
+ (r'^(\s*(?:on|end)\s+)'
1528
+ r'(%s)' % '|'.join(StudioEvents),
1529
+ bygroups(Keyword, Name.Function)),
1530
+ (r'^(\s*)(in|on|script|to)(\s+)', bygroups(Text, Keyword, Text)),
1531
+ (r'\b(as )(%s)\b' % '|'.join(Classes),
1532
+ bygroups(Keyword, Name.Class)),
1533
+ (r'\b(%s)\b' % '|'.join(Literals), Name.Constant),
1534
+ (r'\b(%s)\b' % '|'.join(Commands), Name.Builtin),
1535
+ (r'\b(%s)\b' % '|'.join(Control), Keyword),
1536
+ (r'\b(%s)\b' % '|'.join(Declarations), Keyword),
1537
+ (r'\b(%s)\b' % '|'.join(Reserved), Name.Builtin),
1538
+ (r'\b(%s)s?\b' % '|'.join(BuiltIn), Name.Builtin),
1539
+ (r'\b(%s)\b' % '|'.join(HandlerParams), Name.Builtin),
1540
+ (r'\b(%s)\b' % '|'.join(StudioProperties), Name.Attribute),
1541
+ (r'\b(%s)s?\b' % '|'.join(StudioClasses), Name.Builtin),
1542
+ (r'\b(%s)\b' % '|'.join(StudioCommands), Name.Builtin),
1543
+ (r'\b(%s)\b' % '|'.join(References), Name.Builtin),
1544
+ (r'"(\\\\|\\"|[^"])*"', String.Double),
1545
+ (r'\b(%s)\b' % Identifiers, Name.Variable),
1546
+ (r'[-+]?(\d+\.\d*|\d*\.\d+)(E[-+][0-9]+)?', Number.Float),
1547
+ (r'[-+]?\d+', Number.Integer),
1548
+ ],
1549
+ 'comment': [
1550
+ ('\(\*', Comment.Multiline, '#push'),
1551
+ ('\*\)', Comment.Multiline, '#pop'),
1552
+ ('[^*(]+', Comment.Multiline),
1553
+ ('[*(]', Comment.Multiline),
1554
+ ],
1555
+ }
1556
+
1557
+
1558
+ class ModelicaLexer(RegexLexer):
1559
+ """
1560
+ For `Modelica <http://www.modelica.org/>`_ source code.
1561
+
1562
+ *New in Pygments 1.1.*
1563
+ """
1564
+ name = 'Modelica'
1565
+ aliases = ['modelica']
1566
+ filenames = ['*.mo']
1567
+ mimetypes = ['text/x-modelica']
1568
+
1569
+ flags = re.IGNORECASE | re.DOTALL
1570
+
1571
+ tokens = {
1572
+ 'whitespace': [
1573
+ (r'\n', Text),
1574
+ (r'\s+', Text),
1575
+ (r'\\\n', Text), # line continuation
1576
+ (r'//(\n|(.|\n)*?[^\\]\n)', Comment),
1577
+ (r'/(\\\n)?[*](.|\n)*?[*](\\\n)?/', Comment),
1578
+ ],
1579
+ 'statements': [
1580
+ (r'"', String, 'string'),
1581
+ (r'(\d+\.\d*|\.\d+|\d+|\d.)[eE][+-]?\d+[lL]?', Number.Float),
1582
+ (r'(\d+\.\d*|\.\d+)', Number.Float),
1583
+ (r'\d+[Ll]?', Number.Integer),
1584
+ (r'[~!%^&*+=|?:<>/-]', Operator),
1585
+ (r'[()\[\]{},.;]', Punctuation),
1586
+ (r'(true|false|NULL|Real|Integer|Boolean)\b', Name.Builtin),
1587
+ (r"([a-zA-Z_][\w]*|'[a-zA-Z_\+\-\*\/\^][\w]*')"
1588
+ r"(\.([a-zA-Z_][\w]*|'[a-zA-Z_\+\-\*\/\^][\w]*'))+", Name.Class),
1589
+ (r"('[\w\+\-\*\/\^]+'|\w+)", Name) ],
1590
+ 'root': [
1591
+ include('whitespace'),
1592
+ include('keywords'),
1593
+ include('functions'),
1594
+ include('operators'),
1595
+ include('classes'),
1596
+ (r'("<html>|<html>)', Name.Tag, 'html-content'),
1597
+ include('statements')
1598
+ ],
1599
+ 'keywords': [
1600
+ (r'(algorithm|annotation|break|connect|constant|constrainedby|'
1601
+ r'discrete|each|else|elseif|elsewhen|encapsulated|enumeration|'
1602
+ r'end|equation|exit|expandable|extends|'
1603
+ r'external|false|final|flow|for|if|import|in|inner|input|'
1604
+ r'loop|nondiscrete|outer|output|parameter|partial|'
1605
+ r'protected|public|redeclare|replaceable|stream|time|then|true|'
1606
+ r'when|while|within)\b', Keyword)
1607
+ ],
1608
+ 'functions': [
1609
+ (r'(abs|acos|acosh|asin|asinh|atan|atan2|atan3|ceil|cos|cosh|'
1610
+ r'cross|div|exp|floor|log|log10|mod|rem|sign|sin|sinh|size|'
1611
+ r'sqrt|tan|tanh|zeros)\b', Name.Function)
1612
+ ],
1613
+ 'operators': [
1614
+ (r'(and|assert|cardinality|change|delay|der|edge|initial|'
1615
+ r'noEvent|not|or|pre|reinit|return|sample|smooth|'
1616
+ r'terminal|terminate)\b', Name.Builtin)
1617
+ ],
1618
+ 'classes': [
1619
+ (r'(block|class|connector|function|model|package|'
1620
+ r'record|type)\b', Name.Class)
1621
+ ],
1622
+ 'string': [
1623
+ (r'"', String, '#pop'),
1624
+ (r'\\([\\abfnrtv"\']|x[a-fA-F0-9]{2,4}|[0-7]{1,3})',
1625
+ String.Escape),
1626
+ (r'[^\\"\n]+', String), # all other characters
1627
+ (r'\\\n', String), # line continuation
1628
+ (r'\\', String) # stray backslash
1629
+ ],
1630
+ 'html-content': [
1631
+ (r'<\s*/\s*html\s*>', Name.Tag, '#pop'),
1632
+ (r'.+?(?=<\s*/\s*html\s*>)', using(HtmlLexer)),
1633
+ ]
1634
+ }
1635
+
1636
+
1637
+ class RebolLexer(RegexLexer):
1638
+ """
1639
+ A `REBOL <http://www.rebol.com/>`_ lexer.
1640
+
1641
+ *New in Pygments 1.1.*
1642
+ """
1643
+ name = 'REBOL'
1644
+ aliases = ['rebol']
1645
+ filenames = ['*.r', '*.r3']
1646
+ mimetypes = ['text/x-rebol']
1647
+
1648
+ flags = re.IGNORECASE | re.MULTILINE
1649
+
1650
+ re.IGNORECASE
1651
+
1652
+ escape_re = r'(?:\^\([0-9a-fA-F]{1,4}\)*)'
1653
+
1654
+ def word_callback(lexer, match):
1655
+ word = match.group()
1656
+
1657
+ if re.match(".*:$", word):
1658
+ yield match.start(), Generic.Subheading, word
1659
+ elif re.match(
1660
+ r'(native|alias|all|any|as-string|as-binary|bind|bound\?|case|'
1661
+ r'catch|checksum|comment|debase|dehex|exclude|difference|disarm|'
1662
+ r'either|else|enbase|foreach|remove-each|form|free|get|get-env|if|'
1663
+ r'in|intersect|loop|minimum-of|maximum-of|mold|new-line|'
1664
+ r'new-line\?|not|now|prin|print|reduce|compose|construct|repeat|'
1665
+ r'reverse|save|script\?|set|shift|switch|throw|to-hex|trace|try|'
1666
+ r'type\?|union|unique|unless|unprotect|unset|until|use|value\?|'
1667
+ r'while|compress|decompress|secure|open|close|read|read-io|'
1668
+ r'write-io|write|update|query|wait|input\?|exp|log-10|log-2|'
1669
+ r'log-e|square-root|cosine|sine|tangent|arccosine|arcsine|'
1670
+ r'arctangent|protect|lowercase|uppercase|entab|detab|connected\?|'
1671
+ r'browse|launch|stats|get-modes|set-modes|to-local-file|'
1672
+ r'to-rebol-file|encloak|decloak|create-link|do-browser|bind\?|'
1673
+ r'hide|draw|show|size-text|textinfo|offset-to-caret|'
1674
+ r'caret-to-offset|local-request-file|rgb-to-hsv|hsv-to-rgb|'
1675
+ r'crypt-strength\?|dh-make-key|dh-generate-key|dh-compute-key|'
1676
+ r'dsa-make-key|dsa-generate-key|dsa-make-signature|'
1677
+ r'dsa-verify-signature|rsa-make-key|rsa-generate-key|'
1678
+ r'rsa-encrypt)$', word):
1679
+ yield match.start(), Name.Builtin, word
1680
+ elif re.match(
1681
+ r'(add|subtract|multiply|divide|remainder|power|and~|or~|xor~|'
1682
+ r'minimum|maximum|negate|complement|absolute|random|head|tail|'
1683
+ r'next|back|skip|at|pick|first|second|third|fourth|fifth|sixth|'
1684
+ r'seventh|eighth|ninth|tenth|last|path|find|select|make|to|copy\*|'
1685
+ r'insert|remove|change|poke|clear|trim|sort|min|max|abs|cp|'
1686
+ r'copy)$', word):
1687
+ yield match.start(), Name.Function, word
1688
+ elif re.match(
1689
+ r'(error|source|input|license|help|install|echo|Usage|with|func|'
1690
+ r'throw-on-error|function|does|has|context|probe|\?\?|as-pair|'
1691
+ r'mod|modulo|round|repend|about|set-net|append|join|rejoin|reform|'
1692
+ r'remold|charset|array|replace|move|extract|forskip|forall|alter|'
1693
+ r'first+|also|take|for|forever|dispatch|attempt|what-dir|'
1694
+ r'change-dir|clean-path|list-dir|dirize|rename|split-path|delete|'
1695
+ r'make-dir|delete-dir|in-dir|confirm|dump-obj|upgrade|what|'
1696
+ r'build-tag|process-source|build-markup|decode-cgi|read-cgi|'
1697
+ r'write-user|save-user|set-user-name|protect-system|parse-xml|'
1698
+ r'cvs-date|cvs-version|do-boot|get-net-info|desktop|layout|'
1699
+ r'scroll-para|get-face|alert|set-face|uninstall|unfocus|'
1700
+ r'request-dir|center-face|do-events|net-error|decode-url|'
1701
+ r'parse-header|parse-header-date|parse-email-addrs|import-email|'
1702
+ r'send|build-attach-body|resend|show-popup|hide-popup|open-events|'
1703
+ r'find-key-face|do-face|viewtop|confine|find-window|'
1704
+ r'insert-event-func|remove-event-func|inform|dump-pane|dump-face|'
1705
+ r'flag-face|deflag-face|clear-fields|read-net|vbug|path-thru|'
1706
+ r'read-thru|load-thru|do-thru|launch-thru|load-image|'
1707
+ r'request-download|do-face-alt|set-font|set-para|get-style|'
1708
+ r'set-style|make-face|stylize|choose|hilight-text|hilight-all|'
1709
+ r'unlight-text|focus|scroll-drag|clear-face|reset-face|scroll-face|'
1710
+ r'resize-face|load-stock|load-stock-block|notify|request|flash|'
1711
+ r'request-color|request-pass|request-text|request-list|'
1712
+ r'request-date|request-file|dbug|editor|link-relative-path|'
1713
+ r'emailer|parse-error)$', word):
1714
+ yield match.start(), Keyword.Namespace, word
1715
+ elif re.match(
1716
+ r'(halt|quit|do|load|q|recycle|call|run|ask|parse|view|unview|'
1717
+ r'return|exit|break)$', word):
1718
+ yield match.start(), Name.Exception, word
1719
+ elif re.match('REBOL$', word):
1720
+ yield match.start(), Generic.Heading, word
1721
+ elif re.match("to-.*", word):
1722
+ yield match.start(), Keyword, word
1723
+ elif re.match('(\+|-|\*|/|//|\*\*|and|or|xor|=\?|=|==|<>|<|>|<=|>=)$',
1724
+ word):
1725
+ yield match.start(), Operator, word
1726
+ elif re.match(".*\?$", word):
1727
+ yield match.start(), Keyword, word
1728
+ elif re.match(".*\!$", word):
1729
+ yield match.start(), Keyword.Type, word
1730
+ elif re.match("'.*", word):
1731
+ yield match.start(), Name.Variable.Instance, word # lit-word
1732
+ elif re.match("#.*", word):
1733
+ yield match.start(), Name.Label, word # issue
1734
+ elif re.match("%.*", word):
1735
+ yield match.start(), Name.Decorator, word # file
1736
+ else:
1737
+ yield match.start(), Name.Variable, word
1738
+
1739
+ tokens = {
1740
+ 'root': [
1741
+ (r'\s+', Text),
1742
+ (r'#"', String.Char, 'char'),
1743
+ (r'#{[0-9a-fA-F]*}', Number.Hex),
1744
+ (r'2#{', Number.Hex, 'bin2'),
1745
+ (r'64#{[0-9a-zA-Z+/=\s]*}', Number.Hex),
1746
+ (r'"', String, 'string'),
1747
+ (r'{', String, 'string2'),
1748
+ (r';#+.*\n', Comment.Special),
1749
+ (r';\*+.*\n', Comment.Preproc),
1750
+ (r';.*\n', Comment),
1751
+ (r'%"', Name.Decorator, 'stringFile'),
1752
+ (r'%[^(\^{^")\s\[\]]+', Name.Decorator),
1753
+ (r'<[a-zA-Z0-9:._-]*>', Name.Tag),
1754
+ (r'<[^(<>\s")]+', Name.Tag, 'tag'),
1755
+ (r'[+-]?([a-zA-Z]{1,3})?\$\d+(\.\d+)?', Number.Float), # money
1756
+ (r'[+-]?\d+\:\d+(\:\d+)?(\.\d+)?', String.Other), # time
1757
+ (r'\d+\-[0-9a-zA-Z]+\-\d+(\/\d+\:\d+(\:\d+)?'
1758
+ r'([\.\d+]?([+-]?\d+:\d+)?)?)?', String.Other), # date
1759
+ (r'\d+(\.\d+)+\.\d+', Keyword.Constant), # tuple
1760
+ (r'\d+[xX]\d+', Keyword.Constant), # pair
1761
+ (r'[+-]?\d+(\'\d+)?([\.,]\d*)?[eE][+-]?\d+', Number.Float),
1762
+ (r'[+-]?\d+(\'\d+)?[\.,]\d*', Number.Float),
1763
+ (r'[+-]?\d+(\'\d+)?', Number),
1764
+ (r'[\[\]\(\)]', Generic.Strong),
1765
+ (r'[a-zA-Z]+[^(\^{"\s:)]*://[^(\^{"\s)]*', Name.Decorator), # url
1766
+ (r'mailto:[^(\^{"@\s)]+@[^(\^{"@\s)]+', Name.Decorator), # url
1767
+ (r'[^(\^{"@\s)]+@[^(\^{"@\s)]+', Name.Decorator), # email
1768
+ (r'comment\s', Comment, 'comment'),
1769
+ (r'/[^(\^{^")\s/[\]]*', Name.Attribute),
1770
+ (r'([^(\^{^")\s/[\]]+)(?=[:({"\s/\[\]])', word_callback),
1771
+ (r'([^(\^{^")\s]+)', Text),
1772
+ ],
1773
+ 'string': [
1774
+ (r'[^(\^")]+', String),
1775
+ (escape_re, String.Escape),
1776
+ (r'[\(|\)]+', String),
1777
+ (r'\^.', String.Escape),
1778
+ (r'"', String, '#pop'),
1779
+ ],
1780
+ 'string2': [
1781
+ (r'[^(\^{^})]+', String),
1782
+ (escape_re, String.Escape),
1783
+ (r'[\(|\)]+', String),
1784
+ (r'\^.', String.Escape),
1785
+ (r'{', String, '#push'),
1786
+ (r'}', String, '#pop'),
1787
+ ],
1788
+ 'stringFile': [
1789
+ (r'[^(\^")]+', Name.Decorator),
1790
+ (escape_re, Name.Decorator),
1791
+ (r'\^.', Name.Decorator),
1792
+ (r'"', Name.Decorator, '#pop'),
1793
+ ],
1794
+ 'char': [
1795
+ (escape_re + '"', String.Char, '#pop'),
1796
+ (r'\^."', String.Char, '#pop'),
1797
+ (r'."', String.Char, '#pop'),
1798
+ ],
1799
+ 'tag': [
1800
+ (escape_re, Name.Tag),
1801
+ (r'"', Name.Tag, 'tagString'),
1802
+ (r'[^(<>\r\n")]+', Name.Tag),
1803
+ (r'>', Name.Tag, '#pop'),
1804
+ ],
1805
+ 'tagString': [
1806
+ (r'[^(\^")]+', Name.Tag),
1807
+ (escape_re, Name.Tag),
1808
+ (r'[\(|\)]+', Name.Tag),
1809
+ (r'\^.', Name.Tag),
1810
+ (r'"', Name.Tag, '#pop'),
1811
+ ],
1812
+ 'tuple': [
1813
+ (r'(\d+\.)+', Keyword.Constant),
1814
+ (r'\d+', Keyword.Constant, '#pop'),
1815
+ ],
1816
+ 'bin2': [
1817
+ (r'\s+', Number.Hex),
1818
+ (r'([0-1]\s*){8}', Number.Hex),
1819
+ (r'}', Number.Hex, '#pop'),
1820
+ ],
1821
+ 'comment': [
1822
+ (r'"', Comment, 'commentString1'),
1823
+ (r'{', Comment, 'commentString2'),
1824
+ (r'\[', Comment, 'commentBlock'),
1825
+ (r'[^(\s{\"\[]+', Comment, '#pop'),
1826
+ ],
1827
+ 'commentString1': [
1828
+ (r'[^(\^")]+', Comment),
1829
+ (escape_re, Comment),
1830
+ (r'[\(|\)]+', Comment),
1831
+ (r'\^.', Comment),
1832
+ (r'"', Comment, '#pop'),
1833
+ ],
1834
+ 'commentString2': [
1835
+ (r'[^(\^{^})]+', Comment),
1836
+ (escape_re, Comment),
1837
+ (r'[\(|\)]+', Comment),
1838
+ (r'\^.', Comment),
1839
+ (r'{', Comment, '#push'),
1840
+ (r'}', Comment, '#pop'),
1841
+ ],
1842
+ 'commentBlock': [
1843
+ (r'\[',Comment, '#push'),
1844
+ (r'\]',Comment, '#pop'),
1845
+ (r'[^(\[\])]*', Comment),
1846
+ ],
1847
+ }
1848
+
1849
+
1850
+ class ABAPLexer(RegexLexer):
1851
+ """
1852
+ Lexer for ABAP, SAP's integrated language.
1853
+
1854
+ *New in Pygments 1.1.*
1855
+ """
1856
+ name = 'ABAP'
1857
+ aliases = ['abap']
1858
+ filenames = ['*.abap']
1859
+ mimetypes = ['text/x-abap']
1860
+
1861
+ flags = re.IGNORECASE | re.MULTILINE
1862
+
1863
+ tokens = {
1864
+ 'common': [
1865
+ (r'\s+', Text),
1866
+ (r'^\*.*$', Comment.Single),
1867
+ (r'\".*?\n', Comment.Single),
1868
+ ],
1869
+ 'variable-names': [
1870
+ (r'<[\S_]+>', Name.Variable),
1871
+ (r'[\w][\w_~]*(?:(\[\])|->\*)?', Name.Variable),
1872
+ ],
1873
+ 'root': [
1874
+ include('common'),
1875
+ #function calls
1876
+ (r'(CALL\s+(?:BADI|CUSTOMER-FUNCTION|FUNCTION))(\s+)(\'?\S+\'?)',
1877
+ bygroups(Keyword, Text, Name.Function)),
1878
+ (r'(CALL\s+(?:DIALOG|SCREEN|SUBSCREEN|SELECTION-SCREEN|'
1879
+ r'TRANSACTION|TRANSFORMATION))\b',
1880
+ Keyword),
1881
+ (r'(FORM|PERFORM)(\s+)([\w_]+)',
1882
+ bygroups(Keyword, Text, Name.Function)),
1883
+ (r'(PERFORM)(\s+)(\()([\w_]+)(\))',
1884
+ bygroups(Keyword, Text, Punctuation, Name.Variable, Punctuation )),
1885
+ (r'(MODULE)(\s+)(\S+)(\s+)(INPUT|OUTPUT)',
1886
+ bygroups(Keyword, Text, Name.Function, Text, Keyword)),
1887
+
1888
+ # method implementation
1889
+ (r'(METHOD)(\s+)([\w_~]+)',
1890
+ bygroups(Keyword, Text, Name.Function)),
1891
+ # method calls
1892
+ (r'(\s+)([\w_\-]+)([=\-]>)([\w_\-~]+)',
1893
+ bygroups(Text, Name.Variable, Operator, Name.Function)),
1894
+ # call methodnames returning style
1895
+ (r'(?<=(=|-)>)([\w_\-~]+)(?=\()', Name.Function),
1896
+
1897
+ # keywords with dashes in them.
1898
+ # these need to be first, because for instance the -ID part
1899
+ # of MESSAGE-ID wouldn't get highlighted if MESSAGE was
1900
+ # first in the list of keywords.
1901
+ (r'(ADD-CORRESPONDING|AUTHORITY-CHECK|'
1902
+ r'CLASS-DATA|CLASS-EVENTS|CLASS-METHODS|CLASS-POOL|'
1903
+ r'DELETE-ADJACENT|DIVIDE-CORRESPONDING|'
1904
+ r'EDITOR-CALL|ENHANCEMENT-POINT|ENHANCEMENT-SECTION|EXIT-COMMAND|'
1905
+ r'FIELD-GROUPS|FIELD-SYMBOLS|FUNCTION-POOL|'
1906
+ r'INTERFACE-POOL|INVERTED-DATE|'
1907
+ r'LOAD-OF-PROGRAM|LOG-POINT|'
1908
+ r'MESSAGE-ID|MOVE-CORRESPONDING|MULTIPLY-CORRESPONDING|'
1909
+ r'NEW-LINE|NEW-PAGE|NEW-SECTION|NO-EXTENSION|'
1910
+ r'OUTPUT-LENGTH|PRINT-CONTROL|'
1911
+ r'SELECT-OPTIONS|START-OF-SELECTION|SUBTRACT-CORRESPONDING|'
1912
+ r'SYNTAX-CHECK|SYSTEM-EXCEPTIONS|'
1913
+ r'TYPE-POOL|TYPE-POOLS'
1914
+ r')\b', Keyword),
1915
+
1916
+ # keyword kombinations
1917
+ (r'CREATE\s+(PUBLIC|PRIVATE|DATA|OBJECT)|'
1918
+ r'((PUBLIC|PRIVATE|PROTECTED)\s+SECTION|'
1919
+ r'(TYPE|LIKE)(\s+(LINE\s+OF|REF\s+TO|'
1920
+ r'(SORTED|STANDARD|HASHED)\s+TABLE\s+OF))?|'
1921
+ r'FROM\s+(DATABASE|MEMORY)|CALL\s+METHOD|'
1922
+ r'(GROUP|ORDER) BY|HAVING|SEPARATED BY|'
1923
+ r'GET\s+(BADI|BIT|CURSOR|DATASET|LOCALE|PARAMETER|'
1924
+ r'PF-STATUS|(PROPERTY|REFERENCE)\s+OF|'
1925
+ r'RUN\s+TIME|TIME\s+(STAMP)?)?|'
1926
+ r'SET\s+(BIT|BLANK\s+LINES|COUNTRY|CURSOR|DATASET|EXTENDED\s+CHECK|'
1927
+ r'HANDLER|HOLD\s+DATA|LANGUAGE|LEFT\s+SCROLL-BOUNDARY|'
1928
+ r'LOCALE|MARGIN|PARAMETER|PF-STATUS|PROPERTY\s+OF|'
1929
+ r'RUN\s+TIME\s+(ANALYZER|CLOCK\s+RESOLUTION)|SCREEN|'
1930
+ r'TITLEBAR|UPADTE\s+TASK\s+LOCAL|USER-COMMAND)|'
1931
+ r'CONVERT\s+((INVERTED-)?DATE|TIME|TIME\s+STAMP|TEXT)|'
1932
+ r'(CLOSE|OPEN)\s+(DATASET|CURSOR)|'
1933
+ r'(TO|FROM)\s+(DATA BUFFER|INTERNAL TABLE|MEMORY ID|'
1934
+ r'DATABASE|SHARED\s+(MEMORY|BUFFER))|'
1935
+ r'DESCRIBE\s+(DISTANCE\s+BETWEEN|FIELD|LIST|TABLE)|'
1936
+ r'FREE\s(MEMORY|OBJECT)?|'
1937
+ r'PROCESS\s+(BEFORE\s+OUTPUT|AFTER\s+INPUT|'
1938
+ r'ON\s+(VALUE-REQUEST|HELP-REQUEST))|'
1939
+ r'AT\s+(LINE-SELECTION|USER-COMMAND|END\s+OF|NEW)|'
1940
+ r'AT\s+SELECTION-SCREEN(\s+(ON(\s+(BLOCK|(HELP|VALUE)-REQUEST\s+FOR|'
1941
+ r'END\s+OF|RADIOBUTTON\s+GROUP))?|OUTPUT))?|'
1942
+ r'SELECTION-SCREEN:?\s+((BEGIN|END)\s+OF\s+((TABBED\s+)?BLOCK|LINE|'
1943
+ r'SCREEN)|COMMENT|FUNCTION\s+KEY|'
1944
+ r'INCLUDE\s+BLOCKS|POSITION|PUSHBUTTON|'
1945
+ r'SKIP|ULINE)|'
1946
+ r'LEAVE\s+(LIST-PROCESSING|PROGRAM|SCREEN|'
1947
+ r'TO LIST-PROCESSING|TO TRANSACTION)'
1948
+ r'(ENDING|STARTING)\s+AT|'
1949
+ r'FORMAT\s+(COLOR|INTENSIFIED|INVERSE|HOTSPOT|INPUT|FRAMES|RESET)|'
1950
+ r'AS\s+(CHECKBOX|SUBSCREEN|WINDOW)|'
1951
+ r'WITH\s+(((NON-)?UNIQUE)?\s+KEY|FRAME)|'
1952
+ r'(BEGIN|END)\s+OF|'
1953
+ r'DELETE(\s+ADJACENT\s+DUPLICATES\sFROM)?|'
1954
+ r'COMPARING(\s+ALL\s+FIELDS)?|'
1955
+ r'INSERT(\s+INITIAL\s+LINE\s+INTO|\s+LINES\s+OF)?|'
1956
+ r'IN\s+((BYTE|CHARACTER)\s+MODE|PROGRAM)|'
1957
+ r'END-OF-(DEFINITION|PAGE|SELECTION)|'
1958
+ r'WITH\s+FRAME(\s+TITLE)|'
1959
+
1960
+ # simple kombinations
1961
+ r'AND\s+(MARK|RETURN)|CLIENT\s+SPECIFIED|CORRESPONDING\s+FIELDS\s+OF|'
1962
+ r'IF\s+FOUND|FOR\s+EVENT|INHERITING\s+FROM|LEAVE\s+TO\s+SCREEN|'
1963
+ r'LOOP\s+AT\s+(SCREEN)?|LOWER\s+CASE|MATCHCODE\s+OBJECT|MODIF\s+ID|'
1964
+ r'MODIFY\s+SCREEN|NESTING\s+LEVEL|NO\s+INTERVALS|OF\s+STRUCTURE|'
1965
+ r'RADIOBUTTON\s+GROUP|RANGE\s+OF|REF\s+TO|SUPPRESS DIALOG|'
1966
+ r'TABLE\s+OF|UPPER\s+CASE|TRANSPORTING\s+NO\s+FIELDS|'
1967
+ r'VALUE\s+CHECK|VISIBLE\s+LENGTH|HEADER\s+LINE)\b', Keyword),
1968
+
1969
+ # single word keywords.
1970
+ (r'(^|(?<=(\s|\.)))(ABBREVIATED|ADD|ALIASES|APPEND|ASSERT|'
1971
+ r'ASSIGN(ING)?|AT(\s+FIRST)?|'
1972
+ r'BACK|BLOCK|BREAK-POINT|'
1973
+ r'CASE|CATCH|CHANGING|CHECK|CLASS|CLEAR|COLLECT|COLOR|COMMIT|'
1974
+ r'CREATE|COMMUNICATION|COMPONENTS?|COMPUTE|CONCATENATE|CONDENSE|'
1975
+ r'CONSTANTS|CONTEXTS|CONTINUE|CONTROLS|'
1976
+ r'DATA|DECIMALS|DEFAULT|DEFINE|DEFINITION|DEFERRED|DEMAND|'
1977
+ r'DETAIL|DIRECTORY|DIVIDE|DO|'
1978
+ r'ELSE(IF)?|ENDAT|ENDCASE|ENDCLASS|ENDDO|ENDFORM|ENDFUNCTION|'
1979
+ r'ENDIF|ENDLOOP|ENDMETHOD|ENDMODULE|ENDSELECT|ENDTRY|'
1980
+ r'ENHANCEMENT|EVENTS|EXCEPTIONS|EXIT|EXPORT|EXPORTING|EXTRACT|'
1981
+ r'FETCH|FIELDS?|FIND|FOR|FORM|FORMAT|FREE|FROM|'
1982
+ r'HIDE|'
1983
+ r'ID|IF|IMPORT|IMPLEMENTATION|IMPORTING|IN|INCLUDE|INCLUDING|'
1984
+ r'INDEX|INFOTYPES|INITIALIZATION|INTERFACE|INTERFACES|INTO|'
1985
+ r'LENGTH|LINES|LOAD|LOCAL|'
1986
+ r'JOIN|'
1987
+ r'KEY|'
1988
+ r'MAXIMUM|MESSAGE|METHOD[S]?|MINIMUM|MODULE|MODIFY|MOVE|MULTIPLY|'
1989
+ r'NODES|'
1990
+ r'OBLIGATORY|OF|OFF|ON|OVERLAY|'
1991
+ r'PACK|PARAMETERS|PERCENTAGE|POSITION|PROGRAM|PROVIDE|PUBLIC|PUT|'
1992
+ r'RAISE|RAISING|RANGES|READ|RECEIVE|REFRESH|REJECT|REPORT|RESERVE|'
1993
+ r'RESUME|RETRY|RETURN|RETURNING|RIGHT|ROLLBACK|'
1994
+ r'SCROLL|SEARCH|SELECT|SHIFT|SINGLE|SKIP|SORT|SPLIT|STATICS|STOP|'
1995
+ r'SUBMIT|SUBTRACT|SUM|SUMMARY|SUMMING|SUPPLY|'
1996
+ r'TABLE|TABLES|TIMES|TITLE|TO|TOP-OF-PAGE|TRANSFER|TRANSLATE|TRY|TYPES|'
1997
+ r'ULINE|UNDER|UNPACK|UPDATE|USING|'
1998
+ r'VALUE|VALUES|VIA|'
1999
+ r'WAIT|WHEN|WHERE|WHILE|WITH|WINDOW|WRITE)\b', Keyword),
2000
+
2001
+ # builtins
2002
+ (r'(abs|acos|asin|atan|'
2003
+ r'boolc|boolx|bit_set|'
2004
+ r'char_off|charlen|ceil|cmax|cmin|condense|contains|'
2005
+ r'contains_any_of|contains_any_not_of|concat_lines_of|cos|cosh|'
2006
+ r'count|count_any_of|count_any_not_of|'
2007
+ r'dbmaxlen|distance|'
2008
+ r'escape|exp|'
2009
+ r'find|find_end|find_any_of|find_any_not_of|floor|frac|from_mixed|'
2010
+ r'insert|'
2011
+ r'lines|log|log10|'
2012
+ r'match|matches|'
2013
+ r'nmax|nmin|numofchar|'
2014
+ r'repeat|replace|rescale|reverse|round|'
2015
+ r'segment|shift_left|shift_right|sign|sin|sinh|sqrt|strlen|'
2016
+ r'substring|substring_after|substring_from|substring_before|substring_to|'
2017
+ r'tan|tanh|to_upper|to_lower|to_mixed|translate|trunc|'
2018
+ r'xstrlen)(\()\b', bygroups(Name.Builtin, Punctuation)),
2019
+
2020
+ (r'&[0-9]', Name),
2021
+ (r'[0-9]+', Number.Integer),
2022
+
2023
+ # operators which look like variable names before
2024
+ # parsing variable names.
2025
+ (r'(?<=(\s|.))(AND|EQ|NE|GT|LT|GE|LE|CO|CN|CA|NA|CS|NOT|NS|CP|NP|'
2026
+ r'BYTE-CO|BYTE-CN|BYTE-CA|BYTE-NA|BYTE-CS|BYTE-NS|'
2027
+ r'IS\s+(NOT\s+)?(INITIAL|ASSIGNED|REQUESTED|BOUND))\b', Operator),
2028
+
2029
+ include('variable-names'),
2030
+
2031
+ # standard oparators after variable names,
2032
+ # because < and > are part of field symbols.
2033
+ (r'[?*<>=\-+]', Operator),
2034
+ (r"'(''|[^'])*'", String.Single),
2035
+ (r'[/;:()\[\],\.]', Punctuation)
2036
+ ],
2037
+ }
2038
+
2039
+
2040
+ class NewspeakLexer(RegexLexer):
2041
+ """
2042
+ For `Newspeak <http://newspeaklanguage.org/>` syntax.
2043
+ """
2044
+ name = 'Newspeak'
2045
+ filenames = ['*.ns2']
2046
+ aliases = ['newspeak', ]
2047
+ mimetypes = ['text/x-newspeak']
2048
+
2049
+ tokens = {
2050
+ 'root' : [
2051
+ (r'\b(Newsqueak2)\b',Keyword.Declaration),
2052
+ (r"'[^']*'",String),
2053
+ (r'\b(class)(\s+)([a-zA-Z0-9_]+)(\s*)',
2054
+ bygroups(Keyword.Declaration,Text,Name.Class,Text)),
2055
+ (r'\b(mixin|self|super|private|public|protected|nil|true|false)\b',
2056
+ Keyword),
2057
+ (r'([a-zA-Z0-9_]+\:)(\s*)([a-zA-Z_]\w+)',
2058
+ bygroups(Name.Function,Text,Name.Variable)),
2059
+ (r'([a-zA-Z0-9_]+)(\s*)(=)',
2060
+ bygroups(Name.Attribute,Text,Operator)),
2061
+ (r'<[a-zA-Z0-9_]+>', Comment.Special),
2062
+ include('expressionstat'),
2063
+ include('whitespace')
2064
+ ],
2065
+
2066
+ 'expressionstat': [
2067
+ (r'(\d+\.\d*|\.\d+|\d+[fF])[fF]?', Number.Float),
2068
+ (r'\d+', Number.Integer),
2069
+ (r':\w+',Name.Variable),
2070
+ (r'(\w+)(::)', bygroups(Name.Variable, Operator)),
2071
+ (r'\w+:', Name.Function),
2072
+ (r'\w+', Name.Variable),
2073
+ (r'\(|\)', Punctuation),
2074
+ (r'\[|\]', Punctuation),
2075
+ (r'\{|\}', Punctuation),
2076
+
2077
+ (r'(\^|\+|\/|~|\*|<|>|=|@|%|\||&|\?|!|,|-|:)', Operator),
2078
+ (r'\.|;', Punctuation),
2079
+ include('whitespace'),
2080
+ include('literals'),
2081
+ ],
2082
+ 'literals': [
2083
+ (r'\$.', String),
2084
+ (r"'[^']*'", String),
2085
+ (r"#'[^']*'", String.Symbol),
2086
+ (r"#\w+:?", String.Symbol),
2087
+ (r"#(\+|\/|~|\*|<|>|=|@|%|\||&|\?|!|,|-)+", String.Symbol)
2088
+
2089
+ ],
2090
+ 'whitespace' : [
2091
+ (r'\s+', Text),
2092
+ (r'"[^"]*"', Comment)
2093
+ ]
2094
+ }
2095
+
2096
+ class GherkinLexer(RegexLexer):
2097
+ """
2098
+ For `Gherkin <http://cukes.info/>` syntax.
2099
+
2100
+ *New in Pygments 1.2.*
2101
+ """
2102
+ name = 'Gherkin'
2103
+ aliases = ['Cucumber', 'cucumber', 'Gherkin', 'gherkin']
2104
+ filenames = ['*.feature']
2105
+ mimetypes = ['text/x-gherkin']
2106
+
2107
+ feature_keywords_regexp = ur'^(기능|機能|功能|フィーチャ|خاصية|תכונה|Функционалност|Функционал|Особина|Могућност|Özellik|Właściwość|Tính năng|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|Funcionalidade|Fonctionnalité|Fitur|Feature|Egenskap|Egenskab|Crikey|Característica|Arwedd)(:)(.*)$'
2108
+ scenario_keywords_regexp = ur'^(\s*)(시나리오 개요|시나리오|배경|背景|場景大綱|場景|场景大纲|场景|劇本大綱|劇本|テンプレ|シナリオテンプレート|シナリオテンプレ|シナリオアウトライン|シナリオ|سيناريو مخطط|سيناريو|الخلفية|תרחיש|תבנית תרחיש|רקע|Тарих|Сценарио|Сценарий структураси|Сценарий|Структура сценарија|Структура сценария|Скица|Рамка на сценарий|Пример|Предыстория|Предистория|Позадина|Основа|Концепт|Контекст|Założenia|Tình huống|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|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|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|Esquema do Cenário|Esquema do Cenario|Esquema del escenario|Esquema de l\'escenari|Escenario|Escenari|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)(:)(.*)$'
2109
+ examples_regexp = ur'^(\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|Eksempler|Ejemplos|EXAMPLZ|Dữ liệu|Contoh|Cobber|Beispiele)(:)(.*)$'
2110
+ step_keywords_regexp = ur'^(\s*)(하지만|조건|만일|그리고|그러면|那麼|那么|而且|當|当|前提|假設|假如|但是|但し|並且|もし|ならば|ただし|しかし|かつ|و |متى |لكن |عندما |ثم |بفرض |اذاً |כאשר |וגם |בהינתן |אזי |אז |אבל |Унда |То |Онда |Но |Лекин |Когато |Када |Кад |К тому же |И |Задато |Задати |Задате |Если |Допустим |Дадено |Ва |Бирок |Аммо |Али |Агар |А |Și |És |anrhegedig a |Zatati |Zakładając |Zadato |Zadate |Zadano |Zadani |Zadan |Yna |Ya know how |Ya gotta |Y |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 |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ž |Kai |Kada |Kad |Jeżeli |Ja |Ir |I CAN HAZ |I |Ha |Givet |Given y\'all |Given |Gitt |Gegeven |Gegeben sei |Fakat |Eğer ki |Etant donné |Et |Então |Entonces |Entao |En |Eeldades |E |Duota |Donat |Donada |Diyelim ki |Dengan |De |Dato |Dar |Dann |Dan |Dado |Dacă |Daca |DEN |Când |Cuando |Cho |Cept |Cand |But y\'all |But |Biết |Bet |BUT |Atunci |And y\'all |And |Ama |Als |Alors |Allora |Ali |Aleshores |Ale |Akkor |Aber |AN |A také |A |\* )'
2111
+
2112
+ tokens = {
2113
+ 'comments': [
2114
+ (r'#.*$', Comment)
2115
+ ],
2116
+ 'multiline_descriptions' : [
2117
+ (step_keywords_regexp, Keyword, "#pop"),
2118
+ include('comments'),
2119
+ (r"(\s|.)", Name.Constant)
2120
+ ],
2121
+ 'multiline_descriptions_on_stack' : [
2122
+ (step_keywords_regexp, Keyword, "#pop:2"),
2123
+ include('comments'),
2124
+ (r"(\s|.)", Name.Constant)
2125
+ ],
2126
+ 'scenario_table_description': [
2127
+ (r"\s+\|", Text, 'scenario_table_header'),
2128
+ include('comments'),
2129
+ (r"(\s|.)", Name.Constant)
2130
+ ],
2131
+ 'scenario_table_header': [
2132
+ (r"\s+\|\s*$", Text, "#pop:2"),
2133
+ (r"(\s+\|\s*)(#.*)$", bygroups(Text, Comment), "#pop:2"),
2134
+ include('comments'),
2135
+ (r"\s+\|", Text),
2136
+ (r"[^\|]", Name.Variable)
2137
+ ],
2138
+ 'scenario_sections_on_stack': [
2139
+ (scenario_keywords_regexp,
2140
+ bygroups(Text, Name.Class, Name.Class, Name.Constant),
2141
+ "multiline_descriptions_on_stack")
2142
+ ],
2143
+ 'narrative': [
2144
+ include('scenario_sections_on_stack'),
2145
+ (r"(\s|.)", Name.Builtin)
2146
+ ],
2147
+ 'table_vars': [
2148
+ (r'(<[^>]*>)', bygroups(Name.Variable))
2149
+ ],
2150
+ 'string': [
2151
+ include('table_vars'),
2152
+ (r'(\s|.)', String),
2153
+ ],
2154
+ 'py_string': [
2155
+ (r'"""', String, "#pop"),
2156
+ include('string'),
2157
+ ],
2158
+ 'double_string': [
2159
+ (r'"', String, "#pop"),
2160
+ include('string'),
2161
+ ],
2162
+ 'root': [
2163
+ (r'\n', Text),
2164
+ include('comments'),
2165
+ (r'"""', String, "py_string"),
2166
+ (r'"', String, "double_string"),
2167
+ include('table_vars'),
2168
+ (r'@[^@\s]+', Name.Namespace),
2169
+ (step_keywords_regexp, bygroups(Text, Keyword)),
2170
+ (feature_keywords_regexp,
2171
+ bygroups(Name.Class, Name.Class, Name.Constant), 'narrative'),
2172
+ (scenario_keywords_regexp,
2173
+ bygroups(Text, Name.Class, Name.Class, Name.Constant),
2174
+ "multiline_descriptions"),
2175
+ (examples_regexp,
2176
+ bygroups(Text, Name.Class, Name.Class, Name.Constant),
2177
+ "scenario_table_description"),
2178
+ (r'(\s|.)', Text)
2179
+ ]
2180
+ }
2181
+
2182
+
2183
+ class AsymptoteLexer(RegexLexer):
2184
+ """
2185
+ For `Asymptote <http://asymptote.sf.net/>`_ source code.
2186
+
2187
+ *New in Pygments 1.2.*
2188
+ """
2189
+ name = 'Asymptote'
2190
+ aliases = ['asy', 'asymptote']
2191
+ filenames = ['*.asy']
2192
+ mimetypes = ['text/x-asymptote']
2193
+
2194
+ #: optional Comment or Whitespace
2195
+ _ws = r'(?:\s|//.*?\n|/[*].*?[*]/)+'
2196
+
2197
+ tokens = {
2198
+ 'whitespace': [
2199
+ (r'\n', Text),
2200
+ (r'\s+', Text),
2201
+ (r'\\\n', Text), # line continuation
2202
+ (r'//(\n|(.|\n)*?[^\\]\n)', Comment),
2203
+ (r'/(\\\n)?[*](.|\n)*?[*](\\\n)?/', Comment),
2204
+ ],
2205
+ 'statements': [
2206
+ # simple string (TeX friendly)
2207
+ (r'"(\\\\|\\"|[^"])*"', String),
2208
+ # C style string (with character escapes)
2209
+ (r"'", String, 'string'),
2210
+ (r'(\d+\.\d*|\.\d+|\d+)[eE][+-]?\d+[lL]?', Number.Float),
2211
+ (r'(\d+\.\d*|\.\d+|\d+[fF])[fF]?', Number.Float),
2212
+ (r'0x[0-9a-fA-F]+[Ll]?', Number.Hex),
2213
+ (r'0[0-7]+[Ll]?', Number.Oct),
2214
+ (r'\d+[Ll]?', Number.Integer),
2215
+ (r'[~!%^&*+=|?:<>/-]', Operator),
2216
+ (r'[()\[\],.]', Punctuation),
2217
+ (r'\b(case)(.+?)(:)', bygroups(Keyword, using(this), Text)),
2218
+ (r'(and|controls|tension|atleast|curl|if|else|while|for|do|'
2219
+ r'return|break|continue|struct|typedef|new|access|import|'
2220
+ r'unravel|from|include|quote|static|public|private|restricted|'
2221
+ r'this|explicit|true|false|null|cycle|newframe|operator)\b', Keyword),
2222
+ # Since an asy-type-name can be also an asy-function-name,
2223
+ # in the following we test if the string " [a-zA-Z]" follows
2224
+ # the Keyword.Type.
2225
+ # Of course it is not perfect !
2226
+ (r'(Braid|FitResult|Label|Legend|TreeNode|abscissa|arc|arrowhead|'
2227
+ r'binarytree|binarytreeNode|block|bool|bool3|bounds|bqe|circle|'
2228
+ r'conic|coord|coordsys|cputime|ellipse|file|filltype|frame|grid3|'
2229
+ r'guide|horner|hsv|hyperbola|indexedTransform|int|inversion|key|'
2230
+ r'light|line|linefit|marginT|marker|mass|object|pair|parabola|path|'
2231
+ r'path3|pen|picture|point|position|projection|real|revolution|'
2232
+ r'scaleT|scientific|segment|side|slice|splitface|string|surface|'
2233
+ r'tensionSpecifier|ticklocate|ticksgridT|tickvalues|transform|'
2234
+ r'transformation|tree|triangle|trilinear|triple|vector|'
2235
+ r'vertex|void)(?=([ ]{1,}[a-zA-Z]))', Keyword.Type),
2236
+ # Now the asy-type-name which are not asy-function-name
2237
+ # except yours !
2238
+ # Perhaps useless
2239
+ (r'(Braid|FitResult|TreeNode|abscissa|arrowhead|block|bool|bool3|'
2240
+ r'bounds|coord|frame|guide|horner|int|linefit|marginT|pair|pen|'
2241
+ r'picture|position|real|revolution|slice|splitface|ticksgridT|'
2242
+ r'tickvalues|tree|triple|vertex|void)\b', Keyword.Type),
2243
+ ('[a-zA-Z_][a-zA-Z0-9_]*:(?!:)', Name.Label),
2244
+ ('[a-zA-Z_][a-zA-Z0-9_]*', Name),
2245
+ ],
2246
+ 'root': [
2247
+ include('whitespace'),
2248
+ # functions
2249
+ (r'((?:[a-zA-Z0-9_*\s])+?(?:\s|[*]))' # return arguments
2250
+ r'([a-zA-Z_][a-zA-Z0-9_]*)' # method name
2251
+ r'(\s*\([^;]*?\))' # signature
2252
+ r'(' + _ws + r')({)',
2253
+ bygroups(using(this), Name.Function, using(this), using(this),
2254
+ Punctuation),
2255
+ 'function'),
2256
+ # function declarations
2257
+ (r'((?:[a-zA-Z0-9_*\s])+?(?:\s|[*]))' # return arguments
2258
+ r'([a-zA-Z_][a-zA-Z0-9_]*)' # method name
2259
+ r'(\s*\([^;]*?\))' # signature
2260
+ r'(' + _ws + r')(;)',
2261
+ bygroups(using(this), Name.Function, using(this), using(this),
2262
+ Punctuation)),
2263
+ ('', Text, 'statement'),
2264
+ ],
2265
+ 'statement' : [
2266
+ include('whitespace'),
2267
+ include('statements'),
2268
+ ('[{}]', Punctuation),
2269
+ (';', Punctuation, '#pop'),
2270
+ ],
2271
+ 'function': [
2272
+ include('whitespace'),
2273
+ include('statements'),
2274
+ (';', Punctuation),
2275
+ ('{', Punctuation, '#push'),
2276
+ ('}', Punctuation, '#pop'),
2277
+ ],
2278
+ 'string': [
2279
+ (r"'", String, '#pop'),
2280
+ (r'\\([\\abfnrtv"\'?]|x[a-fA-F0-9]{2,4}|[0-7]{1,3})', String.Escape),
2281
+ (r'\n', String),
2282
+ (r"[^\\'\n]+", String), # all other characters
2283
+ (r'\\\n', String),
2284
+ (r'\\n', String), # line continuation
2285
+ (r'\\', String), # stray backslash
2286
+ ]
2287
+ }
2288
+
2289
+ def get_tokens_unprocessed(self, text):
2290
+ from pygments.lexers._asybuiltins import ASYFUNCNAME, ASYVARNAME
2291
+ for index, token, value in \
2292
+ RegexLexer.get_tokens_unprocessed(self, text):
2293
+ if token is Name and value in ASYFUNCNAME:
2294
+ token = Name.Function
2295
+ elif token is Name and value in ASYVARNAME:
2296
+ token = Name.Variable
2297
+ yield index, token, value