ThirdParty/Pygments/pygments/lexers/functional.py

changeset 2426
da76c71624de
parent 1705
b0fbc9300f2b
child 2525
8b507a9a2d40
equal deleted inserted replaced
2425:ace8a08028f3 2426:da76c71624de
3 pygments.lexers.functional 3 pygments.lexers.functional
4 ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4 ~~~~~~~~~~~~~~~~~~~~~~~~~~
5 5
6 Lexers for functional languages. 6 Lexers for functional languages.
7 7
8 :copyright: Copyright 2006-2012 by the Pygments team, see AUTHORS. 8 :copyright: Copyright 2006-2013 by the Pygments team, see AUTHORS.
9 :license: BSD, see LICENSE for details. 9 :license: BSD, see LICENSE for details.
10 """ 10 """
11 11
12 import re 12 import re
13 13
14 from pygments.lexer import Lexer, RegexLexer, bygroups, include, do_insertions 14 from pygments.lexer import Lexer, RegexLexer, bygroups, include, do_insertions
15 from pygments.token import Text, Comment, Operator, Keyword, Name, \ 15 from pygments.token import Text, Comment, Operator, Keyword, Name, \
16 String, Number, Punctuation, Literal, Generic, Error 16 String, Number, Punctuation, Literal, Generic, Error
17 17
18 __all__ = ['SchemeLexer', 'CommonLispLexer', 'HaskellLexer', 18 __all__ = ['RacketLexer', 'SchemeLexer', 'CommonLispLexer', 'HaskellLexer',
19 'LiterateHaskellLexer', 'SMLLexer', 'OcamlLexer', 'ErlangLexer', 19 'LiterateHaskellLexer', 'SMLLexer', 'OcamlLexer', 'ErlangLexer',
20 'ErlangShellLexer', 'OpaLexer', 'CoqLexer', 'NewLispLexer', 20 'ErlangShellLexer', 'OpaLexer', 'CoqLexer', 'NewLispLexer',
21 'ElixirLexer', 'ElixirConsoleLexer'] 21 'ElixirLexer', 'ElixirConsoleLexer', 'KokaLexer']
22
23
24 class RacketLexer(RegexLexer):
25 """
26 Lexer for `Racket <http://racket-lang.org/>`_ source code (formerly known as
27 PLT Scheme).
28
29 *New in Pygments 1.6.*
30 """
31
32 name = 'Racket'
33 aliases = ['racket', 'rkt']
34 filenames = ['*.rkt', '*.rktl']
35 mimetypes = ['text/x-racket', 'application/x-racket']
36
37 # From namespace-mapped-symbols
38 keywords = [
39 '#%app', '#%datum', '#%expression', '#%module-begin',
40 '#%plain-app', '#%plain-lambda', '#%plain-module-begin',
41 '#%provide', '#%require', '#%stratified-body', '#%top',
42 '#%top-interaction', '#%variable-reference', '...', 'and', 'begin',
43 'begin-for-syntax', 'begin0', 'case', 'case-lambda', 'cond',
44 'datum->syntax-object', 'define', 'define-for-syntax',
45 'define-struct', 'define-syntax', 'define-syntax-rule',
46 'define-syntaxes', 'define-values', 'define-values-for-syntax',
47 'delay', 'do', 'expand-path', 'fluid-let', 'hash-table-copy',
48 'hash-table-count', 'hash-table-for-each', 'hash-table-get',
49 'hash-table-iterate-first', 'hash-table-iterate-key',
50 'hash-table-iterate-next', 'hash-table-iterate-value',
51 'hash-table-map', 'hash-table-put!', 'hash-table-remove!',
52 'hash-table?', 'if', 'lambda', 'let', 'let*', 'let*-values',
53 'let-struct', 'let-syntax', 'let-syntaxes', 'let-values', 'let/cc',
54 'let/ec', 'letrec', 'letrec-syntax', 'letrec-syntaxes',
55 'letrec-syntaxes+values', 'letrec-values', 'list-immutable',
56 'make-hash-table', 'make-immutable-hash-table', 'make-namespace',
57 'module', 'module-identifier=?', 'module-label-identifier=?',
58 'module-template-identifier=?', 'module-transformer-identifier=?',
59 'namespace-transformer-require', 'or', 'parameterize',
60 'parameterize*', 'parameterize-break', 'provide',
61 'provide-for-label', 'provide-for-syntax', 'quasiquote',
62 'quasisyntax', 'quasisyntax/loc', 'quote', 'quote-syntax',
63 'quote-syntax/prune', 'require', 'require-for-label',
64 'require-for-syntax', 'require-for-template', 'set!',
65 'set!-values', 'syntax', 'syntax-case', 'syntax-case*',
66 'syntax-id-rules', 'syntax-object->datum', 'syntax-rules',
67 'syntax/loc', 'time', 'transcript-off', 'transcript-on', 'unless',
68 'unquote', 'unquote-splicing', 'unsyntax', 'unsyntax-splicing',
69 'when', 'with-continuation-mark', 'with-handlers',
70 'with-handlers*', 'with-syntax', 'λ'
71 ]
72
73 # From namespace-mapped-symbols
74 builtins = [
75 '*', '+', '-', '/', '<', '<=', '=', '>', '>=',
76 'abort-current-continuation', 'abs', 'absolute-path?', 'acos',
77 'add1', 'alarm-evt', 'always-evt', 'andmap', 'angle', 'append',
78 'apply', 'arithmetic-shift', 'arity-at-least',
79 'arity-at-least-value', 'arity-at-least?', 'asin', 'assoc', 'assq',
80 'assv', 'atan', 'banner', 'bitwise-and', 'bitwise-bit-field',
81 'bitwise-bit-set?', 'bitwise-ior', 'bitwise-not', 'bitwise-xor',
82 'boolean?', 'bound-identifier=?', 'box', 'box-immutable', 'box?',
83 'break-enabled', 'break-thread', 'build-path',
84 'build-path/convention-type', 'byte-pregexp', 'byte-pregexp?',
85 'byte-ready?', 'byte-regexp', 'byte-regexp?', 'byte?', 'bytes',
86 'bytes->immutable-bytes', 'bytes->list', 'bytes->path',
87 'bytes->path-element', 'bytes->string/latin-1',
88 'bytes->string/locale', 'bytes->string/utf-8', 'bytes-append',
89 'bytes-close-converter', 'bytes-convert', 'bytes-convert-end',
90 'bytes-converter?', 'bytes-copy', 'bytes-copy!', 'bytes-fill!',
91 'bytes-length', 'bytes-open-converter', 'bytes-ref', 'bytes-set!',
92 'bytes-utf-8-index', 'bytes-utf-8-length', 'bytes-utf-8-ref',
93 'bytes<?', 'bytes=?', 'bytes>?', 'bytes?', 'caaaar', 'caaadr',
94 'caaar', 'caadar', 'caaddr', 'caadr', 'caar', 'cadaar', 'cadadr',
95 'cadar', 'caddar', 'cadddr', 'caddr', 'cadr',
96 'call-in-nested-thread', 'call-with-break-parameterization',
97 'call-with-composable-continuation',
98 'call-with-continuation-barrier', 'call-with-continuation-prompt',
99 'call-with-current-continuation', 'call-with-escape-continuation',
100 'call-with-exception-handler',
101 'call-with-immediate-continuation-mark', 'call-with-input-file',
102 'call-with-output-file', 'call-with-parameterization',
103 'call-with-semaphore', 'call-with-semaphore/enable-break',
104 'call-with-values', 'call/cc', 'call/ec', 'car', 'cdaaar',
105 'cdaadr', 'cdaar', 'cdadar', 'cdaddr', 'cdadr', 'cdar', 'cddaar',
106 'cddadr', 'cddar', 'cdddar', 'cddddr', 'cdddr', 'cddr', 'cdr',
107 'ceiling', 'channel-get', 'channel-put', 'channel-put-evt',
108 'channel-try-get', 'channel?', 'chaperone-box', 'chaperone-evt',
109 'chaperone-hash', 'chaperone-of?', 'chaperone-procedure',
110 'chaperone-struct', 'chaperone-struct-type', 'chaperone-vector',
111 'chaperone?', 'char->integer', 'char-alphabetic?', 'char-blank?',
112 'char-ci<=?', 'char-ci<?', 'char-ci=?', 'char-ci>=?', 'char-ci>?',
113 'char-downcase', 'char-foldcase', 'char-general-category',
114 'char-graphic?', 'char-iso-control?', 'char-lower-case?',
115 'char-numeric?', 'char-punctuation?', 'char-ready?',
116 'char-symbolic?', 'char-title-case?', 'char-titlecase',
117 'char-upcase', 'char-upper-case?', 'char-utf-8-length',
118 'char-whitespace?', 'char<=?', 'char<?', 'char=?', 'char>=?',
119 'char>?', 'char?', 'check-duplicate-identifier',
120 'checked-procedure-check-and-extract', 'choice-evt',
121 'cleanse-path', 'close-input-port', 'close-output-port',
122 'collect-garbage', 'collection-file-path', 'collection-path',
123 'compile', 'compile-allow-set!-undefined',
124 'compile-context-preservation-enabled',
125 'compile-enforce-module-constants', 'compile-syntax',
126 'compiled-expression?', 'compiled-module-expression?',
127 'complete-path?', 'complex?', 'cons',
128 'continuation-mark-set->context', 'continuation-mark-set->list',
129 'continuation-mark-set->list*', 'continuation-mark-set-first',
130 'continuation-mark-set?', 'continuation-marks',
131 'continuation-prompt-available?', 'continuation-prompt-tag?',
132 'continuation?', 'copy-file', 'cos',
133 'current-break-parameterization', 'current-code-inspector',
134 'current-command-line-arguments', 'current-compile',
135 'current-continuation-marks', 'current-custodian',
136 'current-directory', 'current-drive', 'current-error-port',
137 'current-eval', 'current-evt-pseudo-random-generator',
138 'current-gc-milliseconds', 'current-get-interaction-input-port',
139 'current-inexact-milliseconds', 'current-input-port',
140 'current-inspector', 'current-library-collection-paths',
141 'current-load', 'current-load-extension',
142 'current-load-relative-directory', 'current-load/use-compiled',
143 'current-locale', 'current-memory-use', 'current-milliseconds',
144 'current-module-declare-name', 'current-module-declare-source',
145 'current-module-name-resolver', 'current-namespace',
146 'current-output-port', 'current-parameterization',
147 'current-preserved-thread-cell-values', 'current-print',
148 'current-process-milliseconds', 'current-prompt-read',
149 'current-pseudo-random-generator', 'current-read-interaction',
150 'current-reader-guard', 'current-readtable', 'current-seconds',
151 'current-security-guard', 'current-subprocess-custodian-mode',
152 'current-thread', 'current-thread-group',
153 'current-thread-initial-stack-size',
154 'current-write-relative-directory', 'custodian-box-value',
155 'custodian-box?', 'custodian-limit-memory',
156 'custodian-managed-list', 'custodian-memory-accounting-available?',
157 'custodian-require-memory', 'custodian-shutdown-all', 'custodian?',
158 'custom-print-quotable-accessor', 'custom-print-quotable?',
159 'custom-write-accessor', 'custom-write?', 'date', 'date*',
160 'date*-nanosecond', 'date*-time-zone-name', 'date*?', 'date-day',
161 'date-dst?', 'date-hour', 'date-minute', 'date-month',
162 'date-second', 'date-time-zone-offset', 'date-week-day',
163 'date-year', 'date-year-day', 'date?', 'datum-intern-literal',
164 'default-continuation-prompt-tag', 'delete-directory',
165 'delete-file', 'denominator', 'directory-exists?',
166 'directory-list', 'display', 'displayln', 'dump-memory-stats',
167 'dynamic-require', 'dynamic-require-for-syntax', 'dynamic-wind',
168 'eof', 'eof-object?', 'ephemeron-value', 'ephemeron?', 'eprintf',
169 'eq-hash-code', 'eq?', 'equal-hash-code',
170 'equal-secondary-hash-code', 'equal?', 'equal?/recur',
171 'eqv-hash-code', 'eqv?', 'error', 'error-display-handler',
172 'error-escape-handler', 'error-print-context-length',
173 'error-print-source-location', 'error-print-width',
174 'error-value->string-handler', 'eval', 'eval-jit-enabled',
175 'eval-syntax', 'even?', 'evt?', 'exact->inexact', 'exact-integer?',
176 'exact-nonnegative-integer?', 'exact-positive-integer?', 'exact?',
177 'executable-yield-handler', 'exit', 'exit-handler', 'exn',
178 'exn-continuation-marks', 'exn-message', 'exn:break',
179 'exn:break-continuation', 'exn:break?', 'exn:fail',
180 'exn:fail:contract', 'exn:fail:contract:arity',
181 'exn:fail:contract:arity?', 'exn:fail:contract:continuation',
182 'exn:fail:contract:continuation?',
183 'exn:fail:contract:divide-by-zero',
184 'exn:fail:contract:divide-by-zero?',
185 'exn:fail:contract:non-fixnum-result',
186 'exn:fail:contract:non-fixnum-result?',
187 'exn:fail:contract:variable', 'exn:fail:contract:variable-id',
188 'exn:fail:contract:variable?', 'exn:fail:contract?',
189 'exn:fail:filesystem', 'exn:fail:filesystem:exists',
190 'exn:fail:filesystem:exists?', 'exn:fail:filesystem:version',
191 'exn:fail:filesystem:version?', 'exn:fail:filesystem?',
192 'exn:fail:network', 'exn:fail:network?', 'exn:fail:out-of-memory',
193 'exn:fail:out-of-memory?', 'exn:fail:read',
194 'exn:fail:read-srclocs', 'exn:fail:read:eof', 'exn:fail:read:eof?',
195 'exn:fail:read:non-char', 'exn:fail:read:non-char?',
196 'exn:fail:read?', 'exn:fail:syntax', 'exn:fail:syntax-exprs',
197 'exn:fail:syntax:unbound', 'exn:fail:syntax:unbound?',
198 'exn:fail:syntax?', 'exn:fail:unsupported',
199 'exn:fail:unsupported?', 'exn:fail:user', 'exn:fail:user?',
200 'exn:fail?', 'exn:srclocs-accessor', 'exn:srclocs?', 'exn?', 'exp',
201 'expand', 'expand-once', 'expand-syntax', 'expand-syntax-once',
202 'expand-syntax-to-top-form', 'expand-to-top-form',
203 'expand-user-path', 'expt', 'file-exists?',
204 'file-or-directory-identity', 'file-or-directory-modify-seconds',
205 'file-or-directory-permissions', 'file-position', 'file-size',
206 'file-stream-buffer-mode', 'file-stream-port?',
207 'filesystem-root-list', 'find-executable-path',
208 'find-library-collection-paths', 'find-system-path', 'fixnum?',
209 'floating-point-bytes->real', 'flonum?', 'floor', 'flush-output',
210 'for-each', 'force', 'format', 'fprintf', 'free-identifier=?',
211 'gcd', 'generate-temporaries', 'gensym', 'get-output-bytes',
212 'get-output-string', 'getenv', 'global-port-print-handler',
213 'guard-evt', 'handle-evt', 'handle-evt?', 'hash', 'hash-equal?',
214 'hash-eqv?', 'hash-has-key?', 'hash-placeholder?', 'hash-ref!',
215 'hasheq', 'hasheqv', 'identifier-binding',
216 'identifier-label-binding', 'identifier-prune-lexical-context',
217 'identifier-prune-to-source-module',
218 'identifier-remove-from-definition-context',
219 'identifier-template-binding', 'identifier-transformer-binding',
220 'identifier?', 'imag-part', 'immutable?', 'impersonate-box',
221 'impersonate-hash', 'impersonate-procedure', 'impersonate-struct',
222 'impersonate-vector', 'impersonator-of?',
223 'impersonator-prop:application-mark',
224 'impersonator-property-accessor-procedure?',
225 'impersonator-property?', 'impersonator?', 'inexact->exact',
226 'inexact-real?', 'inexact?', 'input-port?', 'inspector?',
227 'integer->char', 'integer->integer-bytes',
228 'integer-bytes->integer', 'integer-length', 'integer-sqrt',
229 'integer-sqrt/remainder', 'integer?',
230 'internal-definition-context-seal', 'internal-definition-context?',
231 'keyword->string', 'keyword<?', 'keyword?', 'kill-thread', 'lcm',
232 'length', 'liberal-define-context?', 'link-exists?', 'list',
233 'list*', 'list->bytes', 'list->string', 'list->vector', 'list-ref',
234 'list-tail', 'list?', 'load', 'load-extension',
235 'load-on-demand-enabled', 'load-relative',
236 'load-relative-extension', 'load/cd', 'load/use-compiled',
237 'local-expand', 'local-expand/capture-lifts',
238 'local-transformer-expand',
239 'local-transformer-expand/capture-lifts', 'locale-string-encoding',
240 'log', 'magnitude', 'make-arity-at-least', 'make-bytes',
241 'make-channel', 'make-continuation-prompt-tag', 'make-custodian',
242 'make-custodian-box', 'make-date', 'make-date*',
243 'make-derived-parameter', 'make-directory', 'make-ephemeron',
244 'make-exn', 'make-exn:break', 'make-exn:fail',
245 'make-exn:fail:contract', 'make-exn:fail:contract:arity',
246 'make-exn:fail:contract:continuation',
247 'make-exn:fail:contract:divide-by-zero',
248 'make-exn:fail:contract:non-fixnum-result',
249 'make-exn:fail:contract:variable', 'make-exn:fail:filesystem',
250 'make-exn:fail:filesystem:exists',
251 'make-exn:fail:filesystem:version', 'make-exn:fail:network',
252 'make-exn:fail:out-of-memory', 'make-exn:fail:read',
253 'make-exn:fail:read:eof', 'make-exn:fail:read:non-char',
254 'make-exn:fail:syntax', 'make-exn:fail:syntax:unbound',
255 'make-exn:fail:unsupported', 'make-exn:fail:user',
256 'make-file-or-directory-link', 'make-hash-placeholder',
257 'make-hasheq-placeholder', 'make-hasheqv',
258 'make-hasheqv-placeholder', 'make-immutable-hasheqv',
259 'make-impersonator-property', 'make-input-port', 'make-inspector',
260 'make-known-char-range-list', 'make-output-port', 'make-parameter',
261 'make-pipe', 'make-placeholder', 'make-polar',
262 'make-prefab-struct', 'make-pseudo-random-generator',
263 'make-reader-graph', 'make-readtable', 'make-rectangular',
264 'make-rename-transformer', 'make-resolved-module-path',
265 'make-security-guard', 'make-semaphore', 'make-set!-transformer',
266 'make-shared-bytes', 'make-sibling-inspector',
267 'make-special-comment', 'make-srcloc', 'make-string',
268 'make-struct-field-accessor', 'make-struct-field-mutator',
269 'make-struct-type', 'make-struct-type-property',
270 'make-syntax-delta-introducer', 'make-syntax-introducer',
271 'make-thread-cell', 'make-thread-group', 'make-vector',
272 'make-weak-box', 'make-weak-hasheqv', 'make-will-executor', 'map',
273 'max', 'mcar', 'mcdr', 'mcons', 'member', 'memq', 'memv', 'min',
274 'module->exports', 'module->imports', 'module->language-info',
275 'module->namespace', 'module-compiled-exports',
276 'module-compiled-imports', 'module-compiled-language-info',
277 'module-compiled-name', 'module-path-index-join',
278 'module-path-index-resolve', 'module-path-index-split',
279 'module-path-index?', 'module-path?', 'module-predefined?',
280 'module-provide-protected?', 'modulo', 'mpair?', 'nack-guard-evt',
281 'namespace-attach-module', 'namespace-attach-module-declaration',
282 'namespace-base-phase', 'namespace-mapped-symbols',
283 'namespace-module-identifier', 'namespace-module-registry',
284 'namespace-require', 'namespace-require/constant',
285 'namespace-require/copy', 'namespace-require/expansion-time',
286 'namespace-set-variable-value!', 'namespace-symbol->identifier',
287 'namespace-syntax-introduce', 'namespace-undefine-variable!',
288 'namespace-unprotect-module', 'namespace-variable-value',
289 'namespace?', 'negative?', 'never-evt', 'newline',
290 'normal-case-path', 'not', 'null', 'null?', 'number->string',
291 'number?', 'numerator', 'object-name', 'odd?', 'open-input-bytes',
292 'open-input-file', 'open-input-output-file', 'open-input-string',
293 'open-output-bytes', 'open-output-file', 'open-output-string',
294 'ormap', 'output-port?', 'pair?', 'parameter-procedure=?',
295 'parameter?', 'parameterization?', 'path->bytes',
296 'path->complete-path', 'path->directory-path', 'path->string',
297 'path-add-suffix', 'path-convention-type', 'path-element->bytes',
298 'path-element->string', 'path-for-some-system?',
299 'path-list-string->path-list', 'path-replace-suffix',
300 'path-string?', 'path?', 'peek-byte', 'peek-byte-or-special',
301 'peek-bytes', 'peek-bytes!', 'peek-bytes-avail!',
302 'peek-bytes-avail!*', 'peek-bytes-avail!/enable-break',
303 'peek-char', 'peek-char-or-special', 'peek-string', 'peek-string!',
304 'pipe-content-length', 'placeholder-get', 'placeholder-set!',
305 'placeholder?', 'poll-guard-evt', 'port-closed-evt',
306 'port-closed?', 'port-commit-peeked', 'port-count-lines!',
307 'port-count-lines-enabled', 'port-display-handler',
308 'port-file-identity', 'port-file-unlock', 'port-next-location',
309 'port-print-handler', 'port-progress-evt',
310 'port-provides-progress-evts?', 'port-read-handler',
311 'port-try-file-lock?', 'port-write-handler', 'port-writes-atomic?',
312 'port-writes-special?', 'port?', 'positive?',
313 'prefab-key->struct-type', 'prefab-struct-key', 'pregexp',
314 'pregexp?', 'primitive-closure?', 'primitive-result-arity',
315 'primitive?', 'print', 'print-as-expression',
316 'print-boolean-long-form', 'print-box', 'print-graph',
317 'print-hash-table', 'print-mpair-curly-braces',
318 'print-pair-curly-braces', 'print-reader-abbreviations',
319 'print-struct', 'print-syntax-width', 'print-unreadable',
320 'print-vector-length', 'printf', 'procedure->method',
321 'procedure-arity', 'procedure-arity-includes?', 'procedure-arity?',
322 'procedure-closure-contents-eq?', 'procedure-extract-target',
323 'procedure-reduce-arity', 'procedure-rename',
324 'procedure-struct-type?', 'procedure?', 'promise?',
325 'prop:arity-string', 'prop:checked-procedure',
326 'prop:custom-print-quotable', 'prop:custom-write',
327 'prop:equal+hash', 'prop:evt', 'prop:exn:srclocs',
328 'prop:impersonator-of', 'prop:input-port',
329 'prop:liberal-define-context', 'prop:output-port',
330 'prop:procedure', 'prop:rename-transformer',
331 'prop:set!-transformer', 'pseudo-random-generator->vector',
332 'pseudo-random-generator-vector?', 'pseudo-random-generator?',
333 'putenv', 'quotient', 'quotient/remainder', 'raise',
334 'raise-arity-error', 'raise-mismatch-error', 'raise-syntax-error',
335 'raise-type-error', 'raise-user-error', 'random', 'random-seed',
336 'rational?', 'rationalize', 'read', 'read-accept-bar-quote',
337 'read-accept-box', 'read-accept-compiled', 'read-accept-dot',
338 'read-accept-graph', 'read-accept-infix-dot', 'read-accept-lang',
339 'read-accept-quasiquote', 'read-accept-reader', 'read-byte',
340 'read-byte-or-special', 'read-bytes', 'read-bytes!',
341 'read-bytes-avail!', 'read-bytes-avail!*',
342 'read-bytes-avail!/enable-break', 'read-bytes-line',
343 'read-case-sensitive', 'read-char', 'read-char-or-special',
344 'read-curly-brace-as-paren', 'read-decimal-as-inexact',
345 'read-eval-print-loop', 'read-language', 'read-line',
346 'read-on-demand-source', 'read-square-bracket-as-paren',
347 'read-string', 'read-string!', 'read-syntax',
348 'read-syntax/recursive', 'read/recursive', 'readtable-mapping',
349 'readtable?', 'real->double-flonum', 'real->floating-point-bytes',
350 'real->single-flonum', 'real-part', 'real?', 'regexp',
351 'regexp-match', 'regexp-match-peek', 'regexp-match-peek-immediate',
352 'regexp-match-peek-positions',
353 'regexp-match-peek-positions-immediate',
354 'regexp-match-peek-positions-immediate/end',
355 'regexp-match-peek-positions/end', 'regexp-match-positions',
356 'regexp-match-positions/end', 'regexp-match/end', 'regexp-match?',
357 'regexp-max-lookbehind', 'regexp-replace', 'regexp-replace*',
358 'regexp?', 'relative-path?', 'remainder',
359 'rename-file-or-directory', 'rename-transformer-target',
360 'rename-transformer?', 'resolve-path', 'resolved-module-path-name',
361 'resolved-module-path?', 'reverse', 'round', 'seconds->date',
362 'security-guard?', 'semaphore-peek-evt', 'semaphore-post',
363 'semaphore-try-wait?', 'semaphore-wait',
364 'semaphore-wait/enable-break', 'semaphore?',
365 'set!-transformer-procedure', 'set!-transformer?', 'set-box!',
366 'set-mcar!', 'set-mcdr!', 'set-port-next-location!',
367 'shared-bytes', 'shell-execute', 'simplify-path', 'sin',
368 'single-flonum?', 'sleep', 'special-comment-value',
369 'special-comment?', 'split-path', 'sqrt', 'srcloc',
370 'srcloc-column', 'srcloc-line', 'srcloc-position', 'srcloc-source',
371 'srcloc-span', 'srcloc?', 'string', 'string->bytes/latin-1',
372 'string->bytes/locale', 'string->bytes/utf-8',
373 'string->immutable-string', 'string->keyword', 'string->list',
374 'string->number', 'string->path', 'string->path-element',
375 'string->symbol', 'string->uninterned-symbol',
376 'string->unreadable-symbol', 'string-append', 'string-ci<=?',
377 'string-ci<?', 'string-ci=?', 'string-ci>=?', 'string-ci>?',
378 'string-copy', 'string-copy!', 'string-downcase', 'string-fill!',
379 'string-foldcase', 'string-length', 'string-locale-ci<?',
380 'string-locale-ci=?', 'string-locale-ci>?',
381 'string-locale-downcase', 'string-locale-upcase',
382 'string-locale<?', 'string-locale=?', 'string-locale>?',
383 'string-normalize-nfc', 'string-normalize-nfd',
384 'string-normalize-nfkc', 'string-normalize-nfkd', 'string-ref',
385 'string-set!', 'string-titlecase', 'string-upcase',
386 'string-utf-8-length', 'string<=?', 'string<?', 'string=?',
387 'string>=?', 'string>?', 'string?', 'struct->vector',
388 'struct-accessor-procedure?', 'struct-constructor-procedure?',
389 'struct-info', 'struct-mutator-procedure?',
390 'struct-predicate-procedure?', 'struct-type-info',
391 'struct-type-make-constructor', 'struct-type-make-predicate',
392 'struct-type-property-accessor-procedure?',
393 'struct-type-property?', 'struct-type?', 'struct:arity-at-least',
394 'struct:date', 'struct:date*', 'struct:exn', 'struct:exn:break',
395 'struct:exn:fail', 'struct:exn:fail:contract',
396 'struct:exn:fail:contract:arity',
397 'struct:exn:fail:contract:continuation',
398 'struct:exn:fail:contract:divide-by-zero',
399 'struct:exn:fail:contract:non-fixnum-result',
400 'struct:exn:fail:contract:variable', 'struct:exn:fail:filesystem',
401 'struct:exn:fail:filesystem:exists',
402 'struct:exn:fail:filesystem:version', 'struct:exn:fail:network',
403 'struct:exn:fail:out-of-memory', 'struct:exn:fail:read',
404 'struct:exn:fail:read:eof', 'struct:exn:fail:read:non-char',
405 'struct:exn:fail:syntax', 'struct:exn:fail:syntax:unbound',
406 'struct:exn:fail:unsupported', 'struct:exn:fail:user',
407 'struct:srcloc', 'struct?', 'sub1', 'subbytes', 'subprocess',
408 'subprocess-group-enabled', 'subprocess-kill', 'subprocess-pid',
409 'subprocess-status', 'subprocess-wait', 'subprocess?', 'substring',
410 'symbol->string', 'symbol-interned?', 'symbol-unreadable?',
411 'symbol?', 'sync', 'sync/enable-break', 'sync/timeout',
412 'sync/timeout/enable-break', 'syntax->list', 'syntax-arm',
413 'syntax-column', 'syntax-disarm', 'syntax-e', 'syntax-line',
414 'syntax-local-bind-syntaxes', 'syntax-local-certifier',
415 'syntax-local-context', 'syntax-local-expand-expression',
416 'syntax-local-get-shadower', 'syntax-local-introduce',
417 'syntax-local-lift-context', 'syntax-local-lift-expression',
418 'syntax-local-lift-module-end-declaration',
419 'syntax-local-lift-provide', 'syntax-local-lift-require',
420 'syntax-local-lift-values-expression',
421 'syntax-local-make-definition-context',
422 'syntax-local-make-delta-introducer',
423 'syntax-local-module-defined-identifiers',
424 'syntax-local-module-exports',
425 'syntax-local-module-required-identifiers', 'syntax-local-name',
426 'syntax-local-phase-level',
427 'syntax-local-transforming-module-provides?', 'syntax-local-value',
428 'syntax-local-value/immediate', 'syntax-original?',
429 'syntax-position', 'syntax-property',
430 'syntax-property-symbol-keys', 'syntax-protect', 'syntax-rearm',
431 'syntax-recertify', 'syntax-shift-phase-level', 'syntax-source',
432 'syntax-source-module', 'syntax-span', 'syntax-taint',
433 'syntax-tainted?', 'syntax-track-origin',
434 'syntax-transforming-module-expression?', 'syntax-transforming?',
435 'syntax?', 'system-big-endian?', 'system-idle-evt',
436 'system-language+country', 'system-library-subpath',
437 'system-path-convention-type', 'system-type', 'tan',
438 'tcp-abandon-port', 'tcp-accept', 'tcp-accept-evt',
439 'tcp-accept-ready?', 'tcp-accept/enable-break', 'tcp-addresses',
440 'tcp-close', 'tcp-connect', 'tcp-connect/enable-break',
441 'tcp-listen', 'tcp-listener?', 'tcp-port?', 'terminal-port?',
442 'thread', 'thread-cell-ref', 'thread-cell-set!', 'thread-cell?',
443 'thread-dead-evt', 'thread-dead?', 'thread-group?',
444 'thread-resume', 'thread-resume-evt', 'thread-rewind-receive',
445 'thread-running?', 'thread-suspend', 'thread-suspend-evt',
446 'thread-wait', 'thread/suspend-to-kill', 'thread?', 'time-apply',
447 'truncate', 'udp-addresses', 'udp-bind!', 'udp-bound?',
448 'udp-close', 'udp-connect!', 'udp-connected?', 'udp-open-socket',
449 'udp-receive!', 'udp-receive!*', 'udp-receive!-evt',
450 'udp-receive!/enable-break', 'udp-receive-ready-evt', 'udp-send',
451 'udp-send*', 'udp-send-evt', 'udp-send-ready-evt', 'udp-send-to',
452 'udp-send-to*', 'udp-send-to-evt', 'udp-send-to/enable-break',
453 'udp-send/enable-break', 'udp?', 'unbox',
454 'uncaught-exception-handler', 'use-collection-link-paths',
455 'use-compiled-file-paths', 'use-user-specific-search-paths',
456 'values', 'variable-reference->empty-namespace',
457 'variable-reference->module-base-phase',
458 'variable-reference->module-declaration-inspector',
459 'variable-reference->module-source',
460 'variable-reference->namespace', 'variable-reference->phase',
461 'variable-reference->resolved-module-path',
462 'variable-reference-constant?', 'variable-reference?', 'vector',
463 'vector->immutable-vector', 'vector->list',
464 'vector->pseudo-random-generator',
465 'vector->pseudo-random-generator!', 'vector->values',
466 'vector-fill!', 'vector-immutable', 'vector-length', 'vector-ref',
467 'vector-set!', 'vector-set-performance-stats!', 'vector?',
468 'version', 'void', 'void?', 'weak-box-value', 'weak-box?',
469 'will-execute', 'will-executor?', 'will-register',
470 'will-try-execute', 'with-input-from-file', 'with-output-to-file',
471 'wrap-evt', 'write', 'write-byte', 'write-bytes',
472 'write-bytes-avail', 'write-bytes-avail*', 'write-bytes-avail-evt',
473 'write-bytes-avail/enable-break', 'write-char', 'write-special',
474 'write-special-avail*', 'write-special-evt', 'write-string', 'zero?'
475 ]
476
477 # From SchemeLexer
478 valid_name = r'[a-zA-Z0-9!$%&*+,/:<=>?@^_~|-]+'
479
480 tokens = {
481 'root' : [
482 (r';.*$', Comment.Single),
483 (r'#\|[^|]+\|#', Comment.Multiline),
484
485 # whitespaces - usually not relevant
486 (r'\s+', Text),
487
488 ## numbers: Keep in mind Racket reader hash prefixes,
489 ## which can denote the base or the type. These don't map
490 ## neatly onto pygments token types; some judgment calls
491 ## here. Note that none of these regexps attempt to
492 ## exclude identifiers that start with a number, such as a
493 ## variable named "100-Continue".
494
495 # #b
496 (r'#b[-+]?[01]+\.[01]+', Number.Float),
497 (r'#b[01]+e[-+]?[01]+', Number.Float),
498 (r'#b[-+]?[01]/[01]+', Number),
499 (r'#b[-+]?[01]+', Number.Integer),
500 (r'#b\S*', Error),
501
502 # #d OR no hash prefix
503 (r'(#d)?[-+]?\d+\.\d+', Number.Float),
504 (r'(#d)?\d+e[-+]?\d+', Number.Float),
505 (r'(#d)?[-+]?\d+/\d+', Number),
506 (r'(#d)?[-+]?\d+', Number.Integer),
507 (r'#d\S*', Error),
508
509 # #e
510 (r'#e[-+]?\d+\.\d+', Number.Float),
511 (r'#e\d+e[-+]?\d+', Number.Float),
512 (r'#e[-+]?\d+/\d+', Number),
513 (r'#e[-+]?\d+', Number),
514 (r'#e\S*', Error),
515
516 # #i is always inexact-real, i.e. float
517 (r'#i[-+]?\d+\.\d+', Number.Float),
518 (r'#i\d+e[-+]?\d+', Number.Float),
519 (r'#i[-+]?\d+/\d+', Number.Float),
520 (r'#i[-+]?\d+', Number.Float),
521 (r'#i\S*', Error),
522
523 # #o
524 (r'#o[-+]?[0-7]+\.[0-7]+', Number.Oct),
525 (r'#o[0-7]+e[-+]?[0-7]+', Number.Oct),
526 (r'#o[-+]?[0-7]+/[0-7]+', Number.Oct),
527 (r'#o[-+]?[0-7]+', Number.Oct),
528 (r'#o\S*', Error),
529
530 # #x
531 (r'#x[-+]?[0-9a-fA-F]+\.[0-9a-fA-F]+', Number.Hex),
532 # the exponent variation (e.g. #x1e1) is N/A
533 (r'#x[-+]?[0-9a-fA-F]+/[0-9a-fA-F]+', Number.Hex),
534 (r'#x[-+]?[0-9a-fA-F]+', Number.Hex),
535 (r'#x\S*', Error),
536
537
538 # strings, symbols and characters
539 (r'"(\\\\|\\"|[^"])*"', String),
540 (r"'" + valid_name, String.Symbol),
541 (r"#\\([()/'\"._!§$%& ?=+-]{1}|[a-zA-Z0-9]+)", String.Char),
542 (r'#rx".+"', String.Regex),
543 (r'#px".+"', String.Regex),
544
545 # constants
546 (r'(#t|#f)', Name.Constant),
547
548 # keyword argument names (e.g. #:keyword)
549 (r'#:\S+', Keyword.Declaration),
550
551 # #lang
552 (r'#lang \S+', Keyword.Namespace),
553
554 # special operators
555 (r"('|#|`|,@|,|\.)", Operator),
556
557 # highlight the keywords
558 ('(%s)' % '|'.join([
559 re.escape(entry) + ' ' for entry in keywords]),
560 Keyword
561 ),
562
563 # first variable in a quoted string like
564 # '(this is syntactic sugar)
565 (r"(?<='\()" + valid_name, Name.Variable),
566 (r"(?<=#\()" + valid_name, Name.Variable),
567
568 # highlight the builtins
569 ("(?<=\()(%s)" % '|'.join([
570 re.escape(entry) + ' ' for entry in builtins]),
571 Name.Builtin
572 ),
573
574 # the remaining functions; handle both ( and [
575 (r'(?<=(\(|\[|\{))' + valid_name, Name.Function),
576
577 # find the remaining variables
578 (valid_name, Name.Variable),
579
580 # the famous parentheses!
581 (r'(\(|\)|\[|\]|\{|\})', Punctuation),
582 ],
583 }
22 584
23 585
24 class SchemeLexer(RegexLexer): 586 class SchemeLexer(RegexLexer):
25 """ 587 """
26 A Scheme lexer, parsing a stream and outputting the tokens 588 A Scheme lexer, parsing a stream and outputting the tokens
35 597
36 *New in Pygments 0.6.* 598 *New in Pygments 0.6.*
37 """ 599 """
38 name = 'Scheme' 600 name = 'Scheme'
39 aliases = ['scheme', 'scm'] 601 aliases = ['scheme', 'scm']
40 filenames = ['*.scm', '*.ss', '*.rkt'] 602 filenames = ['*.scm', '*.ss']
41 mimetypes = ['text/x-scheme', 'application/x-scheme'] 603 mimetypes = ['text/x-scheme', 'application/x-scheme']
42 604
43 # list of known keywords and builtins taken form vim 6.4 scheme.vim 605 # list of known keywords and builtins taken form vim 6.4 scheme.vim
44 # syntax file. 606 # syntax file.
45 keywords = [ 607 keywords = [
143 # find the remaining variables 705 # find the remaining variables
144 (valid_name, Name.Variable), 706 (valid_name, Name.Variable),
145 707
146 # the famous parentheses! 708 # the famous parentheses!
147 (r'(\(|\))', Punctuation), 709 (r'(\(|\))', Punctuation),
710 (r'(\[|\])', Punctuation),
148 ], 711 ],
149 } 712 }
150 713
151 714
152 class CommonLispLexer(RegexLexer): 715 class CommonLispLexer(RegexLexer):
240 803
241 # encoding comment (?) 804 # encoding comment (?)
242 (r'#\d*Y.*$', Comment.Special), 805 (r'#\d*Y.*$', Comment.Special),
243 806
244 # strings and characters 807 # strings and characters
245 (r'"(\\.|[^"\\])*"', String), 808 (r'"(\\.|\\\n|[^"\\])*"', String),
246 # quoting 809 # quoting
247 (r":" + symbol, String.Symbol), 810 (r":" + symbol, String.Symbol),
248 (r"'" + symbol, String.Symbol), 811 (r"'" + symbol, String.Symbol),
249 (r"'", Operator), 812 (r"'", Operator),
250 (r"`", Operator), 813 (r"`", Operator),
347 tokens = { 910 tokens = {
348 'root': [ 911 'root': [
349 # Whitespace: 912 # Whitespace:
350 (r'\s+', Text), 913 (r'\s+', Text),
351 #(r'--\s*|.*$', Comment.Doc), 914 #(r'--\s*|.*$', Comment.Doc),
352 (r'--(?![!#$%&*+./<=>?@\^|_~]).*?$', Comment.Single), 915 (r'--(?![!#$%&*+./<=>?@\^|_~:\\]).*?$', Comment.Single),
353 (r'{-', Comment.Multiline, 'comment'), 916 (r'{-', Comment.Multiline, 'comment'),
354 # Lexemes: 917 # Lexemes:
355 # Identifiers 918 # Identifiers
356 (r'\bimport\b', Keyword.Reserved, 'import'), 919 (r'\bimport\b', Keyword.Reserved, 'import'),
357 (r'\bmodule\b', Keyword.Reserved, 'module'), 920 (r'\bmodule\b', Keyword.Reserved, 'module'),
358 (r'\berror\b', Name.Exception), 921 (r'\berror\b', Name.Exception),
359 (r'\b(%s)(?!\')\b' % '|'.join(reserved), Keyword.Reserved), 922 (r'\b(%s)(?!\')\b' % '|'.join(reserved), Keyword.Reserved),
360 (r'^[_a-z][\w\']*', Name.Function), 923 (r'^[_a-z][\w\']*', Name.Function),
361 (r'[_a-z][\w\']*', Name), 924 (r"'?[_a-z][\w']*", Name),
362 (r'[A-Z][\w\']*', Keyword.Type), 925 (r"('')?[A-Z][\w\']*", Keyword.Type),
363 # Operators 926 # Operators
364 (r'\\(?![:!#$%&*+.\\/<=>?@^|~-]+)', Name.Function), # lambda operator 927 (r'\\(?![:!#$%&*+.\\/<=>?@^|~-]+)', Name.Function), # lambda operator
365 (r'(<-|::|->|=>|=)(?![:!#$%&*+.\\/<=>?@^|~-]+)', Operator.Word), # specials 928 (r'(<-|::|->|=>|=)(?![:!#$%&*+.\\/<=>?@^|~-]+)', Operator.Word), # specials
366 (r':[:!#$%&*+.\\/<=>?@^|~-]*', Keyword.Type), # Constructor operators 929 (r':[:!#$%&*+.\\/<=>?@^|~-]*', Keyword.Type), # Constructor operators
367 (r'[:!#$%&*+.\\/<=>?@^|~-]+', Operator), # Other operators 930 (r'[:!#$%&*+.\\/<=>?@^|~-]+', Operator), # Other operators
859 'downto', 'else', 'end', 'exception', 'external', 'false', 1422 'downto', 'else', 'end', 'exception', 'external', 'false',
860 'for', 'fun', 'function', 'functor', 'if', 'in', 'include', 1423 'for', 'fun', 'function', 'functor', 'if', 'in', 'include',
861 'inherit', 'initializer', 'lazy', 'let', 'match', 'method', 1424 'inherit', 'initializer', 'lazy', 'let', 'match', 'method',
862 'module', 'mutable', 'new', 'object', 'of', 'open', 'private', 1425 'module', 'mutable', 'new', 'object', 'of', 'open', 'private',
863 'raise', 'rec', 'sig', 'struct', 'then', 'to', 'true', 'try', 1426 'raise', 'rec', 'sig', 'struct', 'then', 'to', 'true', 'try',
864 'type', 'val', 'virtual', 'when', 'while', 'with' 1427 'type', 'value', 'val', 'virtual', 'when', 'while', 'with',
865 ] 1428 ]
866 keyopts = [ 1429 keyopts = [
867 '!=','#','&','&&','\(','\)','\*','\+',',','-', 1430 '!=','#','&','&&','\(','\)','\*','\+',',','-',
868 '-\.','->','\.','\.\.',':','::',':=',':>',';',';;','<', 1431 '-\.','->','\.','\.\.',':','::',':=',':>',';',';;','<',
869 '<-','=','>','>]','>}','\?','\?\?','\[','\[<','\[>','\[\|', 1432 '<-','=','>','>]','>}','\?','\?\?','\[','\[<','\[>','\[\|',
1009 (r'^-', Punctuation, 'directive'), 1572 (r'^-', Punctuation, 'directive'),
1010 (operators, Operator), 1573 (operators, Operator),
1011 (r'"', String, 'string'), 1574 (r'"', String, 'string'),
1012 (r'<<', Name.Label), 1575 (r'<<', Name.Label),
1013 (r'>>', Name.Label), 1576 (r'>>', Name.Label),
1014 (r'('+atom_re+')(:)', bygroups(Name.Namespace, Punctuation)), 1577 ('(' + atom_re + ')(:)', bygroups(Name.Namespace, Punctuation)),
1015 (r'^('+atom_re+r')(\s*)(\()', bygroups(Name.Function, Text, Punctuation)), 1578 ('(?:^|(?<=:))(' + atom_re + r')(\s*)(\()',
1579 bygroups(Name.Function, Text, Punctuation)),
1016 (r'[+-]?'+base_re+r'#[0-9a-zA-Z]+', Number.Integer), 1580 (r'[+-]?'+base_re+r'#[0-9a-zA-Z]+', Number.Integer),
1017 (r'[+-]?\d+', Number.Integer), 1581 (r'[+-]?\d+', Number.Integer),
1018 (r'[+-]?\d+.\d+', Number.Float), 1582 (r'[+-]?\d+.\d+', Number.Float),
1019 (r'[]\[:_@\".{}()|;,]', Punctuation), 1583 (r'[]\[:_@\".{}()|;,]', Punctuation),
1020 (variable_re, Name.Variable), 1584 (variable_re, Name.Variable),
1099 # but if you color only real keywords, you might just 1663 # but if you color only real keywords, you might just
1100 # as well not color anything 1664 # as well not color anything
1101 keywords = [ 1665 keywords = [
1102 'and', 'as', 'begin', 'css', 'database', 'db', 'do', 'else', 'end', 1666 'and', 'as', 'begin', 'css', 'database', 'db', 'do', 'else', 'end',
1103 'external', 'forall', 'if', 'import', 'match', 'package', 'parser', 1667 'external', 'forall', 'if', 'import', 'match', 'package', 'parser',
1104 'rec', 'server', 'then', 'type', 'val', 'with', 'xml_parser' 1668 'rec', 'server', 'then', 'type', 'val', 'with', 'xml_parser',
1105 ] 1669 ]
1106 1670
1107 # matches both stuff and `stuff` 1671 # matches both stuff and `stuff`
1108 ident_re = r'(([a-zA-Z_]\w*)|(`[^`]*`))' 1672 ident_re = r'(([a-zA-Z_]\w*)|(`[^`]*`))'
1109 1673
1336 (r'/\*', Comment, '#push'), 1900 (r'/\*', Comment, '#push'),
1337 (r'\*/', Comment, '#pop'), 1901 (r'\*/', Comment, '#pop'),
1338 (r'[/*]', Comment), 1902 (r'[/*]', Comment),
1339 ], 1903 ],
1340 1904
1341 # the coy pasting between string and single-string 1905 # the copy pasting between string and single-string
1342 # is kinda sad. Is there a way to avoid that?? 1906 # is kinda sad. Is there a way to avoid that??
1343 'string': [ 1907 'string': [
1344 (r'[^\\"{]+', String.Double), 1908 (r'[^\\"{]+', String.Double),
1345 (r'"', String.Double, '#pop'), 1909 (r'"', String.Double, '#pop'),
1346 (r'{', Operator, 'root'), 1910 (r'{', Operator, 'root'),
1383 'html-attr-value': [ 1947 'html-attr-value': [
1384 (r"'", String.Single, ('#pop', 'single-string')), 1948 (r"'", String.Single, ('#pop', 'single-string')),
1385 (r'"', String.Single, ('#pop', 'string')), 1949 (r'"', String.Single, ('#pop', 'string')),
1386 (r'#'+ident_re, String.Single, '#pop'), 1950 (r'#'+ident_re, String.Single, '#pop'),
1387 (r'#(?={)', String.Single, ('#pop', 'root')), 1951 (r'#(?={)', String.Single, ('#pop', 'root')),
1952 (r'[^"\'{`=<>]+', String.Single, '#pop'),
1388 (r'{', Operator, ('#pop', 'root')), # this is a tail call! 1953 (r'{', Operator, ('#pop', 'root')), # this is a tail call!
1389 ], 1954 ],
1390 1955
1391 # we should probably deal with '\' escapes here 1956 # we should probably deal with '\' escapes here
1392 'html-content': [ 1957 'html-content': [
1393 (r'<!--', Comment, 'html-comment'), 1958 (r'<!--', Comment, 'html-comment'),
1394 (r'</', String.Single, ('#pop', 'html-end-tag')), 1959 (r'</', String.Single, ('#pop', 'html-end-tag')),
1395 (r'<', String.Single, 'html-open-tag'), 1960 (r'<', String.Single, 'html-open-tag'),
1396 (r'{', Operator, 'root'), 1961 (r'{', Operator, 'root'),
1397 (r'.|\s+', String.Single), 1962 (r'[^<{]+', String.Single),
1398 ], 1963 ],
1399 1964
1400 'html-comment': [ 1965 'html-comment': [
1401 (r'-->', Comment, '#pop'), 1966 (r'-->', Comment, '#pop'),
1402 (r'[^\-]+|-', Comment), 1967 (r'[^\-]+|-', Comment),
1686 name = 'Elixir' 2251 name = 'Elixir'
1687 aliases = ['elixir', 'ex', 'exs'] 2252 aliases = ['elixir', 'ex', 'exs']
1688 filenames = ['*.ex', '*.exs'] 2253 filenames = ['*.ex', '*.exs']
1689 mimetypes = ['text/x-elixir'] 2254 mimetypes = ['text/x-elixir']
1690 2255
2256 def gen_elixir_sigil_rules():
2257 states = {}
2258
2259 states['strings'] = [
2260 (r'(%[A-Ba-z])?"""(?:.|\n)*?"""', String.Doc),
2261 (r"'''(?:.|\n)*?'''", String.Doc),
2262 (r'"', String.Double, 'dqs'),
2263 (r"'.*'", String.Single),
2264 (r'(?<!\w)\?(\\(x\d{1,2}|\h{1,2}(?!\h)\b|0[0-7]{0,2}(?![0-7])\b|'
2265 r'[^x0MC])|(\\[MC]-)+\w|[^\s\\])', String.Other)
2266 ]
2267
2268 for lbrace, rbrace, name, in ('\\{', '\\}', 'cb'), \
2269 ('\\[', '\\]', 'sb'), \
2270 ('\\(', '\\)', 'pa'), \
2271 ('\\<', '\\>', 'lt'):
2272
2273 states['strings'] += [
2274 (r'%[a-z]' + lbrace, String.Double, name + 'intp'),
2275 (r'%[A-Z]' + lbrace, String.Double, name + 'no-intp')
2276 ]
2277
2278 states[name +'intp'] = [
2279 (r'' + rbrace + '[a-z]*', String.Double, "#pop"),
2280 include('enddoublestr')
2281 ]
2282
2283 states[name +'no-intp'] = [
2284 (r'.*' + rbrace + '[a-z]*', String.Double , "#pop")
2285 ]
2286
2287 return states
2288
1691 tokens = { 2289 tokens = {
1692 'root': [ 2290 'root': [
1693 (r'\s+', Text), 2291 (r'\s+', Text),
1694 (r'#.*$', Comment.Single), 2292 (r'#.*$', Comment.Single),
1695 (r'\b(case|end|bc|lc|if|unless|try|loop|receive|fn|defmodule|' 2293 (r'\b(case|cond|end|bc|lc|if|unless|try|loop|receive|fn|defmodule|'
1696 r'defp|def|defprotocol|defimpl|defrecord|defmacro|defdelegate|' 2294 r'defp?|defprotocol|defimpl|defrecord|defmacrop?|defdelegate|'
1697 r'defexception|exit|raise|throw)\b(?![?!])|' 2295 r'defexception|exit|raise|throw|unless|after|rescue|catch|else)\b(?![?!])|'
1698 r'(?<!\.)\b(do|\-\>)\b\s*', Keyword), 2296 r'(?<!\.)\b(do|\-\>)\b\s*', Keyword),
1699 (r'\b(import|require|use|recur|quote|unquote|super)\b(?![?!])', 2297 (r'\b(import|require|use|recur|quote|unquote|super|refer)\b(?![?!])',
1700 Keyword.Namespace), 2298 Keyword.Namespace),
1701 (r'(?<!\.)\b(and|not|or|when|xor|in)\b', Operator.Word), 2299 (r'(?<!\.)\b(and|not|or|when|xor|in)\b', Operator.Word),
1702 (r'%=|\*=|\*\*=|\+=|\-=|\^=|\|\|=|' 2300 (r'%=|\*=|\*\*=|\+=|\-=|\^=|\|\|=|'
1703 r'<=>|<(?!<|=)|>(?!<|=|>)|<=|>=|===|==|=~|!=|!~|(?=[ \t])\?|' 2301 r'<=>|<(?!<|=)|>(?!<|=|>)|<=|>=|===|==|=~|!=|!~|(?=[ \t])\?|'
1704 r'(?<=[ \t])!+|&&|\|\||\^|\*|\+|\-|/|' 2302 r'(?<=[ \t])!+|&&|\|\||\^|\*|\+|\-|/|'
1705 r'\||\+\+|\-\-|\*\*|\/\/|\<\-|\<\>|<<|>>|=|\.', Operator), 2303 r'\||\+\+|\-\-|\*\*|\/\/|\<\-|\<\>|<<|>>|=|\.', Operator),
1706 (r'(?<!:)(:)([a-zA-Z_]\w*([?!]|=(?![>=]))?|\<\>|===?|>=?|<=?|' 2304 (r'(?<!:)(:)([a-zA-Z_]\w*([?!]|=(?![>=]))?|\<\>|===?|>=?|<=?|'
1707 r'<=>|&&?|%\(\)|%\[\]|%\{\}|\+\+?|\-\-?|\|\|?|\!|//|[%&`/\|]|' 2305 r'<=>|&&?|%\(\)|%\[\]|%\{\}|\+\+?|\-\-?|\|\|?|\!|//|[%&`/\|]|'
1708 r'\*\*?|=?~|<\-)|([a-zA-Z_]\w*([?!])?)(:)(?!:)', String.Symbol), 2306 r'\*\*?|=?~|<\-)|([a-zA-Z_]\w*([?!])?)(:)(?!:)', String.Symbol),
1709 (r':"', String.Symbol, 'interpoling_symbol'), 2307 (r':"', String.Symbol, 'interpoling_symbol'),
1710 (r'\b(nil|true|false)\b(?![?!])', Name.Constant), 2308 (r'\b(nil|true|false)\b(?![?!])|\b[A-Z]\w*\b', Name.Constant),
1711 (r'\b[A-Z]\w*\b', Name.Constant), 2309 (r'\b(__(FILE|LINE|MODULE|MAIN|FUNCTION)__)\b(?![?!])', Name.Builtin.Pseudo),
1712 (r'\b(__(FILE|LINE|MODULE|STOP_ITERATOR|EXCEPTION|OP|REF|FUNCTION|' 2310 (r'[a-zA-Z_!][\w_]*[!\?]?', Name),
1713 r'BLOCK|KVBLOCK)__)\b(?![?!])', Name.Builtin.Pseudo),
1714 (r'[a-zA-Z_!]\w*[!\?]?', Name),
1715 (r'[(){};,/\|:\\\[\]]', Punctuation), 2311 (r'[(){};,/\|:\\\[\]]', Punctuation),
1716 (r'@[a-zA-Z_]\w*|&\d', Name.Variable), 2312 (r'@[a-zA-Z_]\w*|&\d', Name.Variable),
1717 (r'\b(0[xX][0-9A-Fa-f]+|\d(_?\d)*(\.(?![^\d\s])' 2313 (r'\b(0[xX][0-9A-Fa-f]+|\d(_?\d)*(\.(?![^\d\s])'
1718 r'(_?\d)*)?([eE][-+]?\d(_?\d)*)?|0[bB][01]+)\b', Number), 2314 r'(_?\d)*)?([eE][-+]?\d(_?\d)*)?|0[bB][01]+)\b', Number),
2315 (r'%r\/.*\/', String.Regex),
1719 include('strings'), 2316 include('strings'),
1720 ],
1721 'strings': [
1722 (r'"""(?:.|\n)*?"""', String.Doc),
1723 (r"'''(?:.|\n)*?'''", String.Doc),
1724 (r'"', String.Double, 'dqs'),
1725 (r"'.*'", String.Single),
1726 (r'(?<!\w)\?(\\(x\d{1,2}|\h{1,2}(?!\h)\b|0[0-7]{0,2}(?![0-7])\b|'
1727 r'[^x0MC])|(\\[MC]-)+\w|[^\s\\])', String.Other)
1728 ], 2317 ],
1729 'dqs': [ 2318 'dqs': [
1730 (r'"', String.Double, "#pop"), 2319 (r'"', String.Double, "#pop"),
1731 include('interpoling'), 2320 include('enddoublestr')
1732 (r'[^#"]+', String.Double),
1733 ], 2321 ],
1734 'interpoling': [ 2322 'interpoling': [
1735 (r'#{', String.Interpol, 'interpoling_string'), 2323 (r'#{', String.Interpol, 'interpoling_string'),
1736 ], 2324 ],
1737 'interpoling_string' : [ 2325 'interpoling_string' : [
1741 'interpoling_symbol': [ 2329 'interpoling_symbol': [
1742 (r'"', String.Symbol, "#pop"), 2330 (r'"', String.Symbol, "#pop"),
1743 include('interpoling'), 2331 include('interpoling'),
1744 (r'[^#"]+', String.Symbol), 2332 (r'[^#"]+', String.Symbol),
1745 ], 2333 ],
2334 'enddoublestr' : [
2335 include('interpoling'),
2336 (r'[^#"]+', String.Double),
2337 ]
1746 } 2338 }
2339 tokens.update(gen_elixir_sigil_rules())
1747 2340
1748 2341
1749 class ElixirConsoleLexer(Lexer): 2342 class ElixirConsoleLexer(Lexer):
1750 """ 2343 """
1751 For Elixir interactive console (iex) output like: 2344 For Elixir interactive console (iex) output like:
1800 yield match.start(), Generic.Output, line 2393 yield match.start(), Generic.Output, line
1801 if curcode: 2394 if curcode:
1802 for item in do_insertions(insertions, 2395 for item in do_insertions(insertions,
1803 exlexer.get_tokens_unprocessed(curcode)): 2396 exlexer.get_tokens_unprocessed(curcode)):
1804 yield item 2397 yield item
2398
2399
2400 class KokaLexer(RegexLexer):
2401 """
2402 Lexer for the `Koka <http://research.microsoft.com/en-us/projects/koka/>`_
2403 language.
2404
2405 *New in Pygments 1.6.*
2406 """
2407
2408 name = 'Koka'
2409 aliases = ['koka']
2410 filenames = ['*.kk', '*.kki']
2411 mimetypes = ['text/x-koka']
2412
2413 keywords = [
2414 'infix', 'infixr', 'infixl', 'prefix', 'postfix',
2415 'type', 'cotype', 'rectype', 'alias',
2416 'struct', 'con',
2417 'fun', 'function', 'val', 'var',
2418 'external',
2419 'if', 'then', 'else', 'elif', 'return', 'match',
2420 'private', 'public', 'private',
2421 'module', 'import', 'as',
2422 'include', 'inline',
2423 'rec',
2424 'try', 'yield', 'enum',
2425 'interface', 'instance',
2426 ]
2427
2428 # keywords that are followed by a type
2429 typeStartKeywords = [
2430 'type', 'cotype', 'rectype', 'alias', 'struct', 'enum',
2431 ]
2432
2433 # keywords valid in a type
2434 typekeywords = [
2435 'forall', 'exists', 'some', 'with',
2436 ]
2437
2438 # builtin names and special names
2439 builtin = [
2440 'for', 'while', 'repeat',
2441 'foreach', 'foreach-indexed',
2442 'error', 'catch', 'finally',
2443 'cs', 'js', 'file', 'ref', 'assigned',
2444 ]
2445
2446 # symbols that can be in an operator
2447 symbols = '[\$%&\*\+@!/\\\^~=\.:\-\?\|<>]+'
2448
2449 # symbol boundary: an operator keyword should not be followed by any of these
2450 sboundary = '(?!'+symbols+')'
2451
2452 # name boundary: a keyword should not be followed by any of these
2453 boundary = '(?![a-zA-Z0-9_\\-])'
2454
2455 # main lexer
2456 tokens = {
2457 'root': [
2458 include('whitespace'),
2459
2460 # go into type mode
2461 (r'::?' + sboundary, Keyword.Type, 'type'),
2462 (r'alias' + boundary, Keyword, 'alias-type'),
2463 (r'struct' + boundary, Keyword, 'struct-type'),
2464 (r'(%s)' % '|'.join(typeStartKeywords) + boundary, Keyword, 'type'),
2465
2466 # special sequences of tokens (we use ?: for non-capturing group as
2467 # required by 'bygroups')
2468 (r'(module)(\s*)((?:interface)?)(\s*)'
2469 r'((?:[a-z](?:[a-zA-Z0-9_]|\-[a-zA-Z])*\.)*'
2470 r'[a-z](?:[a-zA-Z0-9_]|\-[a-zA-Z])*)',
2471 bygroups(Keyword, Text, Keyword, Text, Name.Namespace)),
2472 (r'(import)(\s+)((?:[a-z](?:[a-zA-Z0-9_]|\-[a-zA-Z])*\.)*[a-z]'
2473 r'(?:[a-zA-Z0-9_]|\-[a-zA-Z])*)(\s*)((?:as)?)'
2474 r'((?:[A-Z](?:[a-zA-Z0-9_]|\-[a-zA-Z])*)?)',
2475 bygroups(Keyword, Text, Name.Namespace, Text, Keyword,
2476 Name.Namespace)),
2477
2478 # keywords
2479 (r'(%s)' % '|'.join(typekeywords) + boundary, Keyword.Type),
2480 (r'(%s)' % '|'.join(keywords) + boundary, Keyword),
2481 (r'(%s)' % '|'.join(builtin) + boundary, Keyword.Pseudo),
2482 (r'::|:=|\->|[=\.:]' + sboundary, Keyword),
2483 (r'\-' + sboundary, Generic.Strong),
2484
2485 # names
2486 (r'[A-Z]([a-zA-Z0-9_]|\-[a-zA-Z])*(?=\.)', Name.Namespace),
2487 (r'[A-Z]([a-zA-Z0-9_]|\-[a-zA-Z])*(?!\.)', Name.Class),
2488 (r'[a-z]([a-zA-Z0-9_]|\-[a-zA-Z])*', Name),
2489 (r'_([a-zA-Z0-9_]|\-[a-zA-Z])*', Name.Variable),
2490
2491 # literal string
2492 (r'@"', String.Double, 'litstring'),
2493
2494 # operators
2495 (symbols, Operator),
2496 (r'`', Operator),
2497 (r'[\{\}\(\)\[\];,]', Punctuation),
2498
2499 # literals. No check for literal characters with len > 1
2500 (r'[0-9]+\.[0-9]+([eE][\-\+]?[0-9]+)?', Number.Float),
2501 (r'0[xX][0-9a-fA-F]+', Number.Hex),
2502 (r'[0-9]+', Number.Integer),
2503
2504 (r"'", String.Char, 'char'),
2505 (r'"', String.Double, 'string'),
2506 ],
2507
2508 # type started by alias
2509 'alias-type': [
2510 (r'=',Keyword),
2511 include('type')
2512 ],
2513
2514 # type started by struct
2515 'struct-type': [
2516 (r'(?=\((?!,*\)))',Punctuation, '#pop'),
2517 include('type')
2518 ],
2519
2520 # type started by colon
2521 'type': [
2522 (r'[\(\[<]', Keyword.Type, 'type-nested'),
2523 include('type-content')
2524 ],
2525
2526 # type nested in brackets: can contain parameters, comma etc.
2527 'type-nested': [
2528 (r'[\)\]>]', Keyword.Type, '#pop'),
2529 (r'[\(\[<]', Keyword.Type, 'type-nested'),
2530 (r',', Keyword.Type),
2531 (r'([a-z](?:[a-zA-Z0-9_]|\-[a-zA-Z])*)(\s*)(:)(?!:)',
2532 bygroups(Name.Variable,Text,Keyword.Type)), # parameter name
2533 include('type-content')
2534 ],
2535
2536 # shared contents of a type
2537 'type-content': [
2538 include('whitespace'),
2539
2540 # keywords
2541 (r'(%s)' % '|'.join(typekeywords) + boundary, Keyword.Type),
2542 (r'(?=((%s)' % '|'.join(keywords) + boundary + '))',
2543 Keyword, '#pop'), # need to match because names overlap...
2544
2545 # kinds
2546 (r'[EPH]' + boundary, Keyword.Type),
2547 (r'[*!]', Keyword.Type),
2548
2549 # type names
2550 (r'[A-Z]([a-zA-Z0-9_]|\-[a-zA-Z])*(?=\.)', Name.Namespace),
2551 (r'[A-Z]([a-zA-Z0-9_]|\-[a-zA-Z])*(?!\.)', Name.Class),
2552 (r'[a-z][0-9]*(?![a-zA-Z_\-])', Keyword.Type), # Generic.Emph
2553 (r'_([a-zA-Z0-9_]|\-[a-zA-Z])*', Keyword.Type), # Generic.Emph
2554 (r'[a-z]([a-zA-Z0-9_]|\-[a-zA-Z])*', Keyword.Type),
2555
2556 # type keyword operators
2557 (r'::|\->|[\.:|]', Keyword.Type),
2558
2559 #catchall
2560 (r'', Text, '#pop')
2561 ],
2562
2563 # comments and literals
2564 'whitespace': [
2565 (r'\s+', Text),
2566 (r'/\*', Comment.Multiline, 'comment'),
2567 (r'//.*$', Comment.Single)
2568 ],
2569 'comment': [
2570 (r'[^/\*]+', Comment.Multiline),
2571 (r'/\*', Comment.Multiline, '#push'),
2572 (r'\*/', Comment.Multiline, '#pop'),
2573 (r'[\*/]', Comment.Multiline),
2574 ],
2575 'litstring': [
2576 (r'[^"]+', String.Double),
2577 (r'""', String.Escape),
2578 (r'"', String.Double, '#pop'),
2579 ],
2580 'string': [
2581 (r'[^\\"\n]+', String.Double),
2582 include('escape-sequence'),
2583 (r'["\n]', String.Double, '#pop'),
2584 ],
2585 'char': [
2586 (r'[^\\\'\n]+', String.Char),
2587 include('escape-sequence'),
2588 (r'[\'\n]', String.Char, '#pop'),
2589 ],
2590 'escape-sequence': [
2591 (r'\\[abfnrtv0\\\"\'\?]', String.Escape),
2592 (r'\\x[0-9a-fA-F]{2}', String.Escape),
2593 (r'\\u[0-9a-fA-F]{4}', String.Escape),
2594 # Yes, \U literals are 6 hex digits.
2595 (r'\\U[0-9a-fA-F]{6}', String.Escape)
2596 ]
2597 }
2598

eric ide

mercurial