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 |