|
1 # -*- coding: utf-8 -*- |
|
2 """ |
|
3 pygments.lexers.other |
|
4 ~~~~~~~~~~~~~~~~~~~~~ |
|
5 |
|
6 Lexers for other languages. |
|
7 |
|
8 :copyright: Copyright 2006-2009 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'] |
|
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)sh shell scripts. |
|
325 |
|
326 *New in Pygments 0.6.* |
|
327 """ |
|
328 |
|
329 name = 'Bash' |
|
330 aliases = ['bash', 'sh'] |
|
331 filenames = ['*.sh'] |
|
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'\$?"(\\\\|\\[0-7]+|\\.|[^"])*"', String.Double), |
|
363 (r"\$?'(\\\\|\\[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'[-+*/\\~<>=|&#!?,@%\w+:]+', String.Symbol), |
|
637 # literals |
|
638 (r'\'[^\']*\'', String), |
|
639 (r'\$.', String.Char), |
|
640 (r'(\d+r)?-?\d+(\.\d+)?(e-?\d+)?', Number), |
|
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'"(\\\\|\\[0-7]+|\\.|[^"])*"', String.Double), |
|
749 (r"'(\\\\|\\[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_term|(goal|term)_expansion|phrase)(?=[(])', Keyword), |
|
812 # Entity |
|
813 (r'(abolish|c(reate|urrent))_(object|protocol|category)(?=[(])', |
|
814 Keyword), |
|
815 (r'(object|protocol|category)_property(?=[(])', Keyword), |
|
816 # Entity relations |
|
817 (r'complements_object(?=[(])', Keyword), |
|
818 (r'extends_(object|protocol|category)(?=[(])', Keyword), |
|
819 (r'imp(lements_protocol|orts_category)(?=[(])', Keyword), |
|
820 (r'(instantiat|specializ)es_class(?=[(])', Keyword), |
|
821 # Events |
|
822 (r'(current_event|(abolish|define)_events)(?=[(])', Keyword), |
|
823 # Flags |
|
824 (r'(current|set)_logtalk_flag(?=[(])', Keyword), |
|
825 # Compiling, loading, and library paths |
|
826 (r'logtalk_(compile|l(ibrary_path|oad))(?=[(])', Keyword), |
|
827 # Database |
|
828 (r'(clause|retract(all)?)(?=[(])', Keyword), |
|
829 (r'a(bolish|ssert(a|z))(?=[(])', Keyword), |
|
830 # Control |
|
831 (r'(ca(ll|tch)|throw)(?=[(])', Keyword), |
|
832 (r'(fail|true)\b', Keyword), |
|
833 # All solutions |
|
834 (r'((bag|set)of|f(ind|or)all)(?=[(])', Keyword), |
|
835 # Multi-threading meta-predicates |
|
836 (r'threaded(_(call|once|ignore|exit|peek|wait|notify))?(?=[(])', |
|
837 Keyword), |
|
838 # Term unification |
|
839 (r'unify_with_occurs_check(?=[(])', Keyword), |
|
840 # Term creation and decomposition |
|
841 (r'(functor|arg|copy_term)(?=[(])', Keyword), |
|
842 # Evaluable functors |
|
843 (r'(rem|mod|abs|sign)(?=[(])', Keyword), |
|
844 (r'float(_(integer|fractional)_part)?(?=[(])', Keyword), |
|
845 (r'(floor|truncate|round|ceiling)(?=[(])', Keyword), |
|
846 # Other arithmetic functors |
|
847 (r'(cos|atan|exp|log|s(in|qrt))(?=[(])', Keyword), |
|
848 # Term testing |
|
849 (r'(var|atom(ic)?|integer|float|compound|n(onvar|umber))(?=[(])', |
|
850 Keyword), |
|
851 # Stream selection and control |
|
852 (r'(curren|se)t_(in|out)put(?=[(])', Keyword), |
|
853 (r'(open|close)(?=[(])', Keyword), |
|
854 (r'flush_output(?=[(])', Keyword), |
|
855 (r'(at_end_of_stream|flush_output)\b', Keyword), |
|
856 (r'(stream_property|at_end_of_stream|set_stream_position)(?=[(])', |
|
857 Keyword), |
|
858 # Character and byte input/output |
|
859 (r'(nl|(get|peek|put)_(byte|c(har|ode)))(?=[(])', Keyword), |
|
860 (r'\bnl\b', Keyword), |
|
861 # Term input/output |
|
862 (r'read(_term)?(?=[(])', Keyword), |
|
863 (r'write(q|_(canonical|term))?(?=[(])', Keyword), |
|
864 (r'(current_)?op(?=[(])', Keyword), |
|
865 (r'(current_)?char_conversion(?=[(])', Keyword), |
|
866 # Atomic term processing |
|
867 (r'atom_(length|c(hars|o(ncat|des)))(?=[(])', Keyword), |
|
868 (r'(char_code|sub_atom)(?=[(])', Keyword), |
|
869 (r'number_c(har|ode)s(?=[(])', Keyword), |
|
870 # Implementation defined hooks functions |
|
871 (r'(se|curren)t_prolog_flag(?=[(])', Keyword), |
|
872 (r'\bhalt\b', Keyword), |
|
873 (r'halt(?=[(])', Keyword), |
|
874 # Message sending operators |
|
875 (r'(::|:|\^\^)', Operator), |
|
876 # External call |
|
877 (r'[{}]', Keyword), |
|
878 # Logic and control |
|
879 (r'\bonce(?=[(])', Keyword), |
|
880 (r'\brepeat\b', Keyword), |
|
881 # Bitwise functors |
|
882 (r'(>>|<<|/\\|\\\\|\\)', Operator), |
|
883 # Arithemtic evaluation |
|
884 (r'\bis\b', Keyword), |
|
885 # Arithemtic comparison |
|
886 (r'(=:=|=\\=|<|=<|>=|>)', Operator), |
|
887 # Term creation and decomposition |
|
888 (r'=\.\.', Operator), |
|
889 # Term unification |
|
890 (r'(=|\\=)', Operator), |
|
891 # Term comparison |
|
892 (r'(==|\\==|@=<|@<|@>=|@>)', Operator), |
|
893 # Evaluable functors |
|
894 (r'(//|[-+*/])', Operator), |
|
895 (r'\b(mod|rem)\b', Operator), |
|
896 # Other arithemtic functors |
|
897 (r'\b\*\*\b', Operator), |
|
898 # DCG rules |
|
899 (r'-->', Operator), |
|
900 # Control constructs |
|
901 (r'([!;]|->)', Operator), |
|
902 # Logic and control |
|
903 (r'\\+', Operator), |
|
904 # Mode operators |
|
905 (r'[?@]', Operator), |
|
906 # Strings |
|
907 (r'"(\\\\|\\"|[^"])*"', String), |
|
908 # Ponctuation |
|
909 (r'[()\[\],.|]', Text), |
|
910 # Atoms |
|
911 (r"[a-z][a-zA-Z0-9_]*", Text), |
|
912 (r"[']", String, 'quoted_atom'), |
|
913 ], |
|
914 |
|
915 'quoted_atom': [ |
|
916 (r"['][']", String), |
|
917 (r"[']", String, '#pop'), |
|
918 (r'\\([\\abfnrtv"\']|(x[a-fA-F0-9]+|[0-7]+)\\)', String.Escape), |
|
919 (r"[^\\'\n]+", String), |
|
920 (r'\\', String), |
|
921 ], |
|
922 |
|
923 'directive': [ |
|
924 # Entity directives |
|
925 (r'(category|object|protocol)(?=[(])', Keyword, 'entityrelations'), |
|
926 (r'(end_(category|object|protocol))[.]',Keyword, 'root'), |
|
927 # Predicate scope directives |
|
928 (r'(public|protected|private)(?=[(])', Keyword, 'root'), |
|
929 # Other directives |
|
930 (r'e(ncoding|xport)(?=[(])', Keyword, 'root'), |
|
931 (r'in(fo|itialization)(?=[(])', Keyword, 'root'), |
|
932 (r'(dynamic|synchronized|threaded)[.]', Keyword, 'root'), |
|
933 (r'(alias|d(ynamic|iscontiguous)|m(eta_predicate|ode|ultifile)' |
|
934 r'|synchronized)(?=[(])', Keyword, 'root'), |
|
935 (r'op(?=[(])', Keyword, 'root'), |
|
936 (r'(calls|use(s|_module))(?=[(])', Keyword, 'root'), |
|
937 (r'[a-z][a-zA-Z0-9_]*(?=[(])', Text, 'root'), |
|
938 (r'[a-z][a-zA-Z0-9_]*[.]', Text, 'root'), |
|
939 ], |
|
940 |
|
941 'entityrelations': [ |
|
942 (r'(extends|i(nstantiates|mp(lements|orts))|specializes)(?=[(])', |
|
943 Keyword), |
|
944 # Numbers |
|
945 (r"0'.", Number), |
|
946 (r'0b[01]+', Number), |
|
947 (r'0o[0-7]+', Number), |
|
948 (r'0x[0-9a-fA-F]+', Number), |
|
949 (r'\d+\.?\d*((e|E)(\+|-)?\d+)?', Number), |
|
950 # Variables |
|
951 (r'([A-Z_][a-zA-Z0-9_]*)', Name.Variable), |
|
952 # Atoms |
|
953 (r"[a-z][a-zA-Z0-9_]*", Text), |
|
954 (r"[']", String, 'quoted_atom'), |
|
955 # Strings |
|
956 (r'"(\\\\|\\"|[^"])*"', String), |
|
957 # End of entity-opening directive |
|
958 (r'([)]\.)', Text, 'root'), |
|
959 # Scope operator |
|
960 (r'(::)', Operator), |
|
961 # Ponctuation |
|
962 (r'[()\[\],.|]', Text), |
|
963 # Comments |
|
964 (r'%.*?\n', Comment), |
|
965 (r'/\*(.|\n)*?\*/',Comment), |
|
966 # Whitespace |
|
967 (r'\n', Text), |
|
968 (r'\s+', Text), |
|
969 ] |
|
970 } |
|
971 |
|
972 |
|
973 def _shortened(word): |
|
974 dpos = word.find('$') |
|
975 return '|'.join([word[:dpos] + word[dpos+1:i] + r'\b' |
|
976 for i in range(len(word), dpos, -1)]) |
|
977 def _shortened_many(*words): |
|
978 return '|'.join(map(_shortened, words)) |
|
979 |
|
980 class GnuplotLexer(RegexLexer): |
|
981 """ |
|
982 For `Gnuplot <http://gnuplot.info/>`_ plotting scripts. |
|
983 |
|
984 *New in Pygments 0.11.* |
|
985 """ |
|
986 |
|
987 name = 'Gnuplot' |
|
988 aliases = ['gnuplot'] |
|
989 filenames = ['*.plot', '*.plt'] |
|
990 mimetypes = ['text/x-gnuplot'] |
|
991 |
|
992 tokens = { |
|
993 'root': [ |
|
994 include('whitespace'), |
|
995 (_shortened('bi$nd'), Keyword, 'bind'), |
|
996 (_shortened_many('ex$it', 'q$uit'), Keyword, 'quit'), |
|
997 (_shortened('f$it'), Keyword, 'fit'), |
|
998 (r'(if)(\s*)(\()', bygroups(Keyword, Text, Punctuation), 'if'), |
|
999 (r'else\b', Keyword), |
|
1000 (_shortened('pa$use'), Keyword, 'pause'), |
|
1001 (_shortened_many('p$lot', 'rep$lot', 'sp$lot'), Keyword, 'plot'), |
|
1002 (_shortened('sa$ve'), Keyword, 'save'), |
|
1003 (_shortened('se$t'), Keyword, ('genericargs', 'optionarg')), |
|
1004 (_shortened_many('sh$ow', 'uns$et'), |
|
1005 Keyword, ('noargs', 'optionarg')), |
|
1006 (_shortened_many('low$er', 'ra$ise', 'ca$ll', 'cd$', 'cl$ear', |
|
1007 'h$elp', '\\?$', 'hi$story', 'l$oad', 'pr$int', |
|
1008 'pwd$', 're$read', 'res$et', 'scr$eendump', |
|
1009 'she$ll', 'sy$stem', 'up$date'), |
|
1010 Keyword, 'genericargs'), |
|
1011 (_shortened_many('pwd$', 're$read', 'res$et', 'scr$eendump', |
|
1012 'she$ll', 'test$'), |
|
1013 Keyword, 'noargs'), |
|
1014 ('([a-zA-Z_][a-zA-Z0-9_]*)(\s*)(=)', |
|
1015 bygroups(Name.Variable, Text, Operator), 'genericargs'), |
|
1016 ('([a-zA-Z_][a-zA-Z0-9_]*)(\s*\(.*?\)\s*)(=)', |
|
1017 bygroups(Name.Function, Text, Operator), 'genericargs'), |
|
1018 (r'@[a-zA-Z_][a-zA-Z0-9_]*', Name.Constant), # macros |
|
1019 (r';', Keyword), |
|
1020 ], |
|
1021 'comment': [ |
|
1022 (r'[^\\\n]', Comment), |
|
1023 (r'\\\n', Comment), |
|
1024 (r'\\', Comment), |
|
1025 # don't add the newline to the Comment token |
|
1026 ('', Comment, '#pop'), |
|
1027 ], |
|
1028 'whitespace': [ |
|
1029 ('#', Comment, 'comment'), |
|
1030 (r'[ \t\v\f]+', Text), |
|
1031 ], |
|
1032 'noargs': [ |
|
1033 include('whitespace'), |
|
1034 # semicolon and newline end the argument list |
|
1035 (r';', Punctuation, '#pop'), |
|
1036 (r'\n', Text, '#pop'), |
|
1037 ], |
|
1038 'dqstring': [ |
|
1039 (r'"', String, '#pop'), |
|
1040 (r'\\([\\abfnrtv"\']|x[a-fA-F0-9]{2,4}|[0-7]{1,3})', String.Escape), |
|
1041 (r'[^\\"\n]+', String), # all other characters |
|
1042 (r'\\\n', String), # line continuation |
|
1043 (r'\\', String), # stray backslash |
|
1044 (r'\n', String, '#pop'), # newline ends the string too |
|
1045 ], |
|
1046 'sqstring': [ |
|
1047 (r"''", String), # escaped single quote |
|
1048 (r"'", String, '#pop'), |
|
1049 (r"[^\\'\n]+", String), # all other characters |
|
1050 (r'\\\n', String), # line continuation |
|
1051 (r'\\', String), # normal backslash |
|
1052 (r'\n', String, '#pop'), # newline ends the string too |
|
1053 ], |
|
1054 'genericargs': [ |
|
1055 include('noargs'), |
|
1056 (r'"', String, 'dqstring'), |
|
1057 (r"'", String, 'sqstring'), |
|
1058 (r'(\d+\.\d*|\.\d+|\d+)[eE][+-]?\d+', Number.Float), |
|
1059 (r'(\d+\.\d*|\.\d+)', Number.Float), |
|
1060 (r'-?\d+', Number.Integer), |
|
1061 ('[,.~!%^&*+=|?:<>/-]', Operator), |
|
1062 ('[{}()\[\]]', Punctuation), |
|
1063 (r'(eq|ne)\b', Operator.Word), |
|
1064 (r'([a-zA-Z_][a-zA-Z0-9_]*)(\s*)(\()', |
|
1065 bygroups(Name.Function, Text, Punctuation)), |
|
1066 (r'[a-zA-Z_][a-zA-Z0-9_]*', Name), |
|
1067 (r'@[a-zA-Z_][a-zA-Z0-9_]*', Name.Constant), # macros |
|
1068 (r'\\\n', Text), |
|
1069 ], |
|
1070 'optionarg': [ |
|
1071 include('whitespace'), |
|
1072 (_shortened_many( |
|
1073 "a$ll","an$gles","ar$row","au$toscale","b$ars","bor$der", |
|
1074 "box$width","cl$abel","c$lip","cn$trparam","co$ntour","da$ta", |
|
1075 "data$file","dg$rid3d","du$mmy","enc$oding","dec$imalsign", |
|
1076 "fit$","font$path","fo$rmat","fu$nction","fu$nctions","g$rid", |
|
1077 "hid$den3d","his$torysize","is$osamples","k$ey","keyt$itle", |
|
1078 "la$bel","li$nestyle","ls$","loa$dpath","loc$ale","log$scale", |
|
1079 "mac$ros","map$ping","map$ping3d","mar$gin","lmar$gin", |
|
1080 "rmar$gin","tmar$gin","bmar$gin","mo$use","multi$plot", |
|
1081 "mxt$ics","nomxt$ics","mx2t$ics","nomx2t$ics","myt$ics", |
|
1082 "nomyt$ics","my2t$ics","nomy2t$ics","mzt$ics","nomzt$ics", |
|
1083 "mcbt$ics","nomcbt$ics","of$fsets","or$igin","o$utput", |
|
1084 "pa$rametric","pm$3d","pal$ette","colorb$ox","p$lot", |
|
1085 "poi$ntsize","pol$ar","pr$int","obj$ect","sa$mples","si$ze", |
|
1086 "st$yle","su$rface","table$","t$erminal","termo$ptions","ti$cs", |
|
1087 "ticsc$ale","ticsl$evel","timef$mt","tim$estamp","tit$le", |
|
1088 "v$ariables","ve$rsion","vi$ew","xyp$lane","xda$ta","x2da$ta", |
|
1089 "yda$ta","y2da$ta","zda$ta","cbda$ta","xl$abel","x2l$abel", |
|
1090 "yl$abel","y2l$abel","zl$abel","cbl$abel","xti$cs","noxti$cs", |
|
1091 "x2ti$cs","nox2ti$cs","yti$cs","noyti$cs","y2ti$cs","noy2ti$cs", |
|
1092 "zti$cs","nozti$cs","cbti$cs","nocbti$cs","xdti$cs","noxdti$cs", |
|
1093 "x2dti$cs","nox2dti$cs","ydti$cs","noydti$cs","y2dti$cs", |
|
1094 "noy2dti$cs","zdti$cs","nozdti$cs","cbdti$cs","nocbdti$cs", |
|
1095 "xmti$cs","noxmti$cs","x2mti$cs","nox2mti$cs","ymti$cs", |
|
1096 "noymti$cs","y2mti$cs","noy2mti$cs","zmti$cs","nozmti$cs", |
|
1097 "cbmti$cs","nocbmti$cs","xr$ange","x2r$ange","yr$ange", |
|
1098 "y2r$ange","zr$ange","cbr$ange","rr$ange","tr$ange","ur$ange", |
|
1099 "vr$ange","xzeroa$xis","x2zeroa$xis","yzeroa$xis","y2zeroa$xis", |
|
1100 "zzeroa$xis","zeroa$xis","z$ero"), Name.Builtin, '#pop'), |
|
1101 ], |
|
1102 'bind': [ |
|
1103 ('!', Keyword, '#pop'), |
|
1104 (_shortened('all$windows'), Name.Builtin), |
|
1105 include('genericargs'), |
|
1106 ], |
|
1107 'quit': [ |
|
1108 (r'gnuplot\b', Keyword), |
|
1109 include('noargs'), |
|
1110 ], |
|
1111 'fit': [ |
|
1112 (r'via\b', Name.Builtin), |
|
1113 include('plot'), |
|
1114 ], |
|
1115 'if': [ |
|
1116 (r'\)', Punctuation, '#pop'), |
|
1117 include('genericargs'), |
|
1118 ], |
|
1119 'pause': [ |
|
1120 (r'(mouse|any|button1|button2|button3)\b', Name.Builtin), |
|
1121 (_shortened('key$press'), Name.Builtin), |
|
1122 include('genericargs'), |
|
1123 ], |
|
1124 'plot': [ |
|
1125 (_shortened_many('ax$es', 'axi$s', 'bin$ary', 'ev$ery', 'i$ndex', |
|
1126 'mat$rix', 's$mooth', 'thru$', 't$itle', |
|
1127 'not$itle', 'u$sing', 'w$ith'), |
|
1128 Name.Builtin), |
|
1129 include('genericargs'), |
|
1130 ], |
|
1131 'save': [ |
|
1132 (_shortened_many('f$unctions', 's$et', 't$erminal', 'v$ariables'), |
|
1133 Name.Builtin), |
|
1134 include('genericargs'), |
|
1135 ], |
|
1136 } |
|
1137 |
|
1138 |
|
1139 class PovrayLexer(RegexLexer): |
|
1140 """ |
|
1141 For `Persistence of Vision Raytracer <http://www.povray.org/>`_ files. |
|
1142 |
|
1143 *New in Pygments 0.11.* |
|
1144 """ |
|
1145 name = 'POVRay' |
|
1146 aliases = ['pov'] |
|
1147 filenames = ['*.pov', '*.inc'] |
|
1148 mimetypes = ['text/x-povray'] |
|
1149 |
|
1150 tokens = { |
|
1151 'root': [ |
|
1152 (r'/\*[\w\W]*?\*/', Comment.Multiline), |
|
1153 (r'//.*\n', Comment.Single), |
|
1154 (r'"(?:\\.|[^"])+"', String.Double), |
|
1155 (r'#(debug|default|else|end|error|fclose|fopen|if|ifdef|ifndef|' |
|
1156 r'include|range|read|render|statistics|switch|undef|version|' |
|
1157 r'warning|while|write|define|macro|local|declare)', |
|
1158 Comment.Preproc), |
|
1159 (r'\b(aa_level|aa_threshold|abs|acos|acosh|adaptive|adc_bailout|' |
|
1160 r'agate|agate_turb|all|alpha|ambient|ambient_light|angle|' |
|
1161 r'aperture|arc_angle|area_light|asc|asin|asinh|assumed_gamma|' |
|
1162 r'atan|atan2|atanh|atmosphere|atmospheric_attenuation|' |
|
1163 r'attenuating|average|background|black_hole|blue|blur_samples|' |
|
1164 r'bounded_by|box_mapping|bozo|break|brick|brick_size|' |
|
1165 r'brightness|brilliance|bumps|bumpy1|bumpy2|bumpy3|bump_map|' |
|
1166 r'bump_size|case|caustics|ceil|checker|chr|clipped_by|clock|' |
|
1167 r'color|color_map|colour|colour_map|component|composite|concat|' |
|
1168 r'confidence|conic_sweep|constant|control0|control1|cos|cosh|' |
|
1169 r'count|crackle|crand|cube|cubic_spline|cylindrical_mapping|' |
|
1170 r'debug|declare|default|degrees|dents|diffuse|direction|' |
|
1171 r'distance|distance_maximum|div|dust|dust_type|eccentricity|' |
|
1172 r'else|emitting|end|error|error_bound|exp|exponent|' |
|
1173 r'fade_distance|fade_power|falloff|falloff_angle|false|' |
|
1174 r'file_exists|filter|finish|fisheye|flatness|flip|floor|' |
|
1175 r'focal_point|fog|fog_alt|fog_offset|fog_type|frequency|gif|' |
|
1176 r'global_settings|glowing|gradient|granite|gray_threshold|' |
|
1177 r'green|halo|hexagon|hf_gray_16|hierarchy|hollow|hypercomplex|' |
|
1178 r'if|ifdef|iff|image_map|incidence|include|int|interpolate|' |
|
1179 r'inverse|ior|irid|irid_wavelength|jitter|lambda|leopard|' |
|
1180 r'linear|linear_spline|linear_sweep|location|log|looks_like|' |
|
1181 r'look_at|low_error_factor|mandel|map_type|marble|material_map|' |
|
1182 r'matrix|max|max_intersections|max_iteration|max_trace_level|' |
|
1183 r'max_value|metallic|min|minimum_reuse|mod|mortar|' |
|
1184 r'nearest_count|no|normal|normal_map|no_shadow|number_of_waves|' |
|
1185 r'octaves|off|offset|omega|omnimax|on|once|onion|open|' |
|
1186 r'orthographic|panoramic|pattern1|pattern2|pattern3|' |
|
1187 r'perspective|pgm|phase|phong|phong_size|pi|pigment|' |
|
1188 r'pigment_map|planar_mapping|png|point_at|pot|pow|ppm|' |
|
1189 r'precision|pwr|quadratic_spline|quaternion|quick_color|' |
|
1190 r'quick_colour|quilted|radial|radians|radiosity|radius|rainbow|' |
|
1191 r'ramp_wave|rand|range|reciprocal|recursion_limit|red|' |
|
1192 r'reflection|refraction|render|repeat|rgb|rgbf|rgbft|rgbt|' |
|
1193 r'right|ripples|rotate|roughness|samples|scale|scallop_wave|' |
|
1194 r'scattering|seed|shadowless|sin|sine_wave|sinh|sky|sky_sphere|' |
|
1195 r'slice|slope_map|smooth|specular|spherical_mapping|spiral|' |
|
1196 r'spiral1|spiral2|spotlight|spotted|sqr|sqrt|statistics|str|' |
|
1197 r'strcmp|strength|strlen|strlwr|strupr|sturm|substr|switch|sys|' |
|
1198 r't|tan|tanh|test_camera_1|test_camera_2|test_camera_3|' |
|
1199 r'test_camera_4|texture|texture_map|tga|thickness|threshold|' |
|
1200 r'tightness|tile2|tiles|track|transform|translate|transmit|' |
|
1201 r'triangle_wave|true|ttf|turbulence|turb_depth|type|' |
|
1202 r'ultra_wide_angle|up|use_color|use_colour|use_index|u_steps|' |
|
1203 r'val|variance|vaxis_rotate|vcross|vdot|version|vlength|' |
|
1204 r'vnormalize|volume_object|volume_rendered|vol_with_light|' |
|
1205 r'vrotate|v_steps|warning|warp|water_level|waves|while|width|' |
|
1206 r'wood|wrinkles|yes)\b', Keyword), |
|
1207 (r'bicubic_patch|blob|box|camera|cone|cubic|cylinder|difference|' |
|
1208 r'disc|height_field|intersection|julia_fractal|lathe|' |
|
1209 r'light_source|merge|mesh|object|plane|poly|polygon|prism|' |
|
1210 r'quadric|quartic|smooth_triangle|sor|sphere|superellipsoid|' |
|
1211 r'text|torus|triangle|union', Name.Builtin), |
|
1212 # TODO: <=, etc |
|
1213 (r'[\[\](){}<>;,]', Punctuation), |
|
1214 (r'[-+*/=]', Operator), |
|
1215 (r'\b(x|y|z|u|v)\b', Name.Builtin.Pseudo), |
|
1216 (r'[a-zA-Z_][a-zA-Z_0-9]*', Name), |
|
1217 (r'[0-9]+\.[0-9]*', Number.Float), |
|
1218 (r'\.[0-9]+', Number.Float), |
|
1219 (r'[0-9]+', Number.Integer), |
|
1220 (r'\s+', Text), |
|
1221 ] |
|
1222 } |
|
1223 |
|
1224 |
|
1225 class AppleScriptLexer(RegexLexer): |
|
1226 """ |
|
1227 For `AppleScript source code |
|
1228 <http://developer.apple.com/documentation/AppleScript/ |
|
1229 Conceptual/AppleScriptLangGuide>`_, |
|
1230 including `AppleScript Studio |
|
1231 <http://developer.apple.com/documentation/AppleScript/ |
|
1232 Reference/StudioReference>`_. |
|
1233 Contributed by Andreas Amann <aamann@mac.com>. |
|
1234 """ |
|
1235 |
|
1236 name = 'AppleScript' |
|
1237 aliases = ['applescript'] |
|
1238 filenames = ['*.applescript'] |
|
1239 |
|
1240 flags = re.MULTILINE | re.DOTALL |
|
1241 |
|
1242 Identifiers = r'[a-zA-Z]\w*' |
|
1243 Literals = ['AppleScript', 'current application', 'false', 'linefeed', |
|
1244 'missing value', 'pi','quote', 'result', 'return', 'space', |
|
1245 'tab', 'text item delimiters', 'true', 'version'] |
|
1246 Classes = ['alias ', 'application ', 'boolean ', 'class ', 'constant ', |
|
1247 'date ', 'file ', 'integer ', 'list ', 'number ', 'POSIX file ', |
|
1248 'real ', 'record ', 'reference ', 'RGB color ', 'script ', |
|
1249 'text ', 'unit types', '(Unicode )?text', 'string'] |
|
1250 BuiltIn = ['attachment', 'attribute run', 'character', 'day', 'month', |
|
1251 'paragraph', 'word', 'year'] |
|
1252 HandlerParams = ['about', 'above', 'against', 'apart from', 'around', |
|
1253 'aside from', 'at', 'below', 'beneath', 'beside', |
|
1254 'between', 'for', 'given', 'instead of', 'on', 'onto', |
|
1255 'out of', 'over', 'since'] |
|
1256 Commands = ['ASCII (character|number)', 'activate', 'beep', 'choose URL', |
|
1257 'choose application', 'choose color', 'choose file( name)?', |
|
1258 'choose folder', 'choose from list', |
|
1259 'choose remote application', 'clipboard info', |
|
1260 'close( access)?', 'copy', 'count', 'current date', 'delay', |
|
1261 'delete', 'display (alert|dialog)', 'do shell script', |
|
1262 'duplicate', 'exists', 'get eof', 'get volume settings', |
|
1263 'info for', 'launch', 'list (disks|folder)', 'load script', |
|
1264 'log', 'make', 'mount volume', 'new', 'offset', |
|
1265 'open( (for access|location))?', 'path to', 'print', 'quit', |
|
1266 'random number', 'read', 'round', 'run( script)?', |
|
1267 'say', 'scripting components', |
|
1268 'set (eof|the clipboard to|volume)', 'store script', |
|
1269 'summarize', 'system attribute', 'system info', |
|
1270 'the clipboard', 'time to GMT', 'write', 'quoted form'] |
|
1271 References = ['(in )?back of', '(in )?front of', '[0-9]+(st|nd|rd|th)', |
|
1272 'first', 'second', 'third', 'fourth', 'fifth', 'sixth', |
|
1273 'seventh', 'eighth', 'ninth', 'tenth', 'after', 'back', |
|
1274 'before', 'behind', 'every', 'front', 'index', 'last', |
|
1275 'middle', 'some', 'that', 'through', 'thru', 'where', 'whose'] |
|
1276 Operators = ["and", "or", "is equal", "equals", "(is )?equal to", "is not", |
|
1277 "isn't", "isn't equal( to)?", "is not equal( to)?", |
|
1278 "doesn't equal", "does not equal", "(is )?greater than", |
|
1279 "comes after", "is not less than or equal( to)?", |
|
1280 "isn't less than or equal( to)?", "(is )?less than", |
|
1281 "comes before", "is not greater than or equal( to)?", |
|
1282 "isn't greater than or equal( to)?", |
|
1283 "(is )?greater than or equal( to)?", "is not less than", |
|
1284 "isn't less than", "does not come before", |
|
1285 "doesn't come before", "(is )?less than or equal( to)?", |
|
1286 "is not greater than", "isn't greater than", |
|
1287 "does not come after", "doesn't come after", "starts? with", |
|
1288 "begins? with", "ends? with", "contains?", "does not contain", |
|
1289 "doesn't contain", "is in", "is contained by", "is not in", |
|
1290 "is not contained by", "isn't contained by", "div", "mod", |
|
1291 "not", "(a )?(ref( to)?|reference to)", "is", "does"] |
|
1292 Control = ['considering', 'else', 'error', 'exit', 'from', 'if', |
|
1293 'ignoring', 'in', 'repeat', 'tell', 'then', 'times', 'to', |
|
1294 'try', 'until', 'using terms from', 'while', 'whith', |
|
1295 'with timeout( of)?', 'with transaction', 'by', 'continue', |
|
1296 'end', 'its?', 'me', 'my', 'return', 'of' , 'as'] |
|
1297 Declarations = ['global', 'local', 'prop(erty)?', 'set', 'get'] |
|
1298 Reserved = ['but', 'put', 'returning', 'the'] |
|
1299 StudioClasses = ['action cell', 'alert reply', 'application', 'box', |
|
1300 'browser( cell)?', 'bundle', 'button( cell)?', 'cell', |
|
1301 'clip view', 'color well', 'color-panel', |
|
1302 'combo box( item)?', 'control', |
|
1303 'data( (cell|column|item|row|source))?', 'default entry', |
|
1304 'dialog reply', 'document', 'drag info', 'drawer', |
|
1305 'event', 'font(-panel)?', 'formatter', |
|
1306 'image( (cell|view))?', 'matrix', 'menu( item)?', 'item', |
|
1307 'movie( view)?', 'open-panel', 'outline view', 'panel', |
|
1308 'pasteboard', 'plugin', 'popup button', |
|
1309 'progress indicator', 'responder', 'save-panel', |
|
1310 'scroll view', 'secure text field( cell)?', 'slider', |
|
1311 'sound', 'split view', 'stepper', 'tab view( item)?', |
|
1312 'table( (column|header cell|header view|view))', |
|
1313 'text( (field( cell)?|view))?', 'toolbar( item)?', |
|
1314 'user-defaults', 'view', 'window'] |
|
1315 StudioEvents = ['accept outline drop', 'accept table drop', 'action', |
|
1316 'activated', 'alert ended', 'awake from nib', 'became key', |
|
1317 'became main', 'begin editing', 'bounds changed', |
|
1318 'cell value', 'cell value changed', 'change cell value', |
|
1319 'change item value', 'changed', 'child of item', |
|
1320 'choose menu item', 'clicked', 'clicked toolbar item', |
|
1321 'closed', 'column clicked', 'column moved', |
|
1322 'column resized', 'conclude drop', 'data representation', |
|
1323 'deminiaturized', 'dialog ended', 'document nib name', |
|
1324 'double clicked', 'drag( (entered|exited|updated))?', |
|
1325 'drop', 'end editing', 'exposed', 'idle', 'item expandable', |
|
1326 'item value', 'item value changed', 'items changed', |
|
1327 'keyboard down', 'keyboard up', 'launched', |
|
1328 'load data representation', 'miniaturized', 'mouse down', |
|
1329 'mouse dragged', 'mouse entered', 'mouse exited', |
|
1330 'mouse moved', 'mouse up', 'moved', |
|
1331 'number of browser rows', 'number of items', |
|
1332 'number of rows', 'open untitled', 'opened', 'panel ended', |
|
1333 'parameters updated', 'plugin loaded', 'prepare drop', |
|
1334 'prepare outline drag', 'prepare outline drop', |
|
1335 'prepare table drag', 'prepare table drop', |
|
1336 'read from file', 'resigned active', 'resigned key', |
|
1337 'resigned main', 'resized( sub views)?', |
|
1338 'right mouse down', 'right mouse dragged', |
|
1339 'right mouse up', 'rows changed', 'scroll wheel', |
|
1340 'selected tab view item', 'selection changed', |
|
1341 'selection changing', 'should begin editing', |
|
1342 'should close', 'should collapse item', |
|
1343 'should end editing', 'should expand item', |
|
1344 'should open( untitled)?', |
|
1345 'should quit( after last window closed)?', |
|
1346 'should select column', 'should select item', |
|
1347 'should select row', 'should select tab view item', |
|
1348 'should selection change', 'should zoom', 'shown', |
|
1349 'update menu item', 'update parameters', |
|
1350 'update toolbar item', 'was hidden', 'was miniaturized', |
|
1351 'will become active', 'will close', 'will dismiss', |
|
1352 'will display browser cell', 'will display cell', |
|
1353 'will display item cell', 'will display outline cell', |
|
1354 'will finish launching', 'will hide', 'will miniaturize', |
|
1355 'will move', 'will open', 'will pop up', 'will quit', |
|
1356 'will resign active', 'will resize( sub views)?', |
|
1357 'will select tab view item', 'will show', 'will zoom', |
|
1358 'write to file', 'zoomed'] |
|
1359 StudioCommands = ['animate', 'append', 'call method', 'center', |
|
1360 'close drawer', 'close panel', 'display', |
|
1361 'display alert', 'display dialog', 'display panel', 'go', |
|
1362 'hide', 'highlight', 'increment', 'item for', |
|
1363 'load image', 'load movie', 'load nib', 'load panel', |
|
1364 'load sound', 'localized string', 'lock focus', 'log', |
|
1365 'open drawer', 'path for', 'pause', 'perform action', |
|
1366 'play', 'register', 'resume', 'scroll', 'select( all)?', |
|
1367 'show', 'size to fit', 'start', 'step back', |
|
1368 'step forward', 'stop', 'synchronize', 'unlock focus', |
|
1369 'update'] |
|
1370 StudioProperties = ['accepts arrow key', 'action method', 'active', |
|
1371 'alignment', 'allowed identifiers', |
|
1372 'allows branch selection', 'allows column reordering', |
|
1373 'allows column resizing', 'allows column selection', |
|
1374 'allows customization', |
|
1375 'allows editing text attributes', |
|
1376 'allows empty selection', 'allows mixed state', |
|
1377 'allows multiple selection', 'allows reordering', |
|
1378 'allows undo', 'alpha( value)?', 'alternate image', |
|
1379 'alternate increment value', 'alternate title', |
|
1380 'animation delay', 'associated file name', |
|
1381 'associated object', 'auto completes', 'auto display', |
|
1382 'auto enables items', 'auto repeat', |
|
1383 'auto resizes( outline column)?', |
|
1384 'auto save expanded items', 'auto save name', |
|
1385 'auto save table columns', 'auto saves configuration', |
|
1386 'auto scroll', 'auto sizes all columns to fit', |
|
1387 'auto sizes cells', 'background color', 'bezel state', |
|
1388 'bezel style', 'bezeled', 'border rect', 'border type', |
|
1389 'bordered', 'bounds( rotation)?', 'box type', |
|
1390 'button returned', 'button type', |
|
1391 'can choose directories', 'can choose files', |
|
1392 'can draw', 'can hide', |
|
1393 'cell( (background color|size|type))?', 'characters', |
|
1394 'class', 'click count', 'clicked( data)? column', |
|
1395 'clicked data item', 'clicked( data)? row', |
|
1396 'closeable', 'collating', 'color( (mode|panel))', |
|
1397 'command key down', 'configuration', |
|
1398 'content(s| (size|view( margins)?))?', 'context', |
|
1399 'continuous', 'control key down', 'control size', |
|
1400 'control tint', 'control view', |
|
1401 'controller visible', 'coordinate system', |
|
1402 'copies( on scroll)?', 'corner view', 'current cell', |
|
1403 'current column', 'current( field)? editor', |
|
1404 'current( menu)? item', 'current row', |
|
1405 'current tab view item', 'data source', |
|
1406 'default identifiers', 'delta (x|y|z)', |
|
1407 'destination window', 'directory', 'display mode', |
|
1408 'displayed cell', 'document( (edited|rect|view))?', |
|
1409 'double value', 'dragged column', 'dragged distance', |
|
1410 'dragged items', 'draws( cell)? background', |
|
1411 'draws grid', 'dynamically scrolls', 'echos bullets', |
|
1412 'edge', 'editable', 'edited( data)? column', |
|
1413 'edited data item', 'edited( data)? row', 'enabled', |
|
1414 'enclosing scroll view', 'ending page', |
|
1415 'error handling', 'event number', 'event type', |
|
1416 'excluded from windows menu', 'executable path', |
|
1417 'expanded', 'fax number', 'field editor', 'file kind', |
|
1418 'file name', 'file type', 'first responder', |
|
1419 'first visible column', 'flipped', 'floating', |
|
1420 'font( panel)?', 'formatter', 'frameworks path', |
|
1421 'frontmost', 'gave up', 'grid color', 'has data items', |
|
1422 'has horizontal ruler', 'has horizontal scroller', |
|
1423 'has parent data item', 'has resize indicator', |
|
1424 'has shadow', 'has sub menu', 'has vertical ruler', |
|
1425 'has vertical scroller', 'header cell', 'header view', |
|
1426 'hidden', 'hides when deactivated', 'highlights by', |
|
1427 'horizontal line scroll', 'horizontal page scroll', |
|
1428 'horizontal ruler view', 'horizontally resizable', |
|
1429 'icon image', 'id', 'identifier', |
|
1430 'ignores multiple clicks', |
|
1431 'image( (alignment|dims when disabled|frame style|' |
|
1432 'scaling))?', |
|
1433 'imports graphics', 'increment value', |
|
1434 'indentation per level', 'indeterminate', 'index', |
|
1435 'integer value', 'intercell spacing', 'item height', |
|
1436 'key( (code|equivalent( modifier)?|window))?', |
|
1437 'knob thickness', 'label', 'last( visible)? column', |
|
1438 'leading offset', 'leaf', 'level', 'line scroll', |
|
1439 'loaded', 'localized sort', 'location', 'loop mode', |
|
1440 'main( (bunde|menu|window))?', 'marker follows cell', |
|
1441 'matrix mode', 'maximum( content)? size', |
|
1442 'maximum visible columns', |
|
1443 'menu( form representation)?', 'miniaturizable', |
|
1444 'miniaturized', 'minimized image', 'minimized title', |
|
1445 'minimum column width', 'minimum( content)? size', |
|
1446 'modal', 'modified', 'mouse down state', |
|
1447 'movie( (controller|file|rect))?', 'muted', 'name', |
|
1448 'needs display', 'next state', 'next text', |
|
1449 'number of tick marks', 'only tick mark values', |
|
1450 'opaque', 'open panel', 'option key down', |
|
1451 'outline table column', 'page scroll', 'pages across', |
|
1452 'pages down', 'palette label', 'pane splitter', |
|
1453 'parent data item', 'parent window', 'pasteboard', |
|
1454 'path( (names|separator))?', 'playing', |
|
1455 'plays every frame', 'plays selection only', 'position', |
|
1456 'preferred edge', 'preferred type', 'pressure', |
|
1457 'previous text', 'prompt', 'properties', |
|
1458 'prototype cell', 'pulls down', 'rate', |
|
1459 'released when closed', 'repeated', |
|
1460 'requested print time', 'required file type', |
|
1461 'resizable', 'resized column', 'resource path', |
|
1462 'returns records', 'reuses columns', 'rich text', |
|
1463 'roll over', 'row height', 'rulers visible', |
|
1464 'save panel', 'scripts path', 'scrollable', |
|
1465 'selectable( identifiers)?', 'selected cell', |
|
1466 'selected( data)? columns?', 'selected data items?', |
|
1467 'selected( data)? rows?', 'selected item identifier', |
|
1468 'selection by rect', 'send action on arrow key', |
|
1469 'sends action when done editing', 'separates columns', |
|
1470 'separator item', 'sequence number', 'services menu', |
|
1471 'shared frameworks path', 'shared support path', |
|
1472 'sheet', 'shift key down', 'shows alpha', |
|
1473 'shows state by', 'size( mode)?', |
|
1474 'smart insert delete enabled', 'sort case sensitivity', |
|
1475 'sort column', 'sort order', 'sort type', |
|
1476 'sorted( data rows)?', 'sound', 'source( mask)?', |
|
1477 'spell checking enabled', 'starting page', 'state', |
|
1478 'string value', 'sub menu', 'super menu', 'super view', |
|
1479 'tab key traverses cells', 'tab state', 'tab type', |
|
1480 'tab view', 'table view', 'tag', 'target( printer)?', |
|
1481 'text color', 'text container insert', |
|
1482 'text container origin', 'text returned', |
|
1483 'tick mark position', 'time stamp', |
|
1484 'title(d| (cell|font|height|position|rect))?', |
|
1485 'tool tip', 'toolbar', 'trailing offset', 'transparent', |
|
1486 'treat packages as directories', 'truncated labels', |
|
1487 'types', 'unmodified characters', 'update views', |
|
1488 'use sort indicator', 'user defaults', |
|
1489 'uses data source', 'uses ruler', |
|
1490 'uses threaded animation', |
|
1491 'uses title from previous column', 'value wraps', |
|
1492 'version', |
|
1493 'vertical( (line scroll|page scroll|ruler view))?', |
|
1494 'vertically resizable', 'view', |
|
1495 'visible( document rect)?', 'volume', 'width', 'window', |
|
1496 'windows menu', 'wraps', 'zoomable', 'zoomed'] |
|
1497 |
|
1498 tokens = { |
|
1499 'root': [ |
|
1500 (r'\s+', Text), |
|
1501 (ur'¬\n', String.Escape), |
|
1502 (r"'s\s+", Text), # This is a possessive, consider moving |
|
1503 (r'(--|#).*?$', Comment), |
|
1504 (r'\(\*', Comment.Multiline, 'comment'), |
|
1505 (r'[\(\){}!,.:]', Punctuation), |
|
1506 (ur'(«)([^»]+)(»)', |
|
1507 bygroups(Text, Name.Builtin, Text)), |
|
1508 (r'\b((?:considering|ignoring)\s*)' |
|
1509 r'(application responses|case|diacriticals|hyphens|' |
|
1510 r'numeric strings|punctuation|white space)', |
|
1511 bygroups(Keyword, Name.Builtin)), |
|
1512 (ur'(-|\*|\+|&|≠|>=?|<=?|=|≥|≤|/|÷|\^)', Operator), |
|
1513 (r"\b(%s)\b" % '|'.join(Operators), Operator.Word), |
|
1514 (r'^(\s*(?:on|end)\s+)' |
|
1515 r'(%s)' % '|'.join(StudioEvents), |
|
1516 bygroups(Keyword, Name.Function)), |
|
1517 (r'^(\s*)(in|on|script|to)(\s+)', bygroups(Text, Keyword, Text)), |
|
1518 (r'\b(as )(%s)\b' % '|'.join(Classes), |
|
1519 bygroups(Keyword, Name.Class)), |
|
1520 (r'\b(%s)\b' % '|'.join(Literals), Name.Constant), |
|
1521 (r'\b(%s)\b' % '|'.join(Commands), Name.Builtin), |
|
1522 (r'\b(%s)\b' % '|'.join(Control), Keyword), |
|
1523 (r'\b(%s)\b' % '|'.join(Declarations), Keyword), |
|
1524 (r'\b(%s)\b' % '|'.join(Reserved), Name.Builtin), |
|
1525 (r'\b(%s)s?\b' % '|'.join(BuiltIn), Name.Builtin), |
|
1526 (r'\b(%s)\b' % '|'.join(HandlerParams), Name.Builtin), |
|
1527 (r'\b(%s)\b' % '|'.join(StudioProperties), Name.Attribute), |
|
1528 (r'\b(%s)s?\b' % '|'.join(StudioClasses), Name.Builtin), |
|
1529 (r'\b(%s)\b' % '|'.join(StudioCommands), Name.Builtin), |
|
1530 (r'\b(%s)\b' % '|'.join(References), Name.Builtin), |
|
1531 (r'"(\\\\|\\"|[^"])*"', String.Double), |
|
1532 (r'\b(%s)\b' % Identifiers, Name.Variable), |
|
1533 (r'[-+]?(\d+\.\d*|\d*\.\d+)(E[-+][0-9]+)?', Number.Float), |
|
1534 (r'[-+]?\d+', Number.Integer), |
|
1535 ], |
|
1536 'comment': [ |
|
1537 ('\(\*', Comment.Multiline, '#push'), |
|
1538 ('\*\)', Comment.Multiline, '#pop'), |
|
1539 ('[^*(]+', Comment.Multiline), |
|
1540 ('[*(]', Comment.Multiline), |
|
1541 ], |
|
1542 } |
|
1543 |
|
1544 |
|
1545 class ModelicaLexer(RegexLexer): |
|
1546 """ |
|
1547 For `Modelica <http://www.modelica.org/>`_ source code. |
|
1548 |
|
1549 *New in Pygments 1.1.* |
|
1550 """ |
|
1551 name = 'Modelica' |
|
1552 aliases = ['modelica'] |
|
1553 filenames = ['*.mo'] |
|
1554 mimetypes = ['text/x-modelica'] |
|
1555 |
|
1556 flags = re.IGNORECASE | re.DOTALL |
|
1557 |
|
1558 tokens = { |
|
1559 'whitespace': [ |
|
1560 (r'\n', Text), |
|
1561 (r'\s+', Text), |
|
1562 (r'\\\n', Text), # line continuation |
|
1563 (r'//(\n|(.|\n)*?[^\\]\n)', Comment), |
|
1564 (r'/(\\\n)?[*](.|\n)*?[*](\\\n)?/', Comment), |
|
1565 ], |
|
1566 'statements': [ |
|
1567 (r'"', String, 'string'), |
|
1568 (r'(\d+\.\d*|\.\d+|\d+|\d.)[eE][+-]?\d+[lL]?', Number.Float), |
|
1569 (r'(\d+\.\d*|\.\d+)', Number.Float), |
|
1570 (r'\d+[Ll]?', Number.Integer), |
|
1571 (r'[~!%^&*+=|?:<>/-]', Operator), |
|
1572 (r'[()\[\]{},.;]', Punctuation), |
|
1573 (r'(true|false|NULL|Real|Integer|Boolean)\b', Name.Builtin), |
|
1574 (r"([a-zA-Z_][\w]*|'[a-zA-Z_\+\-\*\/\^][\w]*')" |
|
1575 r"(\.([a-zA-Z_][\w]*|'[a-zA-Z_\+\-\*\/\^][\w]*'))+", Name.Class), |
|
1576 (r"('[\w\+\-\*\/\^]+'|\w+)", Name) ], |
|
1577 'root': [ |
|
1578 include('whitespace'), |
|
1579 include('keywords'), |
|
1580 include('functions'), |
|
1581 include('operators'), |
|
1582 include('classes'), |
|
1583 (r'("<html>|<html>)', Name.Tag, 'html-content'), |
|
1584 include('statements') |
|
1585 ], |
|
1586 'keywords': [ |
|
1587 (r'(algorithm|annotation|break|connect|constant|constrainedby|' |
|
1588 r'discrete|each|else|elseif|elsewhen|encapsulated|enumeration|' |
|
1589 r'end|equation|exit|expandable|extends|' |
|
1590 r'external|false|final|flow|for|if|import|in|inner|input|' |
|
1591 r'loop|nondiscrete|outer|output|parameter|partial|' |
|
1592 r'protected|public|redeclare|replaceable|time|then|true|' |
|
1593 r'when|while|within)\b', Keyword) |
|
1594 ], |
|
1595 'functions': [ |
|
1596 (r'(abs|acos|acosh|asin|asinh|atan|atan2|atan3|ceil|cos|cosh|' |
|
1597 r'cross|div|exp|floor|log|log10|mod|rem|sign|sin|sinh|size|' |
|
1598 r'sqrt|tan|tanh|zeros)\b', Name.Function) |
|
1599 ], |
|
1600 'operators': [ |
|
1601 (r'(and|assert|cardinality|change|delay|der|edge|initial|' |
|
1602 r'noEvent|not|or|pre|reinit|return|sample|smooth|' |
|
1603 r'terminal|terminate)\b', Name.Builtin) |
|
1604 ], |
|
1605 'classes': [ |
|
1606 (r'(block|class|connector|function|model|package|' |
|
1607 r'record|type)\b', Name.Class) |
|
1608 ], |
|
1609 'string': [ |
|
1610 (r'"', String, '#pop'), |
|
1611 (r'\\([\\abfnrtv"\']|x[a-fA-F0-9]{2,4}|[0-7]{1,3})', |
|
1612 String.Escape), |
|
1613 (r'[^\\"\n]+', String), # all other characters |
|
1614 (r'\\\n', String), # line continuation |
|
1615 (r'\\', String) # stray backslash |
|
1616 ], |
|
1617 'html-content': [ |
|
1618 (r'<\s*/\s*html\s*>', Name.Tag, '#pop'), |
|
1619 (r'.+?(?=<\s*/\s*html\s*>)', using(HtmlLexer)), |
|
1620 ] |
|
1621 } |
|
1622 |
|
1623 |
|
1624 class RebolLexer(RegexLexer): |
|
1625 """ |
|
1626 A `REBOL <http://www.rebol.com/>`_ lexer. |
|
1627 |
|
1628 *New in Pygments 1.1.* |
|
1629 """ |
|
1630 name = 'REBOL' |
|
1631 aliases = ['rebol'] |
|
1632 filenames = ['*.r', '*.r3'] |
|
1633 mimetypes = ['text/x-rebol'] |
|
1634 |
|
1635 flags = re.IGNORECASE | re.MULTILINE |
|
1636 |
|
1637 re.IGNORECASE |
|
1638 |
|
1639 escape_re = r'(?:\^\([0-9a-fA-F]{1,4}\)*)' |
|
1640 |
|
1641 def word_callback(lexer, match): |
|
1642 word = match.group() |
|
1643 |
|
1644 if re.match(".*:$", word): |
|
1645 yield match.start(), Generic.Subheading, word |
|
1646 elif re.match( |
|
1647 r'(native|alias|all|any|as-string|as-binary|bind|bound\?|case|' |
|
1648 r'catch|checksum|comment|debase|dehex|exclude|difference|disarm|' |
|
1649 r'either|else|enbase|foreach|remove-each|form|free|get|get-env|if|' |
|
1650 r'in|intersect|loop|minimum-of|maximum-of|mold|new-line|' |
|
1651 r'new-line\?|not|now|prin|print|reduce|compose|construct|repeat|' |
|
1652 r'reverse|save|script\?|set|shift|switch|throw|to-hex|trace|try|' |
|
1653 r'type\?|union|unique|unless|unprotect|unset|until|use|value\?|' |
|
1654 r'while|compress|decompress|secure|open|close|read|read-io|' |
|
1655 r'write-io|write|update|query|wait|input\?|exp|log-10|log-2|' |
|
1656 r'log-e|square-root|cosine|sine|tangent|arccosine|arcsine|' |
|
1657 r'arctangent|protect|lowercase|uppercase|entab|detab|connected\?|' |
|
1658 r'browse|launch|stats|get-modes|set-modes|to-local-file|' |
|
1659 r'to-rebol-file|encloak|decloak|create-link|do-browser|bind\?|' |
|
1660 r'hide|draw|show|size-text|textinfo|offset-to-caret|' |
|
1661 r'caret-to-offset|local-request-file|rgb-to-hsv|hsv-to-rgb|' |
|
1662 r'crypt-strength\?|dh-make-key|dh-generate-key|dh-compute-key|' |
|
1663 r'dsa-make-key|dsa-generate-key|dsa-make-signature|' |
|
1664 r'dsa-verify-signature|rsa-make-key|rsa-generate-key|' |
|
1665 r'rsa-encrypt)$', word): |
|
1666 yield match.start(), Name.Builtin, word |
|
1667 elif re.match( |
|
1668 r'(add|subtract|multiply|divide|remainder|power|and~|or~|xor~|' |
|
1669 r'minimum|maximum|negate|complement|absolute|random|head|tail|' |
|
1670 r'next|back|skip|at|pick|first|second|third|fourth|fifth|sixth|' |
|
1671 r'seventh|eighth|ninth|tenth|last|path|find|select|make|to|copy\*|' |
|
1672 r'insert|remove|change|poke|clear|trim|sort|min|max|abs|cp|' |
|
1673 r'copy)$', word): |
|
1674 yield match.start(), Name.Function, word |
|
1675 elif re.match( |
|
1676 r'(error|source|input|license|help|install|echo|Usage|with|func|' |
|
1677 r'throw-on-error|function|does|has|context|probe|\?\?|as-pair|' |
|
1678 r'mod|modulo|round|repend|about|set-net|append|join|rejoin|reform|' |
|
1679 r'remold|charset|array|replace|move|extract|forskip|forall|alter|' |
|
1680 r'first+|also|take|for|forever|dispatch|attempt|what-dir|' |
|
1681 r'change-dir|clean-path|list-dir|dirize|rename|split-path|delete|' |
|
1682 r'make-dir|delete-dir|in-dir|confirm|dump-obj|upgrade|what|' |
|
1683 r'build-tag|process-source|build-markup|decode-cgi|read-cgi|' |
|
1684 r'write-user|save-user|set-user-name|protect-system|parse-xml|' |
|
1685 r'cvs-date|cvs-version|do-boot|get-net-info|desktop|layout|' |
|
1686 r'scroll-para|get-face|alert|set-face|uninstall|unfocus|' |
|
1687 r'request-dir|center-face|do-events|net-error|decode-url|' |
|
1688 r'parse-header|parse-header-date|parse-email-addrs|import-email|' |
|
1689 r'send|build-attach-body|resend|show-popup|hide-popup|open-events|' |
|
1690 r'find-key-face|do-face|viewtop|confine|find-window|' |
|
1691 r'insert-event-func|remove-event-func|inform|dump-pane|dump-face|' |
|
1692 r'flag-face|deflag-face|clear-fields|read-net|vbug|path-thru|' |
|
1693 r'read-thru|load-thru|do-thru|launch-thru|load-image|' |
|
1694 r'request-download|do-face-alt|set-font|set-para|get-style|' |
|
1695 r'set-style|make-face|stylize|choose|hilight-text|hilight-all|' |
|
1696 r'unlight-text|focus|scroll-drag|clear-face|reset-face|scroll-face|' |
|
1697 r'resize-face|load-stock|load-stock-block|notify|request|flash|' |
|
1698 r'request-color|request-pass|request-text|request-list|' |
|
1699 r'request-date|request-file|dbug|editor|link-relative-path|' |
|
1700 r'emailer|parse-error)$', word): |
|
1701 yield match.start(), Keyword.Namespace, word |
|
1702 elif re.match( |
|
1703 r'(halt|quit|do|load|q|recycle|call|run|ask|parse|view|unview|' |
|
1704 r'return|exit|break)$', word): |
|
1705 yield match.start(), Name.Exception, word |
|
1706 elif re.match('REBOL$', word): |
|
1707 yield match.start(), Generic.Heading, word |
|
1708 elif re.match("to-.*", word): |
|
1709 yield match.start(), Keyword, word |
|
1710 elif re.match('(\+|-|\*|/|//|\*\*|and|or|xor|=\?|=|==|<>|<|>|<=|>=)$', |
|
1711 word): |
|
1712 yield match.start(), Operator, word |
|
1713 elif re.match(".*\?$", word): |
|
1714 yield match.start(), Keyword, word |
|
1715 elif re.match(".*\!$", word): |
|
1716 yield match.start(), Keyword.Type, word |
|
1717 elif re.match("'.*", word): |
|
1718 yield match.start(), Name.Variable.Instance, word # lit-word |
|
1719 elif re.match("#.*", word): |
|
1720 yield match.start(), Name.Label, word # issue |
|
1721 elif re.match("%.*", word): |
|
1722 yield match.start(), Name.Decorator, word # file |
|
1723 else: |
|
1724 yield match.start(), Name.Variable, word |
|
1725 |
|
1726 tokens = { |
|
1727 'root': [ |
|
1728 (r'\s+', Text), |
|
1729 (r'#"', String.Char, 'char'), |
|
1730 (r'#{[0-9a-fA-F]*}', Number.Hex), |
|
1731 (r'2#{', Number.Hex, 'bin2'), |
|
1732 (r'64#{[0-9a-zA-Z+/=\s]*}', Number.Hex), |
|
1733 (r'"', String, 'string'), |
|
1734 (r'{', String, 'string2'), |
|
1735 (r';#+.*\n', Comment.Special), |
|
1736 (r';\*+.*\n', Comment.Preproc), |
|
1737 (r';.*\n', Comment), |
|
1738 (r'%"', Name.Decorator, 'stringFile'), |
|
1739 (r'%[^(\^{^")\s\[\]]+', Name.Decorator), |
|
1740 (r'<[a-zA-Z0-9:._-]*>', Name.Tag), |
|
1741 (r'<[^(<>\s")]+', Name.Tag, 'tag'), |
|
1742 (r'[+-]?([a-zA-Z]{1,3})?\$\d+(\.\d+)?', Number.Float), # money |
|
1743 (r'[+-]?\d+\:\d+(\:\d+)?(\.\d+)?', String.Other), # time |
|
1744 (r'\d+\-[0-9a-zA-Z]+\-\d+(\/\d+\:\d+(\:\d+)?' |
|
1745 r'([\.\d+]?([+-]?\d+:\d+)?)?)?', String.Other), # date |
|
1746 (r'\d+(\.\d+)+\.\d+', Keyword.Constant), # tuple |
|
1747 (r'\d+[xX]\d+', Keyword.Constant), # pair |
|
1748 (r'[+-]?\d+(\'\d+)?([\.,]\d*)?[eE][+-]?\d+', Number.Float), |
|
1749 (r'[+-]?\d+(\'\d+)?[\.,]\d*', Number.Float), |
|
1750 (r'[+-]?\d+(\'\d+)?', Number), |
|
1751 (r'[\[\]\(\)]', Generic.Strong), |
|
1752 (r'[a-zA-Z]+[^(\^{"\s:)]*://[^(\^{"\s)]*', Name.Decorator), # url |
|
1753 (r'mailto:[^(\^{"@\s)]+@[^(\^{"@\s)]+', Name.Decorator), # url |
|
1754 (r'[^(\^{"@\s)]+@[^(\^{"@\s)]+', Name.Decorator), # email |
|
1755 (r'comment\s', Comment, 'comment'), |
|
1756 (r'/[^(\^{^")\s/[\]]*', Name.Attribute), |
|
1757 (r'([^(\^{^")\s/[\]]+)(?=[:({"\s/\[\]])', word_callback), |
|
1758 (r'([^(\^{^")\s]+)', Text), |
|
1759 ], |
|
1760 'string': [ |
|
1761 (r'[^(\^")]+', String), |
|
1762 (escape_re, String.Escape), |
|
1763 (r'[\(|\)]+', String), |
|
1764 (r'\^.', String.Escape), |
|
1765 (r'"', String, '#pop'), |
|
1766 ], |
|
1767 'string2': [ |
|
1768 (r'[^(\^{^})]+', String), |
|
1769 (escape_re, String.Escape), |
|
1770 (r'[\(|\)]+', String), |
|
1771 (r'\^.', String.Escape), |
|
1772 (r'{', String, '#push'), |
|
1773 (r'}', String, '#pop'), |
|
1774 ], |
|
1775 'stringFile': [ |
|
1776 (r'[^(\^")]+', Name.Decorator), |
|
1777 (escape_re, Name.Decorator), |
|
1778 (r'\^.', Name.Decorator), |
|
1779 (r'"', Name.Decorator, '#pop'), |
|
1780 ], |
|
1781 'char': [ |
|
1782 (escape_re + '"', String.Char, '#pop'), |
|
1783 (r'\^."', String.Char, '#pop'), |
|
1784 (r'."', String.Char, '#pop'), |
|
1785 ], |
|
1786 'tag': [ |
|
1787 (escape_re, Name.Tag), |
|
1788 (r'"', Name.Tag, 'tagString'), |
|
1789 (r'[^(<>\r\n")]+', Name.Tag), |
|
1790 (r'>', Name.Tag, '#pop'), |
|
1791 ], |
|
1792 'tagString': [ |
|
1793 (r'[^(\^")]+', Name.Tag), |
|
1794 (escape_re, Name.Tag), |
|
1795 (r'[\(|\)]+', Name.Tag), |
|
1796 (r'\^.', Name.Tag), |
|
1797 (r'"', Name.Tag, '#pop'), |
|
1798 ], |
|
1799 'tuple': [ |
|
1800 (r'(\d+\.)+', Keyword.Constant), |
|
1801 (r'\d+', Keyword.Constant, '#pop'), |
|
1802 ], |
|
1803 'bin2': [ |
|
1804 (r'\s+', Number.Hex), |
|
1805 (r'([0-1]\s*){8}', Number.Hex), |
|
1806 (r'}', Number.Hex, '#pop'), |
|
1807 ], |
|
1808 'comment': [ |
|
1809 (r'"', Comment, 'commentString1'), |
|
1810 (r'{', Comment, 'commentString2'), |
|
1811 (r'\[', Comment, 'commentBlock'), |
|
1812 (r'[^(\s{\"\[]+', Comment, '#pop'), |
|
1813 ], |
|
1814 'commentString1': [ |
|
1815 (r'[^(\^")]+', Comment), |
|
1816 (escape_re, Comment), |
|
1817 (r'[\(|\)]+', Comment), |
|
1818 (r'\^.', Comment), |
|
1819 (r'"', Comment, '#pop'), |
|
1820 ], |
|
1821 'commentString2': [ |
|
1822 (r'[^(\^{^})]+', Comment), |
|
1823 (escape_re, Comment), |
|
1824 (r'[\(|\)]+', Comment), |
|
1825 (r'\^.', Comment), |
|
1826 (r'{', Comment, '#push'), |
|
1827 (r'}', Comment, '#pop'), |
|
1828 ], |
|
1829 'commentBlock': [ |
|
1830 (r'\[',Comment, '#push'), |
|
1831 (r'\]',Comment, '#pop'), |
|
1832 (r'[^(\[\])]*', Comment), |
|
1833 ], |
|
1834 } |
|
1835 |
|
1836 |
|
1837 class ABAPLexer(RegexLexer): |
|
1838 """ |
|
1839 Lexer for ABAP, SAP's integrated language. |
|
1840 |
|
1841 *New in Pygments 1.1.* |
|
1842 """ |
|
1843 name = 'ABAP' |
|
1844 aliases = ['abap'] |
|
1845 filenames = ['*.abap'] |
|
1846 mimetypes = ['text/x-abap'] |
|
1847 |
|
1848 flags = re.IGNORECASE | re.MULTILINE |
|
1849 |
|
1850 tokens = { |
|
1851 'common': [ |
|
1852 (r'\s+', Text), |
|
1853 (r'^\*.*$', Comment.Single), |
|
1854 (r'\".*?\n', Comment.Single), |
|
1855 ], |
|
1856 'variable-names': [ |
|
1857 (r'<[\S_]+>', Name.Variable), |
|
1858 (r'[\w][\w_~]*(?:(\[\])|->\*)?', Name.Variable), |
|
1859 ], |
|
1860 'root': [ |
|
1861 include('common'), |
|
1862 #function calls |
|
1863 (r'(CALL\s+(?:BADI|CUSTOMER-FUNCTION|FUNCTION))(\s+)(\'?\S+\'?)', |
|
1864 bygroups(Keyword, Text, Name.Function)), |
|
1865 (r'(CALL\s+(?:DIALOG|SCREEN|SUBSCREEN|SELECTION-SCREEN|' |
|
1866 r'TRANSACTION|TRANSFORMATION))\b', |
|
1867 Keyword), |
|
1868 (r'(FORM|PERFORM)(\s+)([\w_]+)', |
|
1869 bygroups(Keyword, Text, Name.Function)), |
|
1870 (r'(PERFORM)(\s+)(\()([\w_]+)(\))', |
|
1871 bygroups(Keyword, Text, Punctuation, Name.Variable, Punctuation )), |
|
1872 (r'(MODULE)(\s+)(\S+)(\s+)(INPUT|OUTPUT)', |
|
1873 bygroups(Keyword, Text, Name.Function, Text, Keyword)), |
|
1874 |
|
1875 # method implementation |
|
1876 (r'(METHOD)(\s+)([\w_~]+)', |
|
1877 bygroups(Keyword, Text, Name.Function)), |
|
1878 # method calls |
|
1879 (r'(\s+)([\w_\-]+)([=\-]>)([\w_\-~]+)', |
|
1880 bygroups(Text, Name.Variable, Operator, Name.Function)), |
|
1881 # call methodnames returning style |
|
1882 (r'(?<=(=|-)>)([\w_\-~]+)(?=\()', Name.Function), |
|
1883 |
|
1884 # keywords with dashes in them. |
|
1885 # these need to be first, because for instance the -ID part |
|
1886 # of MESSAGE-ID wouldn't get highlighted if MESSAGE was |
|
1887 # first in the list of keywords. |
|
1888 (r'(ADD-CORRESPONDING|AUTHORITY-CHECK|' |
|
1889 r'CLASS-DATA|CLASS-EVENTS|CLASS-METHODS|CLASS-POOL|' |
|
1890 r'DELETE-ADJACENT|DIVIDE-CORRESPONDING|' |
|
1891 r'EDITOR-CALL|ENHANCEMENT-POINT|ENHANCEMENT-SECTION|EXIT-COMMAND|' |
|
1892 r'FIELD-GROUPS|FIELD-SYMBOLS|FUNCTION-POOL|' |
|
1893 r'INTERFACE-POOL|INVERTED-DATE|' |
|
1894 r'LOAD-OF-PROGRAM|LOG-POINT|' |
|
1895 r'MESSAGE-ID|MOVE-CORRESPONDING|MULTIPLY-CORRESPONDING|' |
|
1896 r'NEW-LINE|NEW-PAGE|NEW-SECTION|NO-EXTENSION|' |
|
1897 r'OUTPUT-LENGTH|PRINT-CONTROL|' |
|
1898 r'SELECT-OPTIONS|START-OF-SELECTION|SUBTRACT-CORRESPONDING|' |
|
1899 r'SYNTAX-CHECK|SYSTEM-EXCEPTIONS|' |
|
1900 r'TYPE-POOL|TYPE-POOLS' |
|
1901 r')\b', Keyword), |
|
1902 |
|
1903 # keyword kombinations |
|
1904 (r'CREATE\s+(PUBLIC|PRIVATE|DATA|OBJECT)|' |
|
1905 r'((PUBLIC|PRIVATE|PROTECTED)\s+SECTION|' |
|
1906 r'(TYPE|LIKE)(\s+(LINE\s+OF|REF\s+TO|' |
|
1907 r'(SORTED|STANDARD|HASHED)\s+TABLE\s+OF))?|' |
|
1908 r'FROM\s+(DATABASE|MEMORY)|CALL\s+METHOD|' |
|
1909 r'(GROUP|ORDER) BY|HAVING|SEPARATED BY|' |
|
1910 r'GET\s+(BADI|BIT|CURSOR|DATASET|LOCALE|PARAMETER|' |
|
1911 r'PF-STATUS|(PROPERTY|REFERENCE)\s+OF|' |
|
1912 r'RUN\s+TIME|TIME\s+(STAMP)?)?|' |
|
1913 r'SET\s+(BIT|BLANK\s+LINES|COUNTRY|CURSOR|DATASET|EXTENDED\s+CHECK|' |
|
1914 r'HANDLER|HOLD\s+DATA|LANGUAGE|LEFT\s+SCROLL-BOUNDARY|' |
|
1915 r'LOCALE|MARGIN|PARAMETER|PF-STATUS|PROPERTY\s+OF|' |
|
1916 r'RUN\s+TIME\s+(ANALYZER|CLOCK\s+RESOLUTION)|SCREEN|' |
|
1917 r'TITLEBAR|UPADTE\s+TASK\s+LOCAL|USER-COMMAND)|' |
|
1918 r'CONVERT\s+((INVERTED-)?DATE|TIME|TIME\s+STAMP|TEXT)|' |
|
1919 r'(CLOSE|OPEN)\s+(DATASET|CURSOR)|' |
|
1920 r'(TO|FROM)\s+(DATA BUFFER|INTERNAL TABLE|MEMORY ID|' |
|
1921 r'DATABASE|SHARED\s+(MEMORY|BUFFER))|' |
|
1922 r'DESCRIBE\s+(DISTANCE\s+BETWEEN|FIELD|LIST|TABLE)|' |
|
1923 r'FREE\s(MEMORY|OBJECT)?|' |
|
1924 r'PROCESS\s+(BEFORE\s+OUTPUT|AFTER\s+INPUT|' |
|
1925 r'ON\s+(VALUE-REQUEST|HELP-REQUEST))|' |
|
1926 r'AT\s+(LINE-SELECTION|USER-COMMAND|END\s+OF|NEW)|' |
|
1927 r'AT\s+SELECTION-SCREEN(\s+(ON(\s+(BLOCK|(HELP|VALUE)-REQUEST\s+FOR|' |
|
1928 r'END\s+OF|RADIOBUTTON\s+GROUP))?|OUTPUT))?|' |
|
1929 r'SELECTION-SCREEN:?\s+((BEGIN|END)\s+OF\s+((TABBED\s+)?BLOCK|LINE|' |
|
1930 r'SCREEN)|COMMENT|FUNCTION\s+KEY|' |
|
1931 r'INCLUDE\s+BLOCKS|POSITION|PUSHBUTTON|' |
|
1932 r'SKIP|ULINE)|' |
|
1933 r'LEAVE\s+(LIST-PROCESSING|PROGRAM|SCREEN|' |
|
1934 r'TO LIST-PROCESSING|TO TRANSACTION)' |
|
1935 r'(ENDING|STARTING)\s+AT|' |
|
1936 r'FORMAT\s+(COLOR|INTENSIFIED|INVERSE|HOTSPOT|INPUT|FRAMES|RESET)|' |
|
1937 r'AS\s+(CHECKBOX|SUBSCREEN|WINDOW)|' |
|
1938 r'WITH\s+(((NON-)?UNIQUE)?\s+KEY|FRAME)|' |
|
1939 r'(BEGIN|END)\s+OF|' |
|
1940 r'DELETE(\s+ADJACENT\s+DUPLICATES\sFROM)?|' |
|
1941 r'COMPARING(\s+ALL\s+FIELDS)?|' |
|
1942 r'INSERT(\s+INITIAL\s+LINE\s+INTO|\s+LINES\s+OF)?|' |
|
1943 r'IN\s+((BYTE|CHARACTER)\s+MODE|PROGRAM)|' |
|
1944 r'END-OF-(DEFINITION|PAGE|SELECTION)|' |
|
1945 r'WITH\s+FRAME(\s+TITLE)|' |
|
1946 |
|
1947 # simple kombinations |
|
1948 r'AND\s+(MARK|RETURN)|CLIENT\s+SPECIFIED|CORRESPONDING\s+FIELDS\s+OF|' |
|
1949 r'IF\s+FOUND|FOR\s+EVENT|INHERITING\s+FROM|LEAVE\s+TO\s+SCREEN|' |
|
1950 r'LOOP\s+AT\s+(SCREEN)?|LOWER\s+CASE|MATCHCODE\s+OBJECT|MODIF\s+ID|' |
|
1951 r'MODIFY\s+SCREEN|NESTING\s+LEVEL|NO\s+INTERVALS|OF\s+STRUCTURE|' |
|
1952 r'RADIOBUTTON\s+GROUP|RANGE\s+OF|REF\s+TO|SUPPRESS DIALOG|' |
|
1953 r'TABLE\s+OF|UPPER\s+CASE|TRANSPORTING\s+NO\s+FIELDS|' |
|
1954 r'VALUE\s+CHECK|VISIBLE\s+LENGTH|HEADER\s+LINE)\b', Keyword), |
|
1955 |
|
1956 # single word keywords. |
|
1957 (r'(^|(?<=(\s|\.)))(ABBREVIATED|ADD|ALIASES|APPEND|ASSERT|' |
|
1958 r'ASSIGN(ING)?|AT(\s+FIRST)?|' |
|
1959 r'BACK|BLOCK|BREAK-POINT|' |
|
1960 r'CASE|CATCH|CHANGING|CHECK|CLASS|CLEAR|COLLECT|COLOR|COMMIT|' |
|
1961 r'CREATE|COMMUNICATION|COMPONENTS?|COMPUTE|CONCATENATE|CONDENSE|' |
|
1962 r'CONSTANTS|CONTEXTS|CONTINUE|CONTROLS|' |
|
1963 r'DATA|DECIMALS|DEFAULT|DEFINE|DEFINITION|DEFERRED|DEMAND|' |
|
1964 r'DETAIL|DIRECTORY|DIVIDE|DO|' |
|
1965 r'ELSE(IF)?|ENDAT|ENDCASE|ENDCLASS|ENDDO|ENDFORM|ENDFUNCTION|' |
|
1966 r'ENDIF|ENDLOOP|ENDMETHOD|ENDMODULE|ENDSELECT|ENDTRY|' |
|
1967 r'ENHANCEMENT|EVENTS|EXCEPTIONS|EXIT|EXPORT|EXPORTING|EXTRACT|' |
|
1968 r'FETCH|FIELDS?|FIND|FOR|FORM|FORMAT|FREE|FROM|' |
|
1969 r'HIDE|' |
|
1970 r'ID|IF|IMPORT|IMPLEMENTATION|IMPORTING|IN|INCLUDE|INCLUDING|' |
|
1971 r'INDEX|INFOTYPES|INITIALIZATION|INTERFACE|INTERFACES|INTO|' |
|
1972 r'LENGTH|LINES|LOAD|LOCAL|' |
|
1973 r'JOIN|' |
|
1974 r'KEY|' |
|
1975 r'MAXIMUM|MESSAGE|METHOD[S]?|MINIMUM|MODULE|MODIFY|MOVE|MULTIPLY|' |
|
1976 r'NODES|' |
|
1977 r'OBLIGATORY|OF|OFF|ON|OVERLAY|' |
|
1978 r'PACK|PARAMETERS|PERCENTAGE|POSITION|PROGRAM|PROVIDE|PUBLIC|PUT|' |
|
1979 r'RAISE|RAISING|RANGES|READ|RECEIVE|REFRESH|REJECT|REPORT|RESERVE|' |
|
1980 r'RESUME|RETRY|RETURN|RETURNING|RIGHT|ROLLBACK|' |
|
1981 r'SCROLL|SEARCH|SELECT|SHIFT|SINGLE|SKIP|SORT|SPLIT|STATICS|STOP|' |
|
1982 r'SUBMIT|SUBTRACT|SUM|SUMMARY|SUMMING|SUPPLY|' |
|
1983 r'TABLE|TABLES|TIMES|TITLE|TO|TOP-OF-PAGE|TRANSFER|TRANSLATE|TRY|TYPES|' |
|
1984 r'ULINE|UNDER|UNPACK|UPDATE|USING|' |
|
1985 r'VALUE|VALUES|VIA|' |
|
1986 r'WAIT|WHEN|WHERE|WHILE|WITH|WINDOW|WRITE)\b', Keyword), |
|
1987 |
|
1988 # builtins |
|
1989 (r'(abs|acos|asin|atan|' |
|
1990 r'boolc|boolx|bit_set|' |
|
1991 r'char_off|charlen|ceil|cmax|cmin|condense|contains|' |
|
1992 r'contains_any_of|contains_any_not_of|concat_lines_of|cos|cosh|' |
|
1993 r'count|count_any_of|count_any_not_of|' |
|
1994 r'dbmaxlen|distance|' |
|
1995 r'escape|exp|' |
|
1996 r'find|find_end|find_any_of|find_any_not_of|floor|frac|from_mixed|' |
|
1997 r'insert|' |
|
1998 r'lines|log|log10|' |
|
1999 r'match|matches|' |
|
2000 r'nmax|nmin|numofchar|' |
|
2001 r'repeat|replace|rescale|reverse|round|' |
|
2002 r'segment|shift_left|shift_right|sign|sin|sinh|sqrt|strlen|' |
|
2003 r'substring|substring_after|substring_from|substring_before|substring_to|' |
|
2004 r'tan|tanh|to_upper|to_lower|to_mixed|translate|trunc|' |
|
2005 r'xstrlen)(\()\b', bygroups(Name.Builtin, Punctuation)), |
|
2006 |
|
2007 (r'&[0-9]', Name), |
|
2008 (r'[0-9]+', Number.Integer), |
|
2009 |
|
2010 # operators which look like variable names before |
|
2011 # parsing variable names. |
|
2012 (r'(?<=(\s|.))(AND|EQ|NE|GT|LT|GE|LE|CO|CN|CA|NA|CS|NOT|NS|CP|NP|' |
|
2013 r'BYTE-CO|BYTE-CN|BYTE-CA|BYTE-NA|BYTE-CS|BYTE-NS|' |
|
2014 r'IS\s+(NOT\s+)?(INITIAL|ASSIGNED|REQUESTED|BOUND))\b', Operator), |
|
2015 |
|
2016 include('variable-names'), |
|
2017 |
|
2018 # standard oparators after variable names, |
|
2019 # because < and > are part of field symbols. |
|
2020 (r'[?*<>=\-+]', Operator), |
|
2021 (r"'(''|[^'])*'", String.Single), |
|
2022 (r'[/;:()\[\],\.]', Punctuation) |
|
2023 ], |
|
2024 } |
|
2025 |
|
2026 |
|
2027 class NewspeakLexer(RegexLexer): |
|
2028 """ |
|
2029 For `Newspeak <http://newspeaklanguage.org/>` syntax. |
|
2030 """ |
|
2031 name = 'Newspeak' |
|
2032 filenames = ['*.ns2'] |
|
2033 aliases = ['newspeak', ] |
|
2034 mimetypes = ['text/x-newspeak'] |
|
2035 |
|
2036 tokens = { |
|
2037 'root' : [ |
|
2038 (r'\b(Newsqueak2)\b',Keyword.Declaration), |
|
2039 (r"'[^']*'",String), |
|
2040 (r'\b(class)(\s+)([a-zA-Z0-9_]+)(\s*)', |
|
2041 bygroups(Keyword.Declaration,Text,Name.Class,Text)), |
|
2042 (r'\b(mixin|self|super|private|public|protected|nil|true|false)\b', |
|
2043 Keyword), |
|
2044 (r'([a-zA-Z0-9_]+\:)(\s*)([a-zA-Z_]\w+)', |
|
2045 bygroups(Name.Function,Text,Name.Variable)), |
|
2046 (r'([a-zA-Z0-9_]+)(\s*)(=)', |
|
2047 bygroups(Name.Attribute,Text,Operator)), |
|
2048 (r'<[a-zA-Z0-9_]+>', Comment.Special), |
|
2049 include('expressionstat'), |
|
2050 include('whitespace') |
|
2051 ], |
|
2052 |
|
2053 'expressionstat': [ |
|
2054 (r'(\d+\.\d*|\.\d+|\d+[fF])[fF]?', Number.Float), |
|
2055 (r'\d+', Number.Integer), |
|
2056 (r':\w+',Name.Variable), |
|
2057 (r'(\w+)(::)', bygroups(Name.Variable, Operator)), |
|
2058 (r'\w+:', Name.Function), |
|
2059 (r'\w+', Name.Variable), |
|
2060 (r'\(|\)', Punctuation), |
|
2061 (r'\[|\]', Punctuation), |
|
2062 (r'\{|\}', Punctuation), |
|
2063 |
|
2064 (r'(\^|\+|\/|~|\*|<|>|=|@|%|\||&|\?|!|,|-|:)', Operator), |
|
2065 (r'\.|;', Punctuation), |
|
2066 include('whitespace'), |
|
2067 include('literals'), |
|
2068 ], |
|
2069 'literals': [ |
|
2070 (r'\$.', String), |
|
2071 (r"'[^']*'", String), |
|
2072 (r"#'[^']*'", String.Symbol), |
|
2073 (r"#\w+:?", String.Symbol), |
|
2074 (r"#(\+|\/|~|\*|<|>|=|@|%|\||&|\?|!|,|-)+", String.Symbol) |
|
2075 |
|
2076 ], |
|
2077 'whitespace' : [ |
|
2078 (r'\s+', Text), |
|
2079 (r'"[^"]*"', Comment) |
|
2080 ] |
|
2081 } |
|
2082 |