1"""
2    pygments.lexers.lisp
3    ~~~~~~~~~~~~~~~~~~~~
4
5    Lexers for Lispy languages.
6
7    :copyright: Copyright 2006-2021 by the Pygments team, see AUTHORS.
8    :license: BSD, see LICENSE for details.
9"""
10
11import re
12
13from pygments.lexer import RegexLexer, include, bygroups, words, default
14from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
15    Number, Punctuation, Literal, Error
16
17from pygments.lexers.python import PythonLexer
18
19__all__ = ['SchemeLexer', 'CommonLispLexer', 'HyLexer', 'RacketLexer',
20           'NewLispLexer', 'EmacsLispLexer', 'ShenLexer', 'CPSALexer',
21           'XtlangLexer', 'FennelLexer']
22
23
24class SchemeLexer(RegexLexer):
25    """
26    A Scheme lexer, parsing a stream and outputting the tokens
27    needed to highlight scheme code.
28    This lexer could be most probably easily subclassed to parse
29    other LISP-Dialects like Common Lisp, Emacs Lisp or AutoLisp.
30
31    This parser is checked with pastes from the LISP pastebin
32    at http://paste.lisp.org/ to cover as much syntax as possible.
33
34    It supports the full Scheme syntax as defined in R5RS.
35
36    .. versionadded:: 0.6
37    """
38    name = 'Scheme'
39    aliases = ['scheme', 'scm']
40    filenames = ['*.scm', '*.ss']
41    mimetypes = ['text/x-scheme', 'application/x-scheme']
42
43    # list of known keywords and builtins taken form vim 6.4 scheme.vim
44    # syntax file.
45    keywords = (
46        'lambda', 'define', 'if', 'else', 'cond', 'and', 'or', 'case', 'let',
47        'let*', 'letrec', 'begin', 'do', 'delay', 'set!', '=>', 'quote',
48        'quasiquote', 'unquote', 'unquote-splicing', 'define-syntax',
49        'let-syntax', 'letrec-syntax', 'syntax-rules'
50    )
51    builtins = (
52        '*', '+', '-', '/', '<', '<=', '=', '>', '>=', 'abs', 'acos', 'angle',
53        'append', 'apply', 'asin', 'assoc', 'assq', 'assv', 'atan',
54        'boolean?', 'caaaar', 'caaadr', 'caaar', 'caadar', 'caaddr', 'caadr',
55        'caar', 'cadaar', 'cadadr', 'cadar', 'caddar', 'cadddr', 'caddr',
56        'cadr', 'call-with-current-continuation', 'call-with-input-file',
57        'call-with-output-file', 'call-with-values', 'call/cc', 'car',
58        'cdaaar', 'cdaadr', 'cdaar', 'cdadar', 'cdaddr', 'cdadr', 'cdar',
59        'cddaar', 'cddadr', 'cddar', 'cdddar', 'cddddr', 'cdddr', 'cddr',
60        'cdr', 'ceiling', 'char->integer', 'char-alphabetic?', 'char-ci<=?',
61        'char-ci<?', 'char-ci=?', 'char-ci>=?', 'char-ci>?', 'char-downcase',
62        'char-lower-case?', 'char-numeric?', 'char-ready?', 'char-upcase',
63        'char-upper-case?', 'char-whitespace?', 'char<=?', 'char<?', 'char=?',
64        'char>=?', 'char>?', 'char?', 'close-input-port', 'close-output-port',
65        'complex?', 'cons', 'cos', 'current-input-port', 'current-output-port',
66        'denominator', 'display', 'dynamic-wind', 'eof-object?', 'eq?',
67        'equal?', 'eqv?', 'eval', 'even?', 'exact->inexact', 'exact?', 'exp',
68        'expt', 'floor', 'for-each', 'force', 'gcd', 'imag-part',
69        'inexact->exact', 'inexact?', 'input-port?', 'integer->char',
70        'integer?', 'interaction-environment', 'lcm', 'length', 'list',
71        'list->string', 'list->vector', 'list-ref', 'list-tail', 'list?',
72        'load', 'log', 'magnitude', 'make-polar', 'make-rectangular',
73        'make-string', 'make-vector', 'map', 'max', 'member', 'memq', 'memv',
74        'min', 'modulo', 'negative?', 'newline', 'not', 'null-environment',
75        'null?', 'number->string', 'number?', 'numerator', 'odd?',
76        'open-input-file', 'open-output-file', 'output-port?', 'pair?',
77        'peek-char', 'port?', 'positive?', 'procedure?', 'quotient',
78        'rational?', 'rationalize', 'read', 'read-char', 'real-part', 'real?',
79        'remainder', 'reverse', 'round', 'scheme-report-environment',
80        'set-car!', 'set-cdr!', 'sin', 'sqrt', 'string', 'string->list',
81        'string->number', 'string->symbol', 'string-append', 'string-ci<=?',
82        'string-ci<?', 'string-ci=?', 'string-ci>=?', 'string-ci>?',
83        'string-copy', 'string-fill!', 'string-length', 'string-ref',
84        'string-set!', 'string<=?', 'string<?', 'string=?', 'string>=?',
85        'string>?', 'string?', 'substring', 'symbol->string', 'symbol?',
86        'tan', 'transcript-off', 'transcript-on', 'truncate', 'values',
87        'vector', 'vector->list', 'vector-fill!', 'vector-length',
88        'vector-ref', 'vector-set!', 'vector?', 'with-input-from-file',
89        'with-output-to-file', 'write', 'write-char', 'zero?'
90    )
91
92    # valid names for identifiers
93    # well, names can only not consist fully of numbers
94    # but this should be good enough for now
95    valid_name = r'[\w!$%&*+,/:<=>?@^~|-]+'
96
97    tokens = {
98        'root': [
99            # the comments
100            # and going to the end of the line
101            (r';.*$', Comment.Single),
102            # multi-line comment
103            (r'#\|', Comment.Multiline, 'multiline-comment'),
104            # commented form (entire sexpr folliwng)
105            (r'#;\s*\(', Comment, 'commented-form'),
106            # signifies that the program text that follows is written with the
107            # lexical and datum syntax described in r6rs
108            (r'#!r6rs', Comment),
109
110            # whitespaces - usually not relevant
111            (r'\s+', Text),
112
113            # numbers
114            (r'-?\d+\.\d+', Number.Float),
115            (r'-?\d+', Number.Integer),
116            # support for uncommon kinds of numbers -
117            # have to figure out what the characters mean
118            # (r'(#e|#i|#b|#o|#d|#x)[\d.]+', Number),
119
120            # strings, symbols and characters
121            (r'"(\\\\|\\[^\\]|[^"\\])*"', String),
122            (r"'" + valid_name, String.Symbol),
123            (r"#\\([()/'\"._!§$%& ?=+-]|[a-zA-Z0-9]+)", String.Char),
124
125            # constants
126            (r'(#t|#f)', Name.Constant),
127
128            # special operators
129            (r"('|#|`|,@|,|\.)", Operator),
130
131            # highlight the keywords
132            ('(%s)' % '|'.join(re.escape(entry) + ' ' for entry in keywords),
133             Keyword),
134
135            # first variable in a quoted string like
136            # '(this is syntactic sugar)
137            (r"(?<='\()" + valid_name, Name.Variable),
138            (r"(?<=#\()" + valid_name, Name.Variable),
139
140            # highlight the builtins
141            (r"(?<=\()(%s)" % '|'.join(re.escape(entry) + ' ' for entry in builtins),
142             Name.Builtin),
143
144            # the remaining functions
145            (r'(?<=\()' + valid_name, Name.Function),
146            # find the remaining variables
147            (valid_name, Name.Variable),
148
149            # the famous parentheses!
150            (r'(\(|\))', Punctuation),
151            (r'(\[|\])', Punctuation),
152        ],
153        'multiline-comment': [
154            (r'#\|', Comment.Multiline, '#push'),
155            (r'\|#', Comment.Multiline, '#pop'),
156            (r'[^|#]+', Comment.Multiline),
157            (r'[|#]', Comment.Multiline),
158        ],
159        'commented-form': [
160            (r'\(', Comment, '#push'),
161            (r'\)', Comment, '#pop'),
162            (r'[^()]+', Comment),
163        ],
164    }
165
166
167class CommonLispLexer(RegexLexer):
168    """
169    A Common Lisp lexer.
170
171    .. versionadded:: 0.9
172    """
173    name = 'Common Lisp'
174    aliases = ['common-lisp', 'cl', 'lisp']
175    filenames = ['*.cl', '*.lisp']
176    mimetypes = ['text/x-common-lisp']
177
178    flags = re.IGNORECASE | re.MULTILINE
179
180    # couple of useful regexes
181
182    # characters that are not macro-characters and can be used to begin a symbol
183    nonmacro = r'\\.|[\w!$%&*+-/<=>?@\[\]^{}~]'
184    constituent = nonmacro + '|[#.:]'
185    terminated = r'(?=[ "()\'\n,;`])'  # whitespace or terminating macro characters
186
187    # symbol token, reverse-engineered from hyperspec
188    # Take a deep breath...
189    symbol = r'(\|[^|]+\||(?:%s)(?:%s)*)' % (nonmacro, constituent)
190
191    def __init__(self, **options):
192        from pygments.lexers._cl_builtins import BUILTIN_FUNCTIONS, \
193            SPECIAL_FORMS, MACROS, LAMBDA_LIST_KEYWORDS, DECLARATIONS, \
194            BUILTIN_TYPES, BUILTIN_CLASSES
195        self.builtin_function = BUILTIN_FUNCTIONS
196        self.special_forms = SPECIAL_FORMS
197        self.macros = MACROS
198        self.lambda_list_keywords = LAMBDA_LIST_KEYWORDS
199        self.declarations = DECLARATIONS
200        self.builtin_types = BUILTIN_TYPES
201        self.builtin_classes = BUILTIN_CLASSES
202        RegexLexer.__init__(self, **options)
203
204    def get_tokens_unprocessed(self, text):
205        stack = ['root']
206        for index, token, value in RegexLexer.get_tokens_unprocessed(self, text, stack):
207            if token is Name.Variable:
208                if value in self.builtin_function:
209                    yield index, Name.Builtin, value
210                    continue
211                if value in self.special_forms:
212                    yield index, Keyword, value
213                    continue
214                if value in self.macros:
215                    yield index, Name.Builtin, value
216                    continue
217                if value in self.lambda_list_keywords:
218                    yield index, Keyword, value
219                    continue
220                if value in self.declarations:
221                    yield index, Keyword, value
222                    continue
223                if value in self.builtin_types:
224                    yield index, Keyword.Type, value
225                    continue
226                if value in self.builtin_classes:
227                    yield index, Name.Class, value
228                    continue
229            yield index, token, value
230
231    tokens = {
232        'root': [
233            default('body'),
234        ],
235        'multiline-comment': [
236            (r'#\|', Comment.Multiline, '#push'),  # (cf. Hyperspec 2.4.8.19)
237            (r'\|#', Comment.Multiline, '#pop'),
238            (r'[^|#]+', Comment.Multiline),
239            (r'[|#]', Comment.Multiline),
240        ],
241        'commented-form': [
242            (r'\(', Comment.Preproc, '#push'),
243            (r'\)', Comment.Preproc, '#pop'),
244            (r'[^()]+', Comment.Preproc),
245        ],
246        'body': [
247            # whitespace
248            (r'\s+', Text),
249
250            # single-line comment
251            (r';.*$', Comment.Single),
252
253            # multi-line comment
254            (r'#\|', Comment.Multiline, 'multiline-comment'),
255
256            # encoding comment (?)
257            (r'#\d*Y.*$', Comment.Special),
258
259            # strings and characters
260            (r'"(\\.|\\\n|[^"\\])*"', String),
261            # quoting
262            (r":" + symbol, String.Symbol),
263            (r"::" + symbol, String.Symbol),
264            (r":#" + symbol, String.Symbol),
265            (r"'" + symbol, String.Symbol),
266            (r"'", Operator),
267            (r"`", Operator),
268
269            # decimal numbers
270            (r'[-+]?\d+\.?' + terminated, Number.Integer),
271            (r'[-+]?\d+/\d+' + terminated, Number),
272            (r'[-+]?(\d*\.\d+([defls][-+]?\d+)?|\d+(\.\d*)?[defls][-+]?\d+)' +
273             terminated, Number.Float),
274
275            # sharpsign strings and characters
276            (r"#\\." + terminated, String.Char),
277            (r"#\\" + symbol, String.Char),
278
279            # vector
280            (r'#\(', Operator, 'body'),
281
282            # bitstring
283            (r'#\d*\*[01]*', Literal.Other),
284
285            # uninterned symbol
286            (r'#:' + symbol, String.Symbol),
287
288            # read-time and load-time evaluation
289            (r'#[.,]', Operator),
290
291            # function shorthand
292            (r'#\'', Name.Function),
293
294            # binary rational
295            (r'#b[+-]?[01]+(/[01]+)?', Number.Bin),
296
297            # octal rational
298            (r'#o[+-]?[0-7]+(/[0-7]+)?', Number.Oct),
299
300            # hex rational
301            (r'#x[+-]?[0-9a-f]+(/[0-9a-f]+)?', Number.Hex),
302
303            # radix rational
304            (r'#\d+r[+-]?[0-9a-z]+(/[0-9a-z]+)?', Number),
305
306            # complex
307            (r'(#c)(\()', bygroups(Number, Punctuation), 'body'),
308
309            # array
310            (r'(#\d+a)(\()', bygroups(Literal.Other, Punctuation), 'body'),
311
312            # structure
313            (r'(#s)(\()', bygroups(Literal.Other, Punctuation), 'body'),
314
315            # path
316            (r'#p?"(\\.|[^"])*"', Literal.Other),
317
318            # reference
319            (r'#\d+=', Operator),
320            (r'#\d+#', Operator),
321
322            # read-time comment
323            (r'#+nil' + terminated + r'\s*\(', Comment.Preproc, 'commented-form'),
324
325            # read-time conditional
326            (r'#[+-]', Operator),
327
328            # special operators that should have been parsed already
329            (r'(,@|,|\.)', Operator),
330
331            # special constants
332            (r'(t|nil)' + terminated, Name.Constant),
333
334            # functions and variables
335            (r'\*' + symbol + r'\*', Name.Variable.Global),
336            (symbol, Name.Variable),
337
338            # parentheses
339            (r'\(', Punctuation, 'body'),
340            (r'\)', Punctuation, '#pop'),
341        ],
342    }
343
344
345class HyLexer(RegexLexer):
346    """
347    Lexer for `Hy <http://hylang.org/>`_ source code.
348
349    .. versionadded:: 2.0
350    """
351    name = 'Hy'
352    aliases = ['hylang']
353    filenames = ['*.hy']
354    mimetypes = ['text/x-hy', 'application/x-hy']
355
356    special_forms = (
357        'cond', 'for', '->', '->>', 'car',
358        'cdr', 'first', 'rest', 'let', 'when', 'unless',
359        'import', 'do', 'progn', 'get', 'slice', 'assoc', 'with-decorator',
360        ',', 'list_comp', 'kwapply', '~', 'is', 'in', 'is-not', 'not-in',
361        'quasiquote', 'unquote', 'unquote-splice', 'quote', '|', '<<=', '>>=',
362        'foreach', 'while',
363        'eval-and-compile', 'eval-when-compile'
364    )
365
366    declarations = (
367        'def', 'defn', 'defun', 'defmacro', 'defclass', 'lambda', 'fn', 'setv'
368    )
369
370    hy_builtins = ()
371
372    hy_core = (
373        'cycle', 'dec', 'distinct', 'drop', 'even?', 'filter', 'inc',
374        'instance?', 'iterable?', 'iterate', 'iterator?', 'neg?',
375        'none?', 'nth', 'numeric?', 'odd?', 'pos?', 'remove', 'repeat',
376        'repeatedly', 'take', 'take_nth', 'take_while', 'zero?'
377    )
378
379    builtins = hy_builtins + hy_core
380
381    # valid names for identifiers
382    # well, names can only not consist fully of numbers
383    # but this should be good enough for now
384    valid_name = r'(?!#)[\w!$%*+<=>?/.#:-]+'
385
386    def _multi_escape(entries):
387        return words(entries, suffix=' ')
388
389    tokens = {
390        'root': [
391            # the comments - always starting with semicolon
392            # and going to the end of the line
393            (r';.*$', Comment.Single),
394
395            # whitespaces - usually not relevant
396            (r'[,\s]+', Text),
397
398            # numbers
399            (r'-?\d+\.\d+', Number.Float),
400            (r'-?\d+', Number.Integer),
401            (r'0[0-7]+j?', Number.Oct),
402            (r'0[xX][a-fA-F0-9]+', Number.Hex),
403
404            # strings, symbols and characters
405            (r'"(\\\\|\\[^\\]|[^"\\])*"', String),
406            (r"'" + valid_name, String.Symbol),
407            (r"\\(.|[a-z]+)", String.Char),
408            (r'^(\s*)([rRuU]{,2}"""(?:.|\n)*?""")', bygroups(Text, String.Doc)),
409            (r"^(\s*)([rRuU]{,2}'''(?:.|\n)*?''')", bygroups(Text, String.Doc)),
410
411            # keywords
412            (r'::?' + valid_name, String.Symbol),
413
414            # special operators
415            (r'~@|[`\'#^~&@]', Operator),
416
417            include('py-keywords'),
418            include('py-builtins'),
419
420            # highlight the special forms
421            (_multi_escape(special_forms), Keyword),
422
423            # Technically, only the special forms are 'keywords'. The problem
424            # is that only treating them as keywords means that things like
425            # 'defn' and 'ns' need to be highlighted as builtins. This is ugly
426            # and weird for most styles. So, as a compromise we're going to
427            # highlight them as Keyword.Declarations.
428            (_multi_escape(declarations), Keyword.Declaration),
429
430            # highlight the builtins
431            (_multi_escape(builtins), Name.Builtin),
432
433            # the remaining functions
434            (r'(?<=\()' + valid_name, Name.Function),
435
436            # find the remaining variables
437            (valid_name, Name.Variable),
438
439            # Hy accepts vector notation
440            (r'(\[|\])', Punctuation),
441
442            # Hy accepts map notation
443            (r'(\{|\})', Punctuation),
444
445            # the famous parentheses!
446            (r'(\(|\))', Punctuation),
447
448        ],
449        'py-keywords': PythonLexer.tokens['keywords'],
450        'py-builtins': PythonLexer.tokens['builtins'],
451    }
452
453    def analyse_text(text):
454        if '(import ' in text or '(defn ' in text:
455            return 0.9
456
457
458class RacketLexer(RegexLexer):
459    """
460    Lexer for `Racket <http://racket-lang.org/>`_ source code (formerly
461    known as PLT Scheme).
462
463    .. versionadded:: 1.6
464    """
465
466    name = 'Racket'
467    aliases = ['racket', 'rkt']
468    filenames = ['*.rkt', '*.rktd', '*.rktl']
469    mimetypes = ['text/x-racket', 'application/x-racket']
470
471    # Generated by example.rkt
472    _keywords = (
473        '#%app', '#%datum', '#%declare', '#%expression', '#%module-begin',
474        '#%plain-app', '#%plain-lambda', '#%plain-module-begin',
475        '#%printing-module-begin', '#%provide', '#%require',
476        '#%stratified-body', '#%top', '#%top-interaction',
477        '#%variable-reference', '->', '->*', '->*m', '->d', '->dm', '->i',
478        '->m', '...', ':do-in', '==', '=>', '_', 'absent', 'abstract',
479        'all-defined-out', 'all-from-out', 'and', 'any', 'augment', 'augment*',
480        'augment-final', 'augment-final*', 'augride', 'augride*', 'begin',
481        'begin-for-syntax', 'begin0', 'case', 'case->', 'case->m',
482        'case-lambda', 'class', 'class*', 'class-field-accessor',
483        'class-field-mutator', 'class/c', 'class/derived', 'combine-in',
484        'combine-out', 'command-line', 'compound-unit', 'compound-unit/infer',
485        'cond', 'cons/dc', 'contract', 'contract-out', 'contract-struct',
486        'contracted', 'define', 'define-compound-unit',
487        'define-compound-unit/infer', 'define-contract-struct',
488        'define-custom-hash-types', 'define-custom-set-types',
489        'define-for-syntax', 'define-local-member-name', 'define-logger',
490        'define-match-expander', 'define-member-name',
491        'define-module-boundary-contract', 'define-namespace-anchor',
492        'define-opt/c', 'define-sequence-syntax', 'define-serializable-class',
493        'define-serializable-class*', 'define-signature',
494        'define-signature-form', 'define-struct', 'define-struct/contract',
495        'define-struct/derived', 'define-syntax', 'define-syntax-rule',
496        'define-syntaxes', 'define-unit', 'define-unit-binding',
497        'define-unit-from-context', 'define-unit/contract',
498        'define-unit/new-import-export', 'define-unit/s', 'define-values',
499        'define-values-for-export', 'define-values-for-syntax',
500        'define-values/invoke-unit', 'define-values/invoke-unit/infer',
501        'define/augment', 'define/augment-final', 'define/augride',
502        'define/contract', 'define/final-prop', 'define/match',
503        'define/overment', 'define/override', 'define/override-final',
504        'define/private', 'define/public', 'define/public-final',
505        'define/pubment', 'define/subexpression-pos-prop',
506        'define/subexpression-pos-prop/name', 'delay', 'delay/idle',
507        'delay/name', 'delay/strict', 'delay/sync', 'delay/thread', 'do',
508        'else', 'except', 'except-in', 'except-out', 'export', 'extends',
509        'failure-cont', 'false', 'false/c', 'field', 'field-bound?', 'file',
510        'flat-murec-contract', 'flat-rec-contract', 'for', 'for*', 'for*/and',
511        'for*/async', 'for*/first', 'for*/fold', 'for*/fold/derived',
512        'for*/hash', 'for*/hasheq', 'for*/hasheqv', 'for*/last', 'for*/list',
513        'for*/lists', 'for*/mutable-set', 'for*/mutable-seteq',
514        'for*/mutable-seteqv', 'for*/or', 'for*/product', 'for*/set',
515        'for*/seteq', 'for*/seteqv', 'for*/stream', 'for*/sum', 'for*/vector',
516        'for*/weak-set', 'for*/weak-seteq', 'for*/weak-seteqv', 'for-label',
517        'for-meta', 'for-syntax', 'for-template', 'for/and', 'for/async',
518        'for/first', 'for/fold', 'for/fold/derived', 'for/hash', 'for/hasheq',
519        'for/hasheqv', 'for/last', 'for/list', 'for/lists', 'for/mutable-set',
520        'for/mutable-seteq', 'for/mutable-seteqv', 'for/or', 'for/product',
521        'for/set', 'for/seteq', 'for/seteqv', 'for/stream', 'for/sum',
522        'for/vector', 'for/weak-set', 'for/weak-seteq', 'for/weak-seteqv',
523        'gen:custom-write', 'gen:dict', 'gen:equal+hash', 'gen:set',
524        'gen:stream', 'generic', 'get-field', 'hash/dc', 'if', 'implies',
525        'import', 'include', 'include-at/relative-to',
526        'include-at/relative-to/reader', 'include/reader', 'inherit',
527        'inherit-field', 'inherit/inner', 'inherit/super', 'init',
528        'init-depend', 'init-field', 'init-rest', 'inner', 'inspect',
529        'instantiate', 'interface', 'interface*', 'invariant-assertion',
530        'invoke-unit', 'invoke-unit/infer', 'lambda', 'lazy', 'let', 'let*',
531        'let*-values', 'let-syntax', 'let-syntaxes', 'let-values', 'let/cc',
532        'let/ec', 'letrec', 'letrec-syntax', 'letrec-syntaxes',
533        'letrec-syntaxes+values', 'letrec-values', 'lib', 'link', 'local',
534        'local-require', 'log-debug', 'log-error', 'log-fatal', 'log-info',
535        'log-warning', 'match', 'match*', 'match*/derived', 'match-define',
536        'match-define-values', 'match-lambda', 'match-lambda*',
537        'match-lambda**', 'match-let', 'match-let*', 'match-let*-values',
538        'match-let-values', 'match-letrec', 'match-letrec-values',
539        'match/derived', 'match/values', 'member-name-key', 'mixin', 'module',
540        'module*', 'module+', 'nand', 'new', 'nor', 'object-contract',
541        'object/c', 'only', 'only-in', 'only-meta-in', 'open', 'opt/c', 'or',
542        'overment', 'overment*', 'override', 'override*', 'override-final',
543        'override-final*', 'parameterize', 'parameterize*',
544        'parameterize-break', 'parametric->/c', 'place', 'place*',
545        'place/context', 'planet', 'prefix', 'prefix-in', 'prefix-out',
546        'private', 'private*', 'prompt-tag/c', 'protect-out', 'provide',
547        'provide-signature-elements', 'provide/contract', 'public', 'public*',
548        'public-final', 'public-final*', 'pubment', 'pubment*', 'quasiquote',
549        'quasisyntax', 'quasisyntax/loc', 'quote', 'quote-syntax',
550        'quote-syntax/prune', 'recontract-out', 'recursive-contract',
551        'relative-in', 'rename', 'rename-in', 'rename-inner', 'rename-out',
552        'rename-super', 'require', 'send', 'send*', 'send+', 'send-generic',
553        'send/apply', 'send/keyword-apply', 'set!', 'set!-values',
554        'set-field!', 'shared', 'stream', 'stream*', 'stream-cons', 'struct',
555        'struct*', 'struct-copy', 'struct-field-index', 'struct-out',
556        'struct/c', 'struct/ctc', 'struct/dc', 'submod', 'super',
557        'super-instantiate', 'super-make-object', 'super-new', 'syntax',
558        'syntax-case', 'syntax-case*', 'syntax-id-rules', 'syntax-rules',
559        'syntax/loc', 'tag', 'this', 'this%', 'thunk', 'thunk*', 'time',
560        'unconstrained-domain->', 'unit', 'unit-from-context', 'unit/c',
561        'unit/new-import-export', 'unit/s', 'unless', 'unquote',
562        'unquote-splicing', 'unsyntax', 'unsyntax-splicing', 'values/drop',
563        'when', 'with-continuation-mark', 'with-contract',
564        'with-contract-continuation-mark', 'with-handlers', 'with-handlers*',
565        'with-method', 'with-syntax', 'λ'
566    )
567
568    # Generated by example.rkt
569    _builtins = (
570        '*', '*list/c', '+', '-', '/', '<', '</c', '<=', '<=/c', '=', '=/c',
571        '>', '>/c', '>=', '>=/c', 'abort-current-continuation', 'abs',
572        'absolute-path?', 'acos', 'add-between', 'add1', 'alarm-evt',
573        'always-evt', 'and/c', 'andmap', 'angle', 'any/c', 'append', 'append*',
574        'append-map', 'apply', 'argmax', 'argmin', 'arithmetic-shift',
575        'arity-at-least', 'arity-at-least-value', 'arity-at-least?',
576        'arity-checking-wrapper', 'arity-includes?', 'arity=?',
577        'arrow-contract-info', 'arrow-contract-info-accepts-arglist',
578        'arrow-contract-info-chaperone-procedure',
579        'arrow-contract-info-check-first-order', 'arrow-contract-info?',
580        'asin', 'assf', 'assoc', 'assq', 'assv', 'atan',
581        'bad-number-of-results', 'banner', 'base->-doms/c', 'base->-rngs/c',
582        'base->?', 'between/c', 'bitwise-and', 'bitwise-bit-field',
583        'bitwise-bit-set?', 'bitwise-ior', 'bitwise-not', 'bitwise-xor',
584        'blame-add-car-context', 'blame-add-cdr-context', 'blame-add-context',
585        'blame-add-missing-party', 'blame-add-nth-arg-context',
586        'blame-add-range-context', 'blame-add-unknown-context',
587        'blame-context', 'blame-contract', 'blame-fmt->-string',
588        'blame-missing-party?', 'blame-negative', 'blame-original?',
589        'blame-positive', 'blame-replace-negative', 'blame-source',
590        'blame-swap', 'blame-swapped?', 'blame-update', 'blame-value',
591        'blame?', 'boolean=?', 'boolean?', 'bound-identifier=?', 'box',
592        'box-cas!', 'box-immutable', 'box-immutable/c', 'box/c', 'box?',
593        'break-enabled', 'break-parameterization?', 'break-thread',
594        'build-chaperone-contract-property', 'build-compound-type-name',
595        'build-contract-property', 'build-flat-contract-property',
596        'build-list', 'build-path', 'build-path/convention-type',
597        'build-string', 'build-vector', 'byte-pregexp', 'byte-pregexp?',
598        'byte-ready?', 'byte-regexp', 'byte-regexp?', 'byte?', 'bytes',
599        'bytes->immutable-bytes', 'bytes->list', 'bytes->path',
600        'bytes->path-element', 'bytes->string/latin-1', 'bytes->string/locale',
601        'bytes->string/utf-8', 'bytes-append', 'bytes-append*',
602        'bytes-close-converter', 'bytes-convert', 'bytes-convert-end',
603        'bytes-converter?', 'bytes-copy', 'bytes-copy!',
604        'bytes-environment-variable-name?', 'bytes-fill!', 'bytes-join',
605        'bytes-length', 'bytes-no-nuls?', 'bytes-open-converter', 'bytes-ref',
606        'bytes-set!', 'bytes-utf-8-index', 'bytes-utf-8-length',
607        'bytes-utf-8-ref', 'bytes<?', 'bytes=?', 'bytes>?', 'bytes?', 'caaaar',
608        'caaadr', 'caaar', 'caadar', 'caaddr', 'caadr', 'caar', 'cadaar',
609        'cadadr', 'cadar', 'caddar', 'cadddr', 'caddr', 'cadr',
610        'call-in-nested-thread', 'call-with-atomic-output-file',
611        'call-with-break-parameterization',
612        'call-with-composable-continuation', 'call-with-continuation-barrier',
613        'call-with-continuation-prompt', 'call-with-current-continuation',
614        'call-with-default-reading-parameterization',
615        'call-with-escape-continuation', 'call-with-exception-handler',
616        'call-with-file-lock/timeout', 'call-with-immediate-continuation-mark',
617        'call-with-input-bytes', 'call-with-input-file',
618        'call-with-input-file*', 'call-with-input-string',
619        'call-with-output-bytes', 'call-with-output-file',
620        'call-with-output-file*', 'call-with-output-string',
621        'call-with-parameterization', 'call-with-semaphore',
622        'call-with-semaphore/enable-break', 'call-with-values', 'call/cc',
623        'call/ec', 'car', 'cartesian-product', 'cdaaar', 'cdaadr', 'cdaar',
624        'cdadar', 'cdaddr', 'cdadr', 'cdar', 'cddaar', 'cddadr', 'cddar',
625        'cdddar', 'cddddr', 'cdddr', 'cddr', 'cdr', 'ceiling', 'channel-get',
626        'channel-put', 'channel-put-evt', 'channel-put-evt?',
627        'channel-try-get', 'channel/c', 'channel?', 'chaperone-box',
628        'chaperone-channel', 'chaperone-continuation-mark-key',
629        'chaperone-contract-property?', 'chaperone-contract?', 'chaperone-evt',
630        'chaperone-hash', 'chaperone-hash-set', 'chaperone-of?',
631        'chaperone-procedure', 'chaperone-procedure*', 'chaperone-prompt-tag',
632        'chaperone-struct', 'chaperone-struct-type', 'chaperone-vector',
633        'chaperone?', 'char->integer', 'char-alphabetic?', 'char-blank?',
634        'char-ci<=?', 'char-ci<?', 'char-ci=?', 'char-ci>=?', 'char-ci>?',
635        'char-downcase', 'char-foldcase', 'char-general-category',
636        'char-graphic?', 'char-in', 'char-in/c', 'char-iso-control?',
637        'char-lower-case?', 'char-numeric?', 'char-punctuation?',
638        'char-ready?', 'char-symbolic?', 'char-title-case?', 'char-titlecase',
639        'char-upcase', 'char-upper-case?', 'char-utf-8-length',
640        'char-whitespace?', 'char<=?', 'char<?', 'char=?', 'char>=?', 'char>?',
641        'char?', 'check-duplicate-identifier', 'check-duplicates',
642        'checked-procedure-check-and-extract', 'choice-evt',
643        'class->interface', 'class-info', 'class-seal', 'class-unseal',
644        'class?', 'cleanse-path', 'close-input-port', 'close-output-port',
645        'coerce-chaperone-contract', 'coerce-chaperone-contracts',
646        'coerce-contract', 'coerce-contract/f', 'coerce-contracts',
647        'coerce-flat-contract', 'coerce-flat-contracts', 'collect-garbage',
648        'collection-file-path', 'collection-path', 'combinations', 'compile',
649        'compile-allow-set!-undefined', 'compile-context-preservation-enabled',
650        'compile-enforce-module-constants', 'compile-syntax',
651        'compiled-expression-recompile', 'compiled-expression?',
652        'compiled-module-expression?', 'complete-path?', 'complex?', 'compose',
653        'compose1', 'conjoin', 'conjugate', 'cons', 'cons/c', 'cons?', 'const',
654        'continuation-mark-key/c', 'continuation-mark-key?',
655        'continuation-mark-set->context', 'continuation-mark-set->list',
656        'continuation-mark-set->list*', 'continuation-mark-set-first',
657        'continuation-mark-set?', 'continuation-marks',
658        'continuation-prompt-available?', 'continuation-prompt-tag?',
659        'continuation?', 'contract-continuation-mark-key',
660        'contract-custom-write-property-proc', 'contract-exercise',
661        'contract-first-order', 'contract-first-order-passes?',
662        'contract-late-neg-projection', 'contract-name', 'contract-proc',
663        'contract-projection', 'contract-property?',
664        'contract-random-generate', 'contract-random-generate-fail',
665        'contract-random-generate-fail?',
666        'contract-random-generate-get-current-environment',
667        'contract-random-generate-stash', 'contract-random-generate/choose',
668        'contract-stronger?', 'contract-struct-exercise',
669        'contract-struct-generate', 'contract-struct-late-neg-projection',
670        'contract-struct-list-contract?', 'contract-val-first-projection',
671        'contract?', 'convert-stream', 'copy-directory/files', 'copy-file',
672        'copy-port', 'cos', 'cosh', 'count', 'current-blame-format',
673        'current-break-parameterization', 'current-code-inspector',
674        'current-command-line-arguments', 'current-compile',
675        'current-compiled-file-roots', 'current-continuation-marks',
676        'current-contract-region', 'current-custodian', 'current-directory',
677        'current-directory-for-user', 'current-drive',
678        'current-environment-variables', 'current-error-port', 'current-eval',
679        'current-evt-pseudo-random-generator',
680        'current-force-delete-permissions', 'current-future',
681        'current-gc-milliseconds', 'current-get-interaction-input-port',
682        'current-inexact-milliseconds', 'current-input-port',
683        'current-inspector', 'current-library-collection-links',
684        'current-library-collection-paths', 'current-load',
685        'current-load-extension', 'current-load-relative-directory',
686        'current-load/use-compiled', 'current-locale', 'current-logger',
687        'current-memory-use', 'current-milliseconds',
688        'current-module-declare-name', 'current-module-declare-source',
689        'current-module-name-resolver', 'current-module-path-for-load',
690        'current-namespace', 'current-output-port', 'current-parameterization',
691        'current-plumber', 'current-preserved-thread-cell-values',
692        'current-print', 'current-process-milliseconds', 'current-prompt-read',
693        'current-pseudo-random-generator', 'current-read-interaction',
694        'current-reader-guard', 'current-readtable', 'current-seconds',
695        'current-security-guard', 'current-subprocess-custodian-mode',
696        'current-thread', 'current-thread-group',
697        'current-thread-initial-stack-size',
698        'current-write-relative-directory', 'curry', 'curryr',
699        'custodian-box-value', 'custodian-box?', 'custodian-limit-memory',
700        'custodian-managed-list', 'custodian-memory-accounting-available?',
701        'custodian-require-memory', 'custodian-shutdown-all', 'custodian?',
702        'custom-print-quotable-accessor', 'custom-print-quotable?',
703        'custom-write-accessor', 'custom-write-property-proc', 'custom-write?',
704        'date', 'date*', 'date*-nanosecond', 'date*-time-zone-name', 'date*?',
705        'date-day', 'date-dst?', 'date-hour', 'date-minute', 'date-month',
706        'date-second', 'date-time-zone-offset', 'date-week-day', 'date-year',
707        'date-year-day', 'date?', 'datum->syntax', 'datum-intern-literal',
708        'default-continuation-prompt-tag', 'degrees->radians',
709        'delete-directory', 'delete-directory/files', 'delete-file',
710        'denominator', 'dict->list', 'dict-can-functional-set?',
711        'dict-can-remove-keys?', 'dict-clear', 'dict-clear!', 'dict-copy',
712        'dict-count', 'dict-empty?', 'dict-for-each', 'dict-has-key?',
713        'dict-implements/c', 'dict-implements?', 'dict-iter-contract',
714        'dict-iterate-first', 'dict-iterate-key', 'dict-iterate-next',
715        'dict-iterate-value', 'dict-key-contract', 'dict-keys', 'dict-map',
716        'dict-mutable?', 'dict-ref', 'dict-ref!', 'dict-remove',
717        'dict-remove!', 'dict-set', 'dict-set!', 'dict-set*', 'dict-set*!',
718        'dict-update', 'dict-update!', 'dict-value-contract', 'dict-values',
719        'dict?', 'directory-exists?', 'directory-list', 'disjoin', 'display',
720        'display-lines', 'display-lines-to-file', 'display-to-file',
721        'displayln', 'double-flonum?', 'drop', 'drop-common-prefix',
722        'drop-right', 'dropf', 'dropf-right', 'dump-memory-stats',
723        'dup-input-port', 'dup-output-port', 'dynamic->*', 'dynamic-get-field',
724        'dynamic-object/c', 'dynamic-place', 'dynamic-place*',
725        'dynamic-require', 'dynamic-require-for-syntax', 'dynamic-send',
726        'dynamic-set-field!', 'dynamic-wind', 'eighth', 'empty',
727        'empty-sequence', 'empty-stream', 'empty?',
728        'environment-variables-copy', 'environment-variables-names',
729        'environment-variables-ref', 'environment-variables-set!',
730        'environment-variables?', 'eof', 'eof-evt', 'eof-object?',
731        'ephemeron-value', 'ephemeron?', 'eprintf', 'eq-contract-val',
732        'eq-contract?', 'eq-hash-code', 'eq?', 'equal-contract-val',
733        'equal-contract?', 'equal-hash-code', 'equal-secondary-hash-code',
734        'equal<%>', 'equal?', 'equal?/recur', 'eqv-hash-code', 'eqv?', 'error',
735        'error-display-handler', 'error-escape-handler',
736        'error-print-context-length', 'error-print-source-location',
737        'error-print-width', 'error-value->string-handler', 'eval',
738        'eval-jit-enabled', 'eval-syntax', 'even?', 'evt/c', 'evt?',
739        'exact->inexact', 'exact-ceiling', 'exact-floor', 'exact-integer?',
740        'exact-nonnegative-integer?', 'exact-positive-integer?', 'exact-round',
741        'exact-truncate', 'exact?', 'executable-yield-handler', 'exit',
742        'exit-handler', 'exn', 'exn-continuation-marks', 'exn-message',
743        'exn:break', 'exn:break-continuation', 'exn:break:hang-up',
744        'exn:break:hang-up?', 'exn:break:terminate', 'exn:break:terminate?',
745        'exn:break?', 'exn:fail', 'exn:fail:contract',
746        'exn:fail:contract:arity', 'exn:fail:contract:arity?',
747        'exn:fail:contract:blame', 'exn:fail:contract:blame-object',
748        'exn:fail:contract:blame?', 'exn:fail:contract:continuation',
749        'exn:fail:contract:continuation?', 'exn:fail:contract:divide-by-zero',
750        'exn:fail:contract:divide-by-zero?',
751        'exn:fail:contract:non-fixnum-result',
752        'exn:fail:contract:non-fixnum-result?', 'exn:fail:contract:variable',
753        'exn:fail:contract:variable-id', 'exn:fail:contract:variable?',
754        'exn:fail:contract?', 'exn:fail:filesystem',
755        'exn:fail:filesystem:errno', 'exn:fail:filesystem:errno-errno',
756        'exn:fail:filesystem:errno?', 'exn:fail:filesystem:exists',
757        'exn:fail:filesystem:exists?', 'exn:fail:filesystem:missing-module',
758        'exn:fail:filesystem:missing-module-path',
759        'exn:fail:filesystem:missing-module?', 'exn:fail:filesystem:version',
760        'exn:fail:filesystem:version?', 'exn:fail:filesystem?',
761        'exn:fail:network', 'exn:fail:network:errno',
762        'exn:fail:network:errno-errno', 'exn:fail:network:errno?',
763        'exn:fail:network?', 'exn:fail:object', 'exn:fail:object?',
764        'exn:fail:out-of-memory', 'exn:fail:out-of-memory?', 'exn:fail:read',
765        'exn:fail:read-srclocs', 'exn:fail:read:eof', 'exn:fail:read:eof?',
766        'exn:fail:read:non-char', 'exn:fail:read:non-char?', 'exn:fail:read?',
767        'exn:fail:syntax', 'exn:fail:syntax-exprs',
768        'exn:fail:syntax:missing-module',
769        'exn:fail:syntax:missing-module-path',
770        'exn:fail:syntax:missing-module?', 'exn:fail:syntax:unbound',
771        'exn:fail:syntax:unbound?', 'exn:fail:syntax?', 'exn:fail:unsupported',
772        'exn:fail:unsupported?', 'exn:fail:user', 'exn:fail:user?',
773        'exn:fail?', 'exn:misc:match?', 'exn:missing-module-accessor',
774        'exn:missing-module?', 'exn:srclocs-accessor', 'exn:srclocs?', 'exn?',
775        'exp', 'expand', 'expand-once', 'expand-syntax', 'expand-syntax-once',
776        'expand-syntax-to-top-form', 'expand-to-top-form', 'expand-user-path',
777        'explode-path', 'expt', 'externalizable<%>', 'failure-result/c',
778        'false?', 'field-names', 'fifth', 'file->bytes', 'file->bytes-lines',
779        'file->lines', 'file->list', 'file->string', 'file->value',
780        'file-exists?', 'file-name-from-path', 'file-or-directory-identity',
781        'file-or-directory-modify-seconds', 'file-or-directory-permissions',
782        'file-position', 'file-position*', 'file-size',
783        'file-stream-buffer-mode', 'file-stream-port?', 'file-truncate',
784        'filename-extension', 'filesystem-change-evt',
785        'filesystem-change-evt-cancel', 'filesystem-change-evt?',
786        'filesystem-root-list', 'filter', 'filter-map', 'filter-not',
787        'filter-read-input-port', 'find-executable-path', 'find-files',
788        'find-library-collection-links', 'find-library-collection-paths',
789        'find-relative-path', 'find-system-path', 'findf', 'first',
790        'first-or/c', 'fixnum?', 'flat-contract', 'flat-contract-predicate',
791        'flat-contract-property?', 'flat-contract?', 'flat-named-contract',
792        'flatten', 'floating-point-bytes->real', 'flonum?', 'floor',
793        'flush-output', 'fold-files', 'foldl', 'foldr', 'for-each', 'force',
794        'format', 'fourth', 'fprintf', 'free-identifier=?',
795        'free-label-identifier=?', 'free-template-identifier=?',
796        'free-transformer-identifier=?', 'fsemaphore-count', 'fsemaphore-post',
797        'fsemaphore-try-wait?', 'fsemaphore-wait', 'fsemaphore?', 'future',
798        'future?', 'futures-enabled?', 'gcd', 'generate-member-key',
799        'generate-temporaries', 'generic-set?', 'generic?', 'gensym',
800        'get-output-bytes', 'get-output-string', 'get-preference',
801        'get/build-late-neg-projection', 'get/build-val-first-projection',
802        'getenv', 'global-port-print-handler', 'group-by', 'group-execute-bit',
803        'group-read-bit', 'group-write-bit', 'guard-evt', 'handle-evt',
804        'handle-evt?', 'has-blame?', 'has-contract?', 'hash', 'hash->list',
805        'hash-clear', 'hash-clear!', 'hash-copy', 'hash-copy-clear',
806        'hash-count', 'hash-empty?', 'hash-eq?', 'hash-equal?', 'hash-eqv?',
807        'hash-for-each', 'hash-has-key?', 'hash-iterate-first',
808        'hash-iterate-key', 'hash-iterate-key+value', 'hash-iterate-next',
809        'hash-iterate-pair', 'hash-iterate-value', 'hash-keys', 'hash-map',
810        'hash-placeholder?', 'hash-ref', 'hash-ref!', 'hash-remove',
811        'hash-remove!', 'hash-set', 'hash-set!', 'hash-set*', 'hash-set*!',
812        'hash-update', 'hash-update!', 'hash-values', 'hash-weak?', 'hash/c',
813        'hash?', 'hasheq', 'hasheqv', 'identifier-binding',
814        'identifier-binding-symbol', 'identifier-label-binding',
815        'identifier-prune-lexical-context',
816        'identifier-prune-to-source-module',
817        'identifier-remove-from-definition-context',
818        'identifier-template-binding', 'identifier-transformer-binding',
819        'identifier?', 'identity', 'if/c', 'imag-part', 'immutable?',
820        'impersonate-box', 'impersonate-channel',
821        'impersonate-continuation-mark-key', 'impersonate-hash',
822        'impersonate-hash-set', 'impersonate-procedure',
823        'impersonate-procedure*', 'impersonate-prompt-tag',
824        'impersonate-struct', 'impersonate-vector', 'impersonator-contract?',
825        'impersonator-ephemeron', 'impersonator-of?',
826        'impersonator-prop:application-mark', 'impersonator-prop:blame',
827        'impersonator-prop:contracted',
828        'impersonator-property-accessor-procedure?', 'impersonator-property?',
829        'impersonator?', 'implementation?', 'implementation?/c', 'in-bytes',
830        'in-bytes-lines', 'in-combinations', 'in-cycle', 'in-dict',
831        'in-dict-keys', 'in-dict-pairs', 'in-dict-values', 'in-directory',
832        'in-hash', 'in-hash-keys', 'in-hash-pairs', 'in-hash-values',
833        'in-immutable-hash', 'in-immutable-hash-keys',
834        'in-immutable-hash-pairs', 'in-immutable-hash-values',
835        'in-immutable-set', 'in-indexed', 'in-input-port-bytes',
836        'in-input-port-chars', 'in-lines', 'in-list', 'in-mlist',
837        'in-mutable-hash', 'in-mutable-hash-keys', 'in-mutable-hash-pairs',
838        'in-mutable-hash-values', 'in-mutable-set', 'in-naturals',
839        'in-parallel', 'in-permutations', 'in-port', 'in-producer', 'in-range',
840        'in-sequences', 'in-set', 'in-slice', 'in-stream', 'in-string',
841        'in-syntax', 'in-value', 'in-values*-sequence', 'in-values-sequence',
842        'in-vector', 'in-weak-hash', 'in-weak-hash-keys', 'in-weak-hash-pairs',
843        'in-weak-hash-values', 'in-weak-set', 'inexact->exact',
844        'inexact-real?', 'inexact?', 'infinite?', 'input-port-append',
845        'input-port?', 'inspector?', 'instanceof/c', 'integer->char',
846        'integer->integer-bytes', 'integer-bytes->integer', 'integer-in',
847        'integer-length', 'integer-sqrt', 'integer-sqrt/remainder', 'integer?',
848        'interface->method-names', 'interface-extension?', 'interface?',
849        'internal-definition-context-binding-identifiers',
850        'internal-definition-context-introduce',
851        'internal-definition-context-seal', 'internal-definition-context?',
852        'is-a?', 'is-a?/c', 'keyword->string', 'keyword-apply', 'keyword<?',
853        'keyword?', 'keywords-match', 'kill-thread', 'last', 'last-pair',
854        'lcm', 'length', 'liberal-define-context?', 'link-exists?', 'list',
855        'list*', 'list*of', 'list->bytes', 'list->mutable-set',
856        'list->mutable-seteq', 'list->mutable-seteqv', 'list->set',
857        'list->seteq', 'list->seteqv', 'list->string', 'list->vector',
858        'list->weak-set', 'list->weak-seteq', 'list->weak-seteqv',
859        'list-contract?', 'list-prefix?', 'list-ref', 'list-set', 'list-tail',
860        'list-update', 'list/c', 'list?', 'listen-port-number?', 'listof',
861        'load', 'load-extension', 'load-on-demand-enabled', 'load-relative',
862        'load-relative-extension', 'load/cd', 'load/use-compiled',
863        'local-expand', 'local-expand/capture-lifts',
864        'local-transformer-expand', 'local-transformer-expand/capture-lifts',
865        'locale-string-encoding', 'log', 'log-all-levels', 'log-level-evt',
866        'log-level?', 'log-max-level', 'log-message', 'log-receiver?',
867        'logger-name', 'logger?', 'magnitude', 'make-arity-at-least',
868        'make-base-empty-namespace', 'make-base-namespace', 'make-bytes',
869        'make-channel', 'make-chaperone-contract',
870        'make-continuation-mark-key', 'make-continuation-prompt-tag',
871        'make-contract', 'make-custodian', 'make-custodian-box',
872        'make-custom-hash', 'make-custom-hash-types', 'make-custom-set',
873        'make-custom-set-types', 'make-date', 'make-date*',
874        'make-derived-parameter', 'make-directory', 'make-directory*',
875        'make-do-sequence', 'make-empty-namespace',
876        'make-environment-variables', 'make-ephemeron', 'make-exn',
877        'make-exn:break', 'make-exn:break:hang-up', 'make-exn:break:terminate',
878        'make-exn:fail', 'make-exn:fail:contract',
879        'make-exn:fail:contract:arity', 'make-exn:fail:contract:blame',
880        'make-exn:fail:contract:continuation',
881        'make-exn:fail:contract:divide-by-zero',
882        'make-exn:fail:contract:non-fixnum-result',
883        'make-exn:fail:contract:variable', 'make-exn:fail:filesystem',
884        'make-exn:fail:filesystem:errno', 'make-exn:fail:filesystem:exists',
885        'make-exn:fail:filesystem:missing-module',
886        'make-exn:fail:filesystem:version', 'make-exn:fail:network',
887        'make-exn:fail:network:errno', 'make-exn:fail:object',
888        'make-exn:fail:out-of-memory', 'make-exn:fail:read',
889        'make-exn:fail:read:eof', 'make-exn:fail:read:non-char',
890        'make-exn:fail:syntax', 'make-exn:fail:syntax:missing-module',
891        'make-exn:fail:syntax:unbound', 'make-exn:fail:unsupported',
892        'make-exn:fail:user', 'make-file-or-directory-link',
893        'make-flat-contract', 'make-fsemaphore', 'make-generic',
894        'make-handle-get-preference-locked', 'make-hash',
895        'make-hash-placeholder', 'make-hasheq', 'make-hasheq-placeholder',
896        'make-hasheqv', 'make-hasheqv-placeholder',
897        'make-immutable-custom-hash', 'make-immutable-hash',
898        'make-immutable-hasheq', 'make-immutable-hasheqv',
899        'make-impersonator-property', 'make-input-port',
900        'make-input-port/read-to-peek', 'make-inspector',
901        'make-keyword-procedure', 'make-known-char-range-list',
902        'make-limited-input-port', 'make-list', 'make-lock-file-name',
903        'make-log-receiver', 'make-logger', 'make-mixin-contract',
904        'make-mutable-custom-set', 'make-none/c', 'make-object',
905        'make-output-port', 'make-parameter', 'make-parent-directory*',
906        'make-phantom-bytes', 'make-pipe', 'make-pipe-with-specials',
907        'make-placeholder', 'make-plumber', 'make-polar', 'make-prefab-struct',
908        'make-primitive-class', 'make-proj-contract',
909        'make-pseudo-random-generator', 'make-reader-graph', 'make-readtable',
910        'make-rectangular', 'make-rename-transformer',
911        'make-resolved-module-path', 'make-security-guard', 'make-semaphore',
912        'make-set!-transformer', 'make-shared-bytes', 'make-sibling-inspector',
913        'make-special-comment', 'make-srcloc', 'make-string',
914        'make-struct-field-accessor', 'make-struct-field-mutator',
915        'make-struct-type', 'make-struct-type-property',
916        'make-syntax-delta-introducer', 'make-syntax-introducer',
917        'make-temporary-file', 'make-tentative-pretty-print-output-port',
918        'make-thread-cell', 'make-thread-group', 'make-vector',
919        'make-weak-box', 'make-weak-custom-hash', 'make-weak-custom-set',
920        'make-weak-hash', 'make-weak-hasheq', 'make-weak-hasheqv',
921        'make-will-executor', 'map', 'match-equality-test',
922        'matches-arity-exactly?', 'max', 'mcar', 'mcdr', 'mcons', 'member',
923        'member-name-key-hash-code', 'member-name-key=?', 'member-name-key?',
924        'memf', 'memq', 'memv', 'merge-input', 'method-in-interface?', 'min',
925        'mixin-contract', 'module->exports', 'module->imports',
926        'module->language-info', 'module->namespace',
927        'module-compiled-cross-phase-persistent?', 'module-compiled-exports',
928        'module-compiled-imports', 'module-compiled-language-info',
929        'module-compiled-name', 'module-compiled-submodules',
930        'module-declared?', 'module-path-index-join',
931        'module-path-index-resolve', 'module-path-index-split',
932        'module-path-index-submodule', 'module-path-index?', 'module-path?',
933        'module-predefined?', 'module-provide-protected?', 'modulo', 'mpair?',
934        'mutable-set', 'mutable-seteq', 'mutable-seteqv', 'n->th',
935        'nack-guard-evt', 'namespace-anchor->empty-namespace',
936        'namespace-anchor->namespace', 'namespace-anchor?',
937        'namespace-attach-module', 'namespace-attach-module-declaration',
938        'namespace-base-phase', 'namespace-mapped-symbols',
939        'namespace-module-identifier', 'namespace-module-registry',
940        'namespace-require', 'namespace-require/constant',
941        'namespace-require/copy', 'namespace-require/expansion-time',
942        'namespace-set-variable-value!', 'namespace-symbol->identifier',
943        'namespace-syntax-introduce', 'namespace-undefine-variable!',
944        'namespace-unprotect-module', 'namespace-variable-value', 'namespace?',
945        'nan?', 'natural-number/c', 'negate', 'negative?', 'never-evt',
946        'new-∀/c', 'new-∃/c', 'newline', 'ninth', 'non-empty-listof',
947        'non-empty-string?', 'none/c', 'normal-case-path', 'normalize-arity',
948        'normalize-path', 'normalized-arity?', 'not', 'not/c', 'null', 'null?',
949        'number->string', 'number?', 'numerator', 'object%', 'object->vector',
950        'object-info', 'object-interface', 'object-method-arity-includes?',
951        'object-name', 'object-or-false=?', 'object=?', 'object?', 'odd?',
952        'one-of/c', 'open-input-bytes', 'open-input-file',
953        'open-input-output-file', 'open-input-string', 'open-output-bytes',
954        'open-output-file', 'open-output-nowhere', 'open-output-string',
955        'or/c', 'order-of-magnitude', 'ormap', 'other-execute-bit',
956        'other-read-bit', 'other-write-bit', 'output-port?', 'pair?',
957        'parameter-procedure=?', 'parameter/c', 'parameter?',
958        'parameterization?', 'parse-command-line', 'partition', 'path->bytes',
959        'path->complete-path', 'path->directory-path', 'path->string',
960        'path-add-suffix', 'path-convention-type', 'path-element->bytes',
961        'path-element->string', 'path-element?', 'path-for-some-system?',
962        'path-list-string->path-list', 'path-only', 'path-replace-suffix',
963        'path-string?', 'path<?', 'path?', 'pathlist-closure', 'peek-byte',
964        'peek-byte-or-special', 'peek-bytes', 'peek-bytes!', 'peek-bytes!-evt',
965        'peek-bytes-avail!', 'peek-bytes-avail!*', 'peek-bytes-avail!-evt',
966        'peek-bytes-avail!/enable-break', 'peek-bytes-evt', 'peek-char',
967        'peek-char-or-special', 'peek-string', 'peek-string!',
968        'peek-string!-evt', 'peek-string-evt', 'peeking-input-port',
969        'permutations', 'phantom-bytes?', 'pi', 'pi.f', 'pipe-content-length',
970        'place-break', 'place-channel', 'place-channel-get',
971        'place-channel-put', 'place-channel-put/get', 'place-channel?',
972        'place-dead-evt', 'place-enabled?', 'place-kill', 'place-location?',
973        'place-message-allowed?', 'place-sleep', 'place-wait', 'place?',
974        'placeholder-get', 'placeholder-set!', 'placeholder?',
975        'plumber-add-flush!', 'plumber-flush-all',
976        'plumber-flush-handle-remove!', 'plumber-flush-handle?', 'plumber?',
977        'poll-guard-evt', 'port->bytes', 'port->bytes-lines', 'port->lines',
978        'port->list', 'port->string', 'port-closed-evt', 'port-closed?',
979        'port-commit-peeked', 'port-count-lines!', 'port-count-lines-enabled',
980        'port-counts-lines?', 'port-display-handler', 'port-file-identity',
981        'port-file-unlock', 'port-next-location', 'port-number?',
982        'port-print-handler', 'port-progress-evt',
983        'port-provides-progress-evts?', 'port-read-handler',
984        'port-try-file-lock?', 'port-write-handler', 'port-writes-atomic?',
985        'port-writes-special?', 'port?', 'positive?', 'predicate/c',
986        'prefab-key->struct-type', 'prefab-key?', 'prefab-struct-key',
987        'preferences-lock-file-mode', 'pregexp', 'pregexp?', 'pretty-display',
988        'pretty-format', 'pretty-print', 'pretty-print-.-symbol-without-bars',
989        'pretty-print-abbreviate-read-macros', 'pretty-print-columns',
990        'pretty-print-current-style-table', 'pretty-print-depth',
991        'pretty-print-exact-as-decimal', 'pretty-print-extend-style-table',
992        'pretty-print-handler', 'pretty-print-newline',
993        'pretty-print-post-print-hook', 'pretty-print-pre-print-hook',
994        'pretty-print-print-hook', 'pretty-print-print-line',
995        'pretty-print-remap-stylable', 'pretty-print-show-inexactness',
996        'pretty-print-size-hook', 'pretty-print-style-table?',
997        'pretty-printing', 'pretty-write', 'primitive-closure?',
998        'primitive-result-arity', 'primitive?', 'print', 'print-as-expression',
999        'print-boolean-long-form', 'print-box', 'print-graph',
1000        'print-hash-table', 'print-mpair-curly-braces',
1001        'print-pair-curly-braces', 'print-reader-abbreviations',
1002        'print-struct', 'print-syntax-width', 'print-unreadable',
1003        'print-vector-length', 'printable/c', 'printable<%>', 'printf',
1004        'println', 'procedure->method', 'procedure-arity',
1005        'procedure-arity-includes/c', 'procedure-arity-includes?',
1006        'procedure-arity?', 'procedure-closure-contents-eq?',
1007        'procedure-extract-target', 'procedure-keywords',
1008        'procedure-reduce-arity', 'procedure-reduce-keyword-arity',
1009        'procedure-rename', 'procedure-result-arity', 'procedure-specialize',
1010        'procedure-struct-type?', 'procedure?', 'process', 'process*',
1011        'process*/ports', 'process/ports', 'processor-count', 'progress-evt?',
1012        'promise-forced?', 'promise-running?', 'promise/c', 'promise/name?',
1013        'promise?', 'prop:arity-string', 'prop:arrow-contract',
1014        'prop:arrow-contract-get-info', 'prop:arrow-contract?', 'prop:blame',
1015        'prop:chaperone-contract', 'prop:checked-procedure', 'prop:contract',
1016        'prop:contracted', 'prop:custom-print-quotable', 'prop:custom-write',
1017        'prop:dict', 'prop:dict/contract', 'prop:equal+hash', 'prop:evt',
1018        'prop:exn:missing-module', 'prop:exn:srclocs',
1019        'prop:expansion-contexts', 'prop:flat-contract',
1020        'prop:impersonator-of', 'prop:input-port',
1021        'prop:liberal-define-context', 'prop:object-name',
1022        'prop:opt-chaperone-contract', 'prop:opt-chaperone-contract-get-test',
1023        'prop:opt-chaperone-contract?', 'prop:orc-contract',
1024        'prop:orc-contract-get-subcontracts', 'prop:orc-contract?',
1025        'prop:output-port', 'prop:place-location', 'prop:procedure',
1026        'prop:recursive-contract', 'prop:recursive-contract-unroll',
1027        'prop:recursive-contract?', 'prop:rename-transformer', 'prop:sequence',
1028        'prop:set!-transformer', 'prop:stream', 'proper-subset?',
1029        'pseudo-random-generator->vector', 'pseudo-random-generator-vector?',
1030        'pseudo-random-generator?', 'put-preferences', 'putenv', 'quotient',
1031        'quotient/remainder', 'radians->degrees', 'raise',
1032        'raise-argument-error', 'raise-arguments-error', 'raise-arity-error',
1033        'raise-blame-error', 'raise-contract-error', 'raise-mismatch-error',
1034        'raise-not-cons-blame-error', 'raise-range-error',
1035        'raise-result-error', 'raise-syntax-error', 'raise-type-error',
1036        'raise-user-error', 'random', 'random-seed', 'range', 'rational?',
1037        'rationalize', 'read', 'read-accept-bar-quote', 'read-accept-box',
1038        'read-accept-compiled', 'read-accept-dot', 'read-accept-graph',
1039        'read-accept-infix-dot', 'read-accept-lang', 'read-accept-quasiquote',
1040        'read-accept-reader', 'read-byte', 'read-byte-or-special',
1041        'read-bytes', 'read-bytes!', 'read-bytes!-evt', 'read-bytes-avail!',
1042        'read-bytes-avail!*', 'read-bytes-avail!-evt',
1043        'read-bytes-avail!/enable-break', 'read-bytes-evt', 'read-bytes-line',
1044        'read-bytes-line-evt', 'read-case-sensitive', 'read-cdot', 'read-char',
1045        'read-char-or-special', 'read-curly-brace-as-paren',
1046        'read-curly-brace-with-tag', 'read-decimal-as-inexact',
1047        'read-eval-print-loop', 'read-language', 'read-line', 'read-line-evt',
1048        'read-on-demand-source', 'read-square-bracket-as-paren',
1049        'read-square-bracket-with-tag', 'read-string', 'read-string!',
1050        'read-string!-evt', 'read-string-evt', 'read-syntax',
1051        'read-syntax/recursive', 'read/recursive', 'readtable-mapping',
1052        'readtable?', 'real->decimal-string', 'real->double-flonum',
1053        'real->floating-point-bytes', 'real->single-flonum', 'real-in',
1054        'real-part', 'real?', 'reencode-input-port', 'reencode-output-port',
1055        'regexp', 'regexp-match', 'regexp-match*', 'regexp-match-evt',
1056        'regexp-match-exact?', 'regexp-match-peek',
1057        'regexp-match-peek-immediate', 'regexp-match-peek-positions',
1058        'regexp-match-peek-positions*',
1059        'regexp-match-peek-positions-immediate',
1060        'regexp-match-peek-positions-immediate/end',
1061        'regexp-match-peek-positions/end', 'regexp-match-positions',
1062        'regexp-match-positions*', 'regexp-match-positions/end',
1063        'regexp-match/end', 'regexp-match?', 'regexp-max-lookbehind',
1064        'regexp-quote', 'regexp-replace', 'regexp-replace*',
1065        'regexp-replace-quote', 'regexp-replaces', 'regexp-split',
1066        'regexp-try-match', 'regexp?', 'relative-path?', 'relocate-input-port',
1067        'relocate-output-port', 'remainder', 'remf', 'remf*', 'remove',
1068        'remove*', 'remove-duplicates', 'remq', 'remq*', 'remv', 'remv*',
1069        'rename-contract', 'rename-file-or-directory',
1070        'rename-transformer-target', 'rename-transformer?', 'replace-evt',
1071        'reroot-path', 'resolve-path', 'resolved-module-path-name',
1072        'resolved-module-path?', 'rest', 'reverse', 'round', 'second',
1073        'seconds->date', 'security-guard?', 'semaphore-peek-evt',
1074        'semaphore-peek-evt?', 'semaphore-post', 'semaphore-try-wait?',
1075        'semaphore-wait', 'semaphore-wait/enable-break', 'semaphore?',
1076        'sequence->list', 'sequence->stream', 'sequence-add-between',
1077        'sequence-andmap', 'sequence-append', 'sequence-count',
1078        'sequence-filter', 'sequence-fold', 'sequence-for-each',
1079        'sequence-generate', 'sequence-generate*', 'sequence-length',
1080        'sequence-map', 'sequence-ormap', 'sequence-ref', 'sequence-tail',
1081        'sequence/c', 'sequence?', 'set', 'set!-transformer-procedure',
1082        'set!-transformer?', 'set->list', 'set->stream', 'set-add', 'set-add!',
1083        'set-box!', 'set-clear', 'set-clear!', 'set-copy', 'set-copy-clear',
1084        'set-count', 'set-empty?', 'set-eq?', 'set-equal?', 'set-eqv?',
1085        'set-first', 'set-for-each', 'set-implements/c', 'set-implements?',
1086        'set-intersect', 'set-intersect!', 'set-map', 'set-mcar!', 'set-mcdr!',
1087        'set-member?', 'set-mutable?', 'set-phantom-bytes!',
1088        'set-port-next-location!', 'set-remove', 'set-remove!', 'set-rest',
1089        'set-some-basic-contracts!', 'set-subtract', 'set-subtract!',
1090        'set-symmetric-difference', 'set-symmetric-difference!', 'set-union',
1091        'set-union!', 'set-weak?', 'set/c', 'set=?', 'set?', 'seteq', 'seteqv',
1092        'seventh', 'sgn', 'shared-bytes', 'shell-execute', 'shrink-path-wrt',
1093        'shuffle', 'simple-form-path', 'simplify-path', 'sin',
1094        'single-flonum?', 'sinh', 'sixth', 'skip-projection-wrapper?', 'sleep',
1095        'some-system-path->string', 'sort', 'special-comment-value',
1096        'special-comment?', 'special-filter-input-port', 'split-at',
1097        'split-at-right', 'split-common-prefix', 'split-path', 'splitf-at',
1098        'splitf-at-right', 'sqr', 'sqrt', 'srcloc', 'srcloc->string',
1099        'srcloc-column', 'srcloc-line', 'srcloc-position', 'srcloc-source',
1100        'srcloc-span', 'srcloc?', 'stop-after', 'stop-before', 'stream->list',
1101        'stream-add-between', 'stream-andmap', 'stream-append', 'stream-count',
1102        'stream-empty?', 'stream-filter', 'stream-first', 'stream-fold',
1103        'stream-for-each', 'stream-length', 'stream-map', 'stream-ormap',
1104        'stream-ref', 'stream-rest', 'stream-tail', 'stream/c', 'stream?',
1105        'string', 'string->bytes/latin-1', 'string->bytes/locale',
1106        'string->bytes/utf-8', 'string->immutable-string', 'string->keyword',
1107        'string->list', 'string->number', 'string->path',
1108        'string->path-element', 'string->some-system-path', 'string->symbol',
1109        'string->uninterned-symbol', 'string->unreadable-symbol',
1110        'string-append', 'string-append*', 'string-ci<=?', 'string-ci<?',
1111        'string-ci=?', 'string-ci>=?', 'string-ci>?', 'string-contains?',
1112        'string-copy', 'string-copy!', 'string-downcase',
1113        'string-environment-variable-name?', 'string-fill!', 'string-foldcase',
1114        'string-join', 'string-len/c', 'string-length', 'string-locale-ci<?',
1115        'string-locale-ci=?', 'string-locale-ci>?', 'string-locale-downcase',
1116        'string-locale-upcase', 'string-locale<?', 'string-locale=?',
1117        'string-locale>?', 'string-no-nuls?', 'string-normalize-nfc',
1118        'string-normalize-nfd', 'string-normalize-nfkc',
1119        'string-normalize-nfkd', 'string-normalize-spaces', 'string-port?',
1120        'string-prefix?', 'string-ref', 'string-replace', 'string-set!',
1121        'string-split', 'string-suffix?', 'string-titlecase', 'string-trim',
1122        'string-upcase', 'string-utf-8-length', 'string<=?', 'string<?',
1123        'string=?', 'string>=?', 'string>?', 'string?', 'struct->vector',
1124        'struct-accessor-procedure?', 'struct-constructor-procedure?',
1125        'struct-info', 'struct-mutator-procedure?',
1126        'struct-predicate-procedure?', 'struct-type-info',
1127        'struct-type-make-constructor', 'struct-type-make-predicate',
1128        'struct-type-property-accessor-procedure?', 'struct-type-property/c',
1129        'struct-type-property?', 'struct-type?', 'struct:arity-at-least',
1130        'struct:arrow-contract-info', 'struct:date', 'struct:date*',
1131        'struct:exn', 'struct:exn:break', 'struct:exn:break:hang-up',
1132        'struct:exn:break:terminate', 'struct:exn:fail',
1133        'struct:exn:fail:contract', 'struct:exn:fail:contract:arity',
1134        'struct:exn:fail:contract:blame',
1135        'struct:exn:fail:contract:continuation',
1136        'struct:exn:fail:contract:divide-by-zero',
1137        'struct:exn:fail:contract:non-fixnum-result',
1138        'struct:exn:fail:contract:variable', 'struct:exn:fail:filesystem',
1139        'struct:exn:fail:filesystem:errno',
1140        'struct:exn:fail:filesystem:exists',
1141        'struct:exn:fail:filesystem:missing-module',
1142        'struct:exn:fail:filesystem:version', 'struct:exn:fail:network',
1143        'struct:exn:fail:network:errno', 'struct:exn:fail:object',
1144        'struct:exn:fail:out-of-memory', 'struct:exn:fail:read',
1145        'struct:exn:fail:read:eof', 'struct:exn:fail:read:non-char',
1146        'struct:exn:fail:syntax', 'struct:exn:fail:syntax:missing-module',
1147        'struct:exn:fail:syntax:unbound', 'struct:exn:fail:unsupported',
1148        'struct:exn:fail:user', 'struct:srcloc',
1149        'struct:wrapped-extra-arg-arrow', 'struct?', 'sub1', 'subbytes',
1150        'subclass?', 'subclass?/c', 'subprocess', 'subprocess-group-enabled',
1151        'subprocess-kill', 'subprocess-pid', 'subprocess-status',
1152        'subprocess-wait', 'subprocess?', 'subset?', 'substring', 'suggest/c',
1153        'symbol->string', 'symbol-interned?', 'symbol-unreadable?', 'symbol<?',
1154        'symbol=?', 'symbol?', 'symbols', 'sync', 'sync/enable-break',
1155        'sync/timeout', 'sync/timeout/enable-break', 'syntax->datum',
1156        'syntax->list', 'syntax-arm', 'syntax-column', 'syntax-debug-info',
1157        'syntax-disarm', 'syntax-e', 'syntax-line',
1158        'syntax-local-bind-syntaxes', 'syntax-local-certifier',
1159        'syntax-local-context', 'syntax-local-expand-expression',
1160        'syntax-local-get-shadower', 'syntax-local-identifier-as-binding',
1161        'syntax-local-introduce', 'syntax-local-lift-context',
1162        'syntax-local-lift-expression', 'syntax-local-lift-module',
1163        'syntax-local-lift-module-end-declaration',
1164        'syntax-local-lift-provide', 'syntax-local-lift-require',
1165        'syntax-local-lift-values-expression',
1166        'syntax-local-make-definition-context',
1167        'syntax-local-make-delta-introducer',
1168        'syntax-local-module-defined-identifiers',
1169        'syntax-local-module-exports',
1170        'syntax-local-module-required-identifiers', 'syntax-local-name',
1171        'syntax-local-phase-level', 'syntax-local-submodules',
1172        'syntax-local-transforming-module-provides?', 'syntax-local-value',
1173        'syntax-local-value/immediate', 'syntax-original?', 'syntax-position',
1174        'syntax-property', 'syntax-property-preserved?',
1175        'syntax-property-symbol-keys', 'syntax-protect', 'syntax-rearm',
1176        'syntax-recertify', 'syntax-shift-phase-level', 'syntax-source',
1177        'syntax-source-module', 'syntax-span', 'syntax-taint',
1178        'syntax-tainted?', 'syntax-track-origin',
1179        'syntax-transforming-module-expression?',
1180        'syntax-transforming-with-lifts?', 'syntax-transforming?', 'syntax/c',
1181        'syntax?', 'system', 'system*', 'system*/exit-code',
1182        'system-big-endian?', 'system-idle-evt', 'system-language+country',
1183        'system-library-subpath', 'system-path-convention-type', 'system-type',
1184        'system/exit-code', 'tail-marks-match?', 'take', 'take-common-prefix',
1185        'take-right', 'takef', 'takef-right', 'tan', 'tanh',
1186        'tcp-abandon-port', 'tcp-accept', 'tcp-accept-evt',
1187        'tcp-accept-ready?', 'tcp-accept/enable-break', 'tcp-addresses',
1188        'tcp-close', 'tcp-connect', 'tcp-connect/enable-break', 'tcp-listen',
1189        'tcp-listener?', 'tcp-port?', 'tentative-pretty-print-port-cancel',
1190        'tentative-pretty-print-port-transfer', 'tenth', 'terminal-port?',
1191        'the-unsupplied-arg', 'third', 'thread', 'thread-cell-ref',
1192        'thread-cell-set!', 'thread-cell-values?', 'thread-cell?',
1193        'thread-dead-evt', 'thread-dead?', 'thread-group?', 'thread-receive',
1194        'thread-receive-evt', 'thread-resume', 'thread-resume-evt',
1195        'thread-rewind-receive', 'thread-running?', 'thread-send',
1196        'thread-suspend', 'thread-suspend-evt', 'thread-try-receive',
1197        'thread-wait', 'thread/suspend-to-kill', 'thread?', 'time-apply',
1198        'touch', 'transplant-input-port', 'transplant-output-port', 'true',
1199        'truncate', 'udp-addresses', 'udp-bind!', 'udp-bound?', 'udp-close',
1200        'udp-connect!', 'udp-connected?', 'udp-multicast-interface',
1201        'udp-multicast-join-group!', 'udp-multicast-leave-group!',
1202        'udp-multicast-loopback?', 'udp-multicast-set-interface!',
1203        'udp-multicast-set-loopback!', 'udp-multicast-set-ttl!',
1204        'udp-multicast-ttl', 'udp-open-socket', 'udp-receive!',
1205        'udp-receive!*', 'udp-receive!-evt', 'udp-receive!/enable-break',
1206        'udp-receive-ready-evt', 'udp-send', 'udp-send*', 'udp-send-evt',
1207        'udp-send-ready-evt', 'udp-send-to', 'udp-send-to*', 'udp-send-to-evt',
1208        'udp-send-to/enable-break', 'udp-send/enable-break', 'udp?', 'unbox',
1209        'uncaught-exception-handler', 'unit?', 'unspecified-dom',
1210        'unsupplied-arg?', 'use-collection-link-paths',
1211        'use-compiled-file-paths', 'use-user-specific-search-paths',
1212        'user-execute-bit', 'user-read-bit', 'user-write-bit', 'value-blame',
1213        'value-contract', 'values', 'variable-reference->empty-namespace',
1214        'variable-reference->module-base-phase',
1215        'variable-reference->module-declaration-inspector',
1216        'variable-reference->module-path-index',
1217        'variable-reference->module-source', 'variable-reference->namespace',
1218        'variable-reference->phase',
1219        'variable-reference->resolved-module-path',
1220        'variable-reference-constant?', 'variable-reference?', 'vector',
1221        'vector->immutable-vector', 'vector->list',
1222        'vector->pseudo-random-generator', 'vector->pseudo-random-generator!',
1223        'vector->values', 'vector-append', 'vector-argmax', 'vector-argmin',
1224        'vector-copy', 'vector-copy!', 'vector-count', 'vector-drop',
1225        'vector-drop-right', 'vector-fill!', 'vector-filter',
1226        'vector-filter-not', 'vector-immutable', 'vector-immutable/c',
1227        'vector-immutableof', 'vector-length', 'vector-map', 'vector-map!',
1228        'vector-member', 'vector-memq', 'vector-memv', 'vector-ref',
1229        'vector-set!', 'vector-set*!', 'vector-set-performance-stats!',
1230        'vector-split-at', 'vector-split-at-right', 'vector-take',
1231        'vector-take-right', 'vector/c', 'vector?', 'vectorof', 'version',
1232        'void', 'void?', 'weak-box-value', 'weak-box?', 'weak-set',
1233        'weak-seteq', 'weak-seteqv', 'will-execute', 'will-executor?',
1234        'will-register', 'will-try-execute', 'with-input-from-bytes',
1235        'with-input-from-file', 'with-input-from-string',
1236        'with-output-to-bytes', 'with-output-to-file', 'with-output-to-string',
1237        'would-be-future', 'wrap-evt', 'wrapped-extra-arg-arrow',
1238        'wrapped-extra-arg-arrow-extra-neg-party-argument',
1239        'wrapped-extra-arg-arrow-real-func', 'wrapped-extra-arg-arrow?',
1240        'writable<%>', 'write', 'write-byte', 'write-bytes',
1241        'write-bytes-avail', 'write-bytes-avail*', 'write-bytes-avail-evt',
1242        'write-bytes-avail/enable-break', 'write-char', 'write-special',
1243        'write-special-avail*', 'write-special-evt', 'write-string',
1244        'write-to-file', 'writeln', 'xor', 'zero?', '~.a', '~.s', '~.v', '~a',
1245        '~e', '~r', '~s', '~v'
1246    )
1247
1248    _opening_parenthesis = r'[([{]'
1249    _closing_parenthesis = r'[)\]}]'
1250    _delimiters = r'()[\]{}",\'`;\s'
1251    _symbol = r'(?:\|[^|]*\||\\[\w\W]|[^|\\%s]+)+' % _delimiters
1252    _exact_decimal_prefix = r'(?:#e)?(?:#d)?(?:#e)?'
1253    _exponent = r'(?:[defls][-+]?\d+)'
1254    _inexact_simple_no_hashes = r'(?:\d+(?:/\d+|\.\d*)?|\.\d+)'
1255    _inexact_simple = (r'(?:%s|(?:\d+#+(?:\.#*|/\d+#*)?|\.\d+#+|'
1256                       r'\d+(?:\.\d*#+|/\d+#+)))' % _inexact_simple_no_hashes)
1257    _inexact_normal_no_hashes = r'(?:%s%s?)' % (_inexact_simple_no_hashes,
1258                                                _exponent)
1259    _inexact_normal = r'(?:%s%s?)' % (_inexact_simple, _exponent)
1260    _inexact_special = r'(?:(?:inf|nan)\.[0f])'
1261    _inexact_real = r'(?:[-+]?%s|[-+]%s)' % (_inexact_normal,
1262                                             _inexact_special)
1263    _inexact_unsigned = r'(?:%s|%s)' % (_inexact_normal, _inexact_special)
1264
1265    tokens = {
1266        'root': [
1267            (_closing_parenthesis, Error),
1268            (r'(?!\Z)', Text, 'unquoted-datum')
1269        ],
1270        'datum': [
1271            (r'(?s)#;|#![ /]([^\\\n]|\\.)*', Comment),
1272            (r';[^\n\r\x85\u2028\u2029]*', Comment.Single),
1273            (r'#\|', Comment.Multiline, 'block-comment'),
1274
1275            # Whitespaces
1276            (r'(?u)\s+', Text),
1277
1278            # Numbers: Keep in mind Racket reader hash prefixes, which
1279            # can denote the base or the type. These don't map neatly
1280            # onto Pygments token types; some judgment calls here.
1281
1282            # #d or no prefix
1283            (r'(?i)%s[-+]?\d+(?=[%s])' % (_exact_decimal_prefix, _delimiters),
1284             Number.Integer, '#pop'),
1285            (r'(?i)%s[-+]?(\d+(\.\d*)?|\.\d+)([deflst][-+]?\d+)?(?=[%s])' %
1286             (_exact_decimal_prefix, _delimiters), Number.Float, '#pop'),
1287            (r'(?i)%s[-+]?(%s([-+]%s?i)?|[-+]%s?i)(?=[%s])' %
1288             (_exact_decimal_prefix, _inexact_normal_no_hashes,
1289              _inexact_normal_no_hashes, _inexact_normal_no_hashes,
1290              _delimiters), Number, '#pop'),
1291
1292            # Inexact without explicit #i
1293            (r'(?i)(#d)?(%s([-+]%s?i)?|[-+]%s?i|%s@%s)(?=[%s])' %
1294             (_inexact_real, _inexact_unsigned, _inexact_unsigned,
1295              _inexact_real, _inexact_real, _delimiters), Number.Float,
1296             '#pop'),
1297
1298            # The remaining extflonums
1299            (r'(?i)(([-+]?%st[-+]?\d+)|[-+](inf|nan)\.t)(?=[%s])' %
1300             (_inexact_simple, _delimiters), Number.Float, '#pop'),
1301
1302            # #b
1303            (r'(?iu)(#[ei])?#b%s' % _symbol, Number.Bin, '#pop'),
1304
1305            # #o
1306            (r'(?iu)(#[ei])?#o%s' % _symbol, Number.Oct, '#pop'),
1307
1308            # #x
1309            (r'(?iu)(#[ei])?#x%s' % _symbol, Number.Hex, '#pop'),
1310
1311            # #i is always inexact, i.e. float
1312            (r'(?iu)(#d)?#i%s' % _symbol, Number.Float, '#pop'),
1313
1314            # Strings and characters
1315            (r'#?"', String.Double, ('#pop', 'string')),
1316            (r'#<<(.+)\n(^(?!\1$).*$\n)*^\1$', String.Heredoc, '#pop'),
1317            (r'#\\(u[\da-fA-F]{1,4}|U[\da-fA-F]{1,8})', String.Char, '#pop'),
1318            (r'(?is)#\\([0-7]{3}|[a-z]+|.)', String.Char, '#pop'),
1319            (r'(?s)#[pr]x#?"(\\?.)*?"', String.Regex, '#pop'),
1320
1321            # Constants
1322            (r'#(true|false|[tTfF])', Name.Constant, '#pop'),
1323
1324            # Keyword argument names (e.g. #:keyword)
1325            (r'(?u)#:%s' % _symbol, Keyword.Declaration, '#pop'),
1326
1327            # Reader extensions
1328            (r'(#lang |#!)(\S+)',
1329             bygroups(Keyword.Namespace, Name.Namespace)),
1330            (r'#reader', Keyword.Namespace, 'quoted-datum'),
1331
1332            # Other syntax
1333            (r"(?i)\.(?=[%s])|#c[is]|#['`]|#,@?" % _delimiters, Operator),
1334            (r"'|#[s&]|#hash(eqv?)?|#\d*(?=%s)" % _opening_parenthesis,
1335             Operator, ('#pop', 'quoted-datum'))
1336        ],
1337        'datum*': [
1338            (r'`|,@?', Operator),
1339            (_symbol, String.Symbol, '#pop'),
1340            (r'[|\\]', Error),
1341            default('#pop')
1342        ],
1343        'list': [
1344            (_closing_parenthesis, Punctuation, '#pop')
1345        ],
1346        'unquoted-datum': [
1347            include('datum'),
1348            (r'quote(?=[%s])' % _delimiters, Keyword,
1349             ('#pop', 'quoted-datum')),
1350            (r'`', Operator, ('#pop', 'quasiquoted-datum')),
1351            (r'quasiquote(?=[%s])' % _delimiters, Keyword,
1352             ('#pop', 'quasiquoted-datum')),
1353            (_opening_parenthesis, Punctuation, ('#pop', 'unquoted-list')),
1354            (words(_keywords, prefix='(?u)', suffix='(?=[%s])' % _delimiters),
1355             Keyword, '#pop'),
1356            (words(_builtins, prefix='(?u)', suffix='(?=[%s])' % _delimiters),
1357             Name.Builtin, '#pop'),
1358            (_symbol, Name, '#pop'),
1359            include('datum*')
1360        ],
1361        'unquoted-list': [
1362            include('list'),
1363            (r'(?!\Z)', Text, 'unquoted-datum')
1364        ],
1365        'quasiquoted-datum': [
1366            include('datum'),
1367            (r',@?', Operator, ('#pop', 'unquoted-datum')),
1368            (r'unquote(-splicing)?(?=[%s])' % _delimiters, Keyword,
1369             ('#pop', 'unquoted-datum')),
1370            (_opening_parenthesis, Punctuation, ('#pop', 'quasiquoted-list')),
1371            include('datum*')
1372        ],
1373        'quasiquoted-list': [
1374            include('list'),
1375            (r'(?!\Z)', Text, 'quasiquoted-datum')
1376        ],
1377        'quoted-datum': [
1378            include('datum'),
1379            (_opening_parenthesis, Punctuation, ('#pop', 'quoted-list')),
1380            include('datum*')
1381        ],
1382        'quoted-list': [
1383            include('list'),
1384            (r'(?!\Z)', Text, 'quoted-datum')
1385        ],
1386        'block-comment': [
1387            (r'#\|', Comment.Multiline, '#push'),
1388            (r'\|#', Comment.Multiline, '#pop'),
1389            (r'[^#|]+|.', Comment.Multiline)
1390        ],
1391        'string': [
1392            (r'"', String.Double, '#pop'),
1393            (r'(?s)\\([0-7]{1,3}|x[\da-fA-F]{1,2}|u[\da-fA-F]{1,4}|'
1394             r'U[\da-fA-F]{1,8}|.)', String.Escape),
1395            (r'[^\\"]+', String.Double)
1396        ]
1397    }
1398
1399
1400class NewLispLexer(RegexLexer):
1401    """
1402    For `newLISP. <http://www.newlisp.org/>`_ source code (version 10.3.0).
1403
1404    .. versionadded:: 1.5
1405    """
1406
1407    name = 'NewLisp'
1408    aliases = ['newlisp']
1409    filenames = ['*.lsp', '*.nl', '*.kif']
1410    mimetypes = ['text/x-newlisp', 'application/x-newlisp']
1411
1412    flags = re.IGNORECASE | re.MULTILINE | re.UNICODE
1413
1414    # list of built-in functions for newLISP version 10.3
1415    builtins = (
1416        '^', '--', '-', ':', '!', '!=', '?', '@', '*', '/', '&', '%', '+', '++',
1417        '<', '<<', '<=', '=', '>', '>=', '>>', '|', '~', '$', '$0', '$1', '$10',
1418        '$11', '$12', '$13', '$14', '$15', '$2', '$3', '$4', '$5', '$6', '$7',
1419        '$8', '$9', '$args', '$idx', '$it', '$main-args', 'abort', 'abs',
1420        'acos', 'acosh', 'add', 'address', 'amb', 'and',  'append-file',
1421        'append', 'apply', 'args', 'array-list', 'array?', 'array', 'asin',
1422        'asinh', 'assoc', 'atan', 'atan2', 'atanh', 'atom?', 'base64-dec',
1423        'base64-enc', 'bayes-query', 'bayes-train', 'begin',
1424        'beta', 'betai', 'bind', 'binomial', 'bits', 'callback',
1425        'case', 'catch', 'ceil', 'change-dir', 'char', 'chop', 'Class', 'clean',
1426        'close', 'command-event', 'cond', 'cons', 'constant',
1427        'context?', 'context', 'copy-file', 'copy', 'cos', 'cosh', 'count',
1428        'cpymem', 'crc32', 'crit-chi2', 'crit-z', 'current-line', 'curry',
1429        'date-list', 'date-parse', 'date-value', 'date', 'debug', 'dec',
1430        'def-new', 'default', 'define-macro', 'define',
1431        'delete-file', 'delete-url', 'delete', 'destroy', 'det', 'device',
1432        'difference', 'directory?', 'directory', 'div', 'do-until', 'do-while',
1433        'doargs',  'dolist',  'dostring', 'dotimes',  'dotree', 'dump', 'dup',
1434        'empty?', 'encrypt', 'ends-with', 'env', 'erf', 'error-event',
1435        'eval-string', 'eval', 'exec', 'exists', 'exit', 'exp', 'expand',
1436        'explode', 'extend', 'factor', 'fft', 'file-info', 'file?', 'filter',
1437        'find-all', 'find', 'first', 'flat', 'float?', 'float', 'floor', 'flt',
1438        'fn', 'for-all', 'for', 'fork', 'format', 'fv', 'gammai', 'gammaln',
1439        'gcd', 'get-char', 'get-float', 'get-int', 'get-long', 'get-string',
1440        'get-url', 'global?', 'global', 'if-not', 'if', 'ifft', 'import', 'inc',
1441        'index', 'inf?', 'int', 'integer?', 'integer', 'intersect', 'invert',
1442        'irr', 'join', 'lambda-macro', 'lambda?', 'lambda', 'last-error',
1443        'last', 'legal?', 'length', 'let', 'letex', 'letn',
1444        'list?', 'list', 'load', 'local', 'log', 'lookup',
1445        'lower-case', 'macro?', 'main-args', 'MAIN', 'make-dir', 'map', 'mat',
1446        'match', 'max', 'member', 'min', 'mod', 'module', 'mul', 'multiply',
1447        'NaN?', 'net-accept', 'net-close', 'net-connect', 'net-error',
1448        'net-eval', 'net-interface', 'net-ipv', 'net-listen', 'net-local',
1449        'net-lookup', 'net-packet', 'net-peek', 'net-peer', 'net-ping',
1450        'net-receive-from', 'net-receive-udp', 'net-receive', 'net-select',
1451        'net-send-to', 'net-send-udp', 'net-send', 'net-service',
1452        'net-sessions', 'new', 'nil?', 'nil', 'normal', 'not', 'now', 'nper',
1453        'npv', 'nth', 'null?', 'number?', 'open', 'or', 'ostype', 'pack',
1454        'parse-date', 'parse', 'peek', 'pipe', 'pmt', 'pop-assoc', 'pop',
1455        'post-url', 'pow', 'prefix', 'pretty-print', 'primitive?', 'print',
1456        'println', 'prob-chi2', 'prob-z', 'process', 'prompt-event',
1457        'protected?', 'push', 'put-url', 'pv', 'quote?', 'quote', 'rand',
1458        'random', 'randomize', 'read', 'read-char', 'read-expr', 'read-file',
1459        'read-key', 'read-line', 'read-utf8', 'reader-event',
1460        'real-path', 'receive', 'ref-all', 'ref', 'regex-comp', 'regex',
1461        'remove-dir', 'rename-file', 'replace', 'reset', 'rest', 'reverse',
1462        'rotate', 'round', 'save', 'search', 'seed', 'seek', 'select', 'self',
1463        'semaphore', 'send', 'sequence', 'series', 'set-locale', 'set-ref-all',
1464        'set-ref', 'set', 'setf',  'setq', 'sgn', 'share', 'signal', 'silent',
1465        'sin', 'sinh', 'sleep', 'slice', 'sort', 'source', 'spawn', 'sqrt',
1466        'starts-with', 'string?', 'string', 'sub', 'swap', 'sym', 'symbol?',
1467        'symbols', 'sync', 'sys-error', 'sys-info', 'tan', 'tanh', 'term',
1468        'throw-error', 'throw', 'time-of-day', 'time', 'timer', 'title-case',
1469        'trace-highlight', 'trace', 'transpose', 'Tree', 'trim', 'true?',
1470        'true', 'unicode', 'unify', 'unique', 'unless', 'unpack', 'until',
1471        'upper-case', 'utf8', 'utf8len', 'uuid', 'wait-pid', 'when', 'while',
1472        'write', 'write-char', 'write-file', 'write-line',
1473        'xfer-event', 'xml-error', 'xml-parse', 'xml-type-tags', 'zero?',
1474    )
1475
1476    # valid names
1477    valid_name = r'([\w!$%&*+.,/<=>?@^~|-])+|(\[.*?\])+'
1478
1479    tokens = {
1480        'root': [
1481            # shebang
1482            (r'#!(.*?)$', Comment.Preproc),
1483            # comments starting with semicolon
1484            (r';.*$', Comment.Single),
1485            # comments starting with #
1486            (r'#.*$', Comment.Single),
1487
1488            # whitespace
1489            (r'\s+', Text),
1490
1491            # strings, symbols and characters
1492            (r'"(\\\\|\\[^\\]|[^"\\])*"', String),
1493
1494            # braces
1495            (r'\{', String, "bracestring"),
1496
1497            # [text] ... [/text] delimited strings
1498            (r'\[text\]*', String, "tagstring"),
1499
1500            # 'special' operators...
1501            (r"('|:)", Operator),
1502
1503            # highlight the builtins
1504            (words(builtins, suffix=r'\b'),
1505             Keyword),
1506
1507            # the remaining functions
1508            (r'(?<=\()' + valid_name, Name.Variable),
1509
1510            # the remaining variables
1511            (valid_name, String.Symbol),
1512
1513            # parentheses
1514            (r'(\(|\))', Punctuation),
1515        ],
1516
1517        # braced strings...
1518        'bracestring': [
1519            (r'\{', String, "#push"),
1520            (r'\}', String, "#pop"),
1521            ('[^{}]+', String),
1522        ],
1523
1524        # tagged [text]...[/text] delimited strings...
1525        'tagstring': [
1526            (r'(?s)(.*?)(\[/text\])', String, '#pop'),
1527        ],
1528    }
1529
1530
1531class EmacsLispLexer(RegexLexer):
1532    """
1533    An ELisp lexer, parsing a stream and outputting the tokens
1534    needed to highlight elisp code.
1535
1536    .. versionadded:: 2.1
1537    """
1538    name = 'EmacsLisp'
1539    aliases = ['emacs', 'elisp', 'emacs-lisp']
1540    filenames = ['*.el']
1541    mimetypes = ['text/x-elisp', 'application/x-elisp']
1542
1543    flags = re.MULTILINE
1544
1545    # couple of useful regexes
1546
1547    # characters that are not macro-characters and can be used to begin a symbol
1548    nonmacro = r'\\.|[\w!$%&*+-/<=>?@^{}~|]'
1549    constituent = nonmacro + '|[#.:]'
1550    terminated = r'(?=[ "()\]\'\n,;`])'  # whitespace or terminating macro characters
1551
1552    # symbol token, reverse-engineered from hyperspec
1553    # Take a deep breath...
1554    symbol = r'((?:%s)(?:%s)*)' % (nonmacro, constituent)
1555
1556    macros = {
1557        'atomic-change-group', 'case', 'block', 'cl-block', 'cl-callf', 'cl-callf2',
1558        'cl-case', 'cl-decf', 'cl-declaim', 'cl-declare',
1559        'cl-define-compiler-macro', 'cl-defmacro', 'cl-defstruct',
1560        'cl-defsubst', 'cl-deftype', 'cl-defun', 'cl-destructuring-bind',
1561        'cl-do', 'cl-do*', 'cl-do-all-symbols', 'cl-do-symbols', 'cl-dolist',
1562        'cl-dotimes', 'cl-ecase', 'cl-etypecase', 'eval-when', 'cl-eval-when', 'cl-flet',
1563        'cl-flet*', 'cl-function', 'cl-incf', 'cl-labels', 'cl-letf',
1564        'cl-letf*', 'cl-load-time-value', 'cl-locally', 'cl-loop',
1565        'cl-macrolet', 'cl-multiple-value-bind', 'cl-multiple-value-setq',
1566        'cl-progv', 'cl-psetf', 'cl-psetq', 'cl-pushnew', 'cl-remf',
1567        'cl-return', 'cl-return-from', 'cl-rotatef', 'cl-shiftf',
1568        'cl-symbol-macrolet', 'cl-tagbody', 'cl-the', 'cl-typecase',
1569        'combine-after-change-calls', 'condition-case-unless-debug', 'decf',
1570        'declaim', 'declare', 'declare-function', 'def-edebug-spec',
1571        'defadvice', 'defclass', 'defcustom', 'defface', 'defgeneric',
1572        'defgroup', 'define-advice', 'define-alternatives',
1573        'define-compiler-macro', 'define-derived-mode', 'define-generic-mode',
1574        'define-global-minor-mode', 'define-globalized-minor-mode',
1575        'define-minor-mode', 'define-modify-macro',
1576        'define-obsolete-face-alias', 'define-obsolete-function-alias',
1577        'define-obsolete-variable-alias', 'define-setf-expander',
1578        'define-skeleton', 'defmacro', 'defmethod', 'defsetf', 'defstruct',
1579        'defsubst', 'deftheme', 'deftype', 'defun', 'defvar-local',
1580        'delay-mode-hooks', 'destructuring-bind', 'do', 'do*',
1581        'do-all-symbols', 'do-symbols', 'dolist', 'dont-compile', 'dotimes',
1582        'dotimes-with-progress-reporter', 'ecase', 'ert-deftest', 'etypecase',
1583        'eval-and-compile', 'eval-when-compile', 'flet', 'ignore-errors',
1584        'incf', 'labels', 'lambda', 'letrec', 'lexical-let', 'lexical-let*',
1585        'loop', 'multiple-value-bind', 'multiple-value-setq', 'noreturn',
1586        'oref', 'oref-default', 'oset', 'oset-default', 'pcase',
1587        'pcase-defmacro', 'pcase-dolist', 'pcase-exhaustive', 'pcase-let',
1588        'pcase-let*', 'pop', 'psetf', 'psetq', 'push', 'pushnew', 'remf',
1589        'return', 'rotatef', 'rx', 'save-match-data', 'save-selected-window',
1590        'save-window-excursion', 'setf', 'setq-local', 'shiftf',
1591        'track-mouse', 'typecase', 'unless', 'use-package', 'when',
1592        'while-no-input', 'with-case-table', 'with-category-table',
1593        'with-coding-priority', 'with-current-buffer', 'with-demoted-errors',
1594        'with-eval-after-load', 'with-file-modes', 'with-local-quit',
1595        'with-output-to-string', 'with-output-to-temp-buffer',
1596        'with-parsed-tramp-file-name', 'with-selected-frame',
1597        'with-selected-window', 'with-silent-modifications', 'with-slots',
1598        'with-syntax-table', 'with-temp-buffer', 'with-temp-file',
1599        'with-temp-message', 'with-timeout', 'with-tramp-connection-property',
1600        'with-tramp-file-property', 'with-tramp-progress-reporter',
1601        'with-wrapper-hook', 'load-time-value', 'locally', 'macrolet', 'progv',
1602        'return-from',
1603    }
1604
1605    special_forms = {
1606        'and', 'catch', 'cond', 'condition-case', 'defconst', 'defvar',
1607        'function', 'if', 'interactive', 'let', 'let*', 'or', 'prog1',
1608        'prog2', 'progn', 'quote', 'save-current-buffer', 'save-excursion',
1609        'save-restriction', 'setq', 'setq-default', 'subr-arity',
1610        'unwind-protect', 'while',
1611    }
1612
1613    builtin_function = {
1614        '%', '*', '+', '-', '/', '/=', '1+', '1-', '<', '<=', '=', '>', '>=',
1615        'Snarf-documentation', 'abort-recursive-edit', 'abs',
1616        'accept-process-output', 'access-file', 'accessible-keymaps', 'acos',
1617        'active-minibuffer-window', 'add-face-text-property',
1618        'add-name-to-file', 'add-text-properties', 'all-completions',
1619        'append', 'apply', 'apropos-internal', 'aref', 'arrayp', 'aset',
1620        'ash', 'asin', 'assoc', 'assoc-string', 'assq', 'atan', 'atom',
1621        'autoload', 'autoload-do-load', 'backtrace', 'backtrace--locals',
1622        'backtrace-debug', 'backtrace-eval', 'backtrace-frame',
1623        'backward-char', 'backward-prefix-chars', 'barf-if-buffer-read-only',
1624        'base64-decode-region', 'base64-decode-string',
1625        'base64-encode-region', 'base64-encode-string', 'beginning-of-line',
1626        'bidi-find-overridden-directionality', 'bidi-resolved-levels',
1627        'bitmap-spec-p', 'bobp', 'bolp', 'bool-vector',
1628        'bool-vector-count-consecutive', 'bool-vector-count-population',
1629        'bool-vector-exclusive-or', 'bool-vector-intersection',
1630        'bool-vector-not', 'bool-vector-p', 'bool-vector-set-difference',
1631        'bool-vector-subsetp', 'bool-vector-union', 'boundp',
1632        'buffer-base-buffer', 'buffer-chars-modified-tick',
1633        'buffer-enable-undo', 'buffer-file-name', 'buffer-has-markers-at',
1634        'buffer-list', 'buffer-live-p', 'buffer-local-value',
1635        'buffer-local-variables', 'buffer-modified-p', 'buffer-modified-tick',
1636        'buffer-name', 'buffer-size', 'buffer-string', 'buffer-substring',
1637        'buffer-substring-no-properties', 'buffer-swap-text', 'bufferp',
1638        'bury-buffer-internal', 'byte-code', 'byte-code-function-p',
1639        'byte-to-position', 'byte-to-string', 'byteorder',
1640        'call-interactively', 'call-last-kbd-macro', 'call-process',
1641        'call-process-region', 'cancel-kbd-macro-events', 'capitalize',
1642        'capitalize-region', 'capitalize-word', 'car', 'car-less-than-car',
1643        'car-safe', 'case-table-p', 'category-docstring',
1644        'category-set-mnemonics', 'category-table', 'category-table-p',
1645        'ccl-execute', 'ccl-execute-on-string', 'ccl-program-p', 'cdr',
1646        'cdr-safe', 'ceiling', 'char-after', 'char-before',
1647        'char-category-set', 'char-charset', 'char-equal', 'char-or-string-p',
1648        'char-resolve-modifiers', 'char-syntax', 'char-table-extra-slot',
1649        'char-table-p', 'char-table-parent', 'char-table-range',
1650        'char-table-subtype', 'char-to-string', 'char-width', 'characterp',
1651        'charset-after', 'charset-id-internal', 'charset-plist',
1652        'charset-priority-list', 'charsetp', 'check-coding-system',
1653        'check-coding-systems-region', 'clear-buffer-auto-save-failure',
1654        'clear-charset-maps', 'clear-face-cache', 'clear-font-cache',
1655        'clear-image-cache', 'clear-string', 'clear-this-command-keys',
1656        'close-font', 'clrhash', 'coding-system-aliases',
1657        'coding-system-base', 'coding-system-eol-type', 'coding-system-p',
1658        'coding-system-plist', 'coding-system-priority-list',
1659        'coding-system-put', 'color-distance', 'color-gray-p',
1660        'color-supported-p', 'combine-after-change-execute',
1661        'command-error-default-function', 'command-remapping', 'commandp',
1662        'compare-buffer-substrings', 'compare-strings',
1663        'compare-window-configurations', 'completing-read',
1664        'compose-region-internal', 'compose-string-internal',
1665        'composition-get-gstring', 'compute-motion', 'concat', 'cons',
1666        'consp', 'constrain-to-field', 'continue-process',
1667        'controlling-tty-p', 'coordinates-in-window-p', 'copy-alist',
1668        'copy-category-table', 'copy-file', 'copy-hash-table', 'copy-keymap',
1669        'copy-marker', 'copy-sequence', 'copy-syntax-table', 'copysign',
1670        'cos', 'current-active-maps', 'current-bidi-paragraph-direction',
1671        'current-buffer', 'current-case-table', 'current-column',
1672        'current-global-map', 'current-idle-time', 'current-indentation',
1673        'current-input-mode', 'current-local-map', 'current-message',
1674        'current-minor-mode-maps', 'current-time', 'current-time-string',
1675        'current-time-zone', 'current-window-configuration',
1676        'cygwin-convert-file-name-from-windows',
1677        'cygwin-convert-file-name-to-windows', 'daemon-initialized',
1678        'daemonp', 'dbus--init-bus', 'dbus-get-unique-name',
1679        'dbus-message-internal', 'debug-timer-check', 'declare-equiv-charset',
1680        'decode-big5-char', 'decode-char', 'decode-coding-region',
1681        'decode-coding-string', 'decode-sjis-char', 'decode-time',
1682        'default-boundp', 'default-file-modes', 'default-printer-name',
1683        'default-toplevel-value', 'default-value', 'define-category',
1684        'define-charset-alias', 'define-charset-internal',
1685        'define-coding-system-alias', 'define-coding-system-internal',
1686        'define-fringe-bitmap', 'define-hash-table-test', 'define-key',
1687        'define-prefix-command', 'delete',
1688        'delete-all-overlays', 'delete-and-extract-region', 'delete-char',
1689        'delete-directory-internal', 'delete-field', 'delete-file',
1690        'delete-frame', 'delete-other-windows-internal', 'delete-overlay',
1691        'delete-process', 'delete-region', 'delete-terminal',
1692        'delete-window-internal', 'delq', 'describe-buffer-bindings',
1693        'describe-vector', 'destroy-fringe-bitmap', 'detect-coding-region',
1694        'detect-coding-string', 'ding', 'directory-file-name',
1695        'directory-files', 'directory-files-and-attributes', 'discard-input',
1696        'display-supports-face-attributes-p', 'do-auto-save', 'documentation',
1697        'documentation-property', 'downcase', 'downcase-region',
1698        'downcase-word', 'draw-string', 'dump-colors', 'dump-emacs',
1699        'dump-face', 'dump-frame-glyph-matrix', 'dump-glyph-matrix',
1700        'dump-glyph-row', 'dump-redisplay-history', 'dump-tool-bar-row',
1701        'elt', 'emacs-pid', 'encode-big5-char', 'encode-char',
1702        'encode-coding-region', 'encode-coding-string', 'encode-sjis-char',
1703        'encode-time', 'end-kbd-macro', 'end-of-line', 'eobp', 'eolp', 'eq',
1704        'eql', 'equal', 'equal-including-properties', 'erase-buffer',
1705        'error-message-string', 'eval', 'eval-buffer', 'eval-region',
1706        'event-convert-list', 'execute-kbd-macro', 'exit-recursive-edit',
1707        'exp', 'expand-file-name', 'expt', 'external-debugging-output',
1708        'face-attribute-relative-p', 'face-attributes-as-vector', 'face-font',
1709        'fboundp', 'fceiling', 'fetch-bytecode', 'ffloor',
1710        'field-beginning', 'field-end', 'field-string',
1711        'field-string-no-properties', 'file-accessible-directory-p',
1712        'file-acl', 'file-attributes', 'file-attributes-lessp',
1713        'file-directory-p', 'file-executable-p', 'file-exists-p',
1714        'file-locked-p', 'file-modes', 'file-name-absolute-p',
1715        'file-name-all-completions', 'file-name-as-directory',
1716        'file-name-completion', 'file-name-directory',
1717        'file-name-nondirectory', 'file-newer-than-file-p', 'file-readable-p',
1718        'file-regular-p', 'file-selinux-context', 'file-symlink-p',
1719        'file-system-info', 'file-system-info', 'file-writable-p',
1720        'fillarray', 'find-charset-region', 'find-charset-string',
1721        'find-coding-systems-region-internal', 'find-composition-internal',
1722        'find-file-name-handler', 'find-font', 'find-operation-coding-system',
1723        'float', 'float-time', 'floatp', 'floor', 'fmakunbound',
1724        'following-char', 'font-at', 'font-drive-otf', 'font-face-attributes',
1725        'font-family-list', 'font-get', 'font-get-glyphs',
1726        'font-get-system-font', 'font-get-system-normal-font', 'font-info',
1727        'font-match-p', 'font-otf-alternates', 'font-put',
1728        'font-shape-gstring', 'font-spec', 'font-variation-glyphs',
1729        'font-xlfd-name', 'fontp', 'fontset-font', 'fontset-info',
1730        'fontset-list', 'fontset-list-all', 'force-mode-line-update',
1731        'force-window-update', 'format', 'format-mode-line',
1732        'format-network-address', 'format-time-string', 'forward-char',
1733        'forward-comment', 'forward-line', 'forward-word',
1734        'frame-border-width', 'frame-bottom-divider-width',
1735        'frame-can-run-window-configuration-change-hook', 'frame-char-height',
1736        'frame-char-width', 'frame-face-alist', 'frame-first-window',
1737        'frame-focus', 'frame-font-cache', 'frame-fringe-width', 'frame-list',
1738        'frame-live-p', 'frame-or-buffer-changed-p', 'frame-parameter',
1739        'frame-parameters', 'frame-pixel-height', 'frame-pixel-width',
1740        'frame-pointer-visible-p', 'frame-right-divider-width',
1741        'frame-root-window', 'frame-scroll-bar-height',
1742        'frame-scroll-bar-width', 'frame-selected-window', 'frame-terminal',
1743        'frame-text-cols', 'frame-text-height', 'frame-text-lines',
1744        'frame-text-width', 'frame-total-cols', 'frame-total-lines',
1745        'frame-visible-p', 'framep', 'frexp', 'fringe-bitmaps-at-pos',
1746        'fround', 'fset', 'ftruncate', 'funcall', 'funcall-interactively',
1747        'function-equal', 'functionp', 'gap-position', 'gap-size',
1748        'garbage-collect', 'gc-status', 'generate-new-buffer-name', 'get',
1749        'get-buffer', 'get-buffer-create', 'get-buffer-process',
1750        'get-buffer-window', 'get-byte', 'get-char-property',
1751        'get-char-property-and-overlay', 'get-file-buffer', 'get-file-char',
1752        'get-internal-run-time', 'get-load-suffixes', 'get-pos-property',
1753        'get-process', 'get-screen-color', 'get-text-property',
1754        'get-unicode-property-internal', 'get-unused-category',
1755        'get-unused-iso-final-char', 'getenv-internal', 'gethash',
1756        'gfile-add-watch', 'gfile-rm-watch', 'global-key-binding',
1757        'gnutls-available-p', 'gnutls-boot', 'gnutls-bye', 'gnutls-deinit',
1758        'gnutls-error-fatalp', 'gnutls-error-string', 'gnutls-errorp',
1759        'gnutls-get-initstage', 'gnutls-peer-status',
1760        'gnutls-peer-status-warning-describe', 'goto-char', 'gpm-mouse-start',
1761        'gpm-mouse-stop', 'group-gid', 'group-real-gid',
1762        'handle-save-session', 'handle-switch-frame', 'hash-table-count',
1763        'hash-table-p', 'hash-table-rehash-size',
1764        'hash-table-rehash-threshold', 'hash-table-size', 'hash-table-test',
1765        'hash-table-weakness', 'iconify-frame', 'identity', 'image-flush',
1766        'image-mask-p', 'image-metadata', 'image-size', 'imagemagick-types',
1767        'imagep', 'indent-to', 'indirect-function', 'indirect-variable',
1768        'init-image-library', 'inotify-add-watch', 'inotify-rm-watch',
1769        'input-pending-p', 'insert', 'insert-and-inherit',
1770        'insert-before-markers', 'insert-before-markers-and-inherit',
1771        'insert-buffer-substring', 'insert-byte', 'insert-char',
1772        'insert-file-contents', 'insert-startup-screen', 'int86',
1773        'integer-or-marker-p', 'integerp', 'interactive-form', 'intern',
1774        'intern-soft', 'internal--track-mouse', 'internal-char-font',
1775        'internal-complete-buffer', 'internal-copy-lisp-face',
1776        'internal-default-process-filter',
1777        'internal-default-process-sentinel', 'internal-describe-syntax-value',
1778        'internal-event-symbol-parse-modifiers',
1779        'internal-face-x-get-resource', 'internal-get-lisp-face-attribute',
1780        'internal-lisp-face-attribute-values', 'internal-lisp-face-empty-p',
1781        'internal-lisp-face-equal-p', 'internal-lisp-face-p',
1782        'internal-make-lisp-face', 'internal-make-var-non-special',
1783        'internal-merge-in-global-face',
1784        'internal-set-alternative-font-family-alist',
1785        'internal-set-alternative-font-registry-alist',
1786        'internal-set-font-selection-order',
1787        'internal-set-lisp-face-attribute',
1788        'internal-set-lisp-face-attribute-from-resource',
1789        'internal-show-cursor', 'internal-show-cursor-p', 'interrupt-process',
1790        'invisible-p', 'invocation-directory', 'invocation-name', 'isnan',
1791        'iso-charset', 'key-binding', 'key-description',
1792        'keyboard-coding-system', 'keymap-parent', 'keymap-prompt', 'keymapp',
1793        'keywordp', 'kill-all-local-variables', 'kill-buffer', 'kill-emacs',
1794        'kill-local-variable', 'kill-process', 'last-nonminibuffer-frame',
1795        'lax-plist-get', 'lax-plist-put', 'ldexp', 'length',
1796        'libxml-parse-html-region', 'libxml-parse-xml-region',
1797        'line-beginning-position', 'line-end-position', 'line-pixel-height',
1798        'list', 'list-fonts', 'list-system-processes', 'listp', 'load',
1799        'load-average', 'local-key-binding', 'local-variable-if-set-p',
1800        'local-variable-p', 'locale-info', 'locate-file-internal',
1801        'lock-buffer', 'log', 'logand', 'logb', 'logior', 'lognot', 'logxor',
1802        'looking-at', 'lookup-image', 'lookup-image-map', 'lookup-key',
1803        'lower-frame', 'lsh', 'macroexpand', 'make-bool-vector',
1804        'make-byte-code', 'make-category-set', 'make-category-table',
1805        'make-char', 'make-char-table', 'make-directory-internal',
1806        'make-frame-invisible', 'make-frame-visible', 'make-hash-table',
1807        'make-indirect-buffer', 'make-keymap', 'make-list',
1808        'make-local-variable', 'make-marker', 'make-network-process',
1809        'make-overlay', 'make-serial-process', 'make-sparse-keymap',
1810        'make-string', 'make-symbol', 'make-symbolic-link', 'make-temp-name',
1811        'make-terminal-frame', 'make-variable-buffer-local',
1812        'make-variable-frame-local', 'make-vector', 'makunbound',
1813        'map-char-table', 'map-charset-chars', 'map-keymap',
1814        'map-keymap-internal', 'mapatoms', 'mapc', 'mapcar', 'mapconcat',
1815        'maphash', 'mark-marker', 'marker-buffer', 'marker-insertion-type',
1816        'marker-position', 'markerp', 'match-beginning', 'match-data',
1817        'match-end', 'matching-paren', 'max', 'max-char', 'md5', 'member',
1818        'memory-info', 'memory-limit', 'memory-use-counts', 'memq', 'memql',
1819        'menu-bar-menu-at-x-y', 'menu-or-popup-active-p',
1820        'menu-or-popup-active-p', 'merge-face-attribute', 'message',
1821        'message-box', 'message-or-box', 'min',
1822        'minibuffer-completion-contents', 'minibuffer-contents',
1823        'minibuffer-contents-no-properties', 'minibuffer-depth',
1824        'minibuffer-prompt', 'minibuffer-prompt-end',
1825        'minibuffer-selected-window', 'minibuffer-window', 'minibufferp',
1826        'minor-mode-key-binding', 'mod', 'modify-category-entry',
1827        'modify-frame-parameters', 'modify-syntax-entry',
1828        'mouse-pixel-position', 'mouse-position', 'move-overlay',
1829        'move-point-visually', 'move-to-column', 'move-to-window-line',
1830        'msdos-downcase-filename', 'msdos-long-file-names', 'msdos-memget',
1831        'msdos-memput', 'msdos-mouse-disable', 'msdos-mouse-enable',
1832        'msdos-mouse-init', 'msdos-mouse-p', 'msdos-remember-default-colors',
1833        'msdos-set-keyboard', 'msdos-set-mouse-buttons',
1834        'multibyte-char-to-unibyte', 'multibyte-string-p', 'narrow-to-region',
1835        'natnump', 'nconc', 'network-interface-info',
1836        'network-interface-list', 'new-fontset', 'newline-cache-check',
1837        'next-char-property-change', 'next-frame', 'next-overlay-change',
1838        'next-property-change', 'next-read-file-uses-dialog-p',
1839        'next-single-char-property-change', 'next-single-property-change',
1840        'next-window', 'nlistp', 'nreverse', 'nth', 'nthcdr', 'null',
1841        'number-or-marker-p', 'number-to-string', 'numberp',
1842        'open-dribble-file', 'open-font', 'open-termscript',
1843        'optimize-char-table', 'other-buffer', 'other-window-for-scrolling',
1844        'overlay-buffer', 'overlay-end', 'overlay-get', 'overlay-lists',
1845        'overlay-properties', 'overlay-put', 'overlay-recenter',
1846        'overlay-start', 'overlayp', 'overlays-at', 'overlays-in',
1847        'parse-partial-sexp', 'play-sound-internal', 'plist-get',
1848        'plist-member', 'plist-put', 'point', 'point-marker', 'point-max',
1849        'point-max-marker', 'point-min', 'point-min-marker',
1850        'pos-visible-in-window-p', 'position-bytes', 'posix-looking-at',
1851        'posix-search-backward', 'posix-search-forward', 'posix-string-match',
1852        'posn-at-point', 'posn-at-x-y', 'preceding-char',
1853        'prefix-numeric-value', 'previous-char-property-change',
1854        'previous-frame', 'previous-overlay-change',
1855        'previous-property-change', 'previous-single-char-property-change',
1856        'previous-single-property-change', 'previous-window', 'prin1',
1857        'prin1-to-string', 'princ', 'print', 'process-attributes',
1858        'process-buffer', 'process-coding-system', 'process-command',
1859        'process-connection', 'process-contact', 'process-datagram-address',
1860        'process-exit-status', 'process-filter', 'process-filter-multibyte-p',
1861        'process-id', 'process-inherit-coding-system-flag', 'process-list',
1862        'process-mark', 'process-name', 'process-plist',
1863        'process-query-on-exit-flag', 'process-running-child-p',
1864        'process-send-eof', 'process-send-region', 'process-send-string',
1865        'process-sentinel', 'process-status', 'process-tty-name',
1866        'process-type', 'processp', 'profiler-cpu-log',
1867        'profiler-cpu-running-p', 'profiler-cpu-start', 'profiler-cpu-stop',
1868        'profiler-memory-log', 'profiler-memory-running-p',
1869        'profiler-memory-start', 'profiler-memory-stop', 'propertize',
1870        'purecopy', 'put', 'put-text-property',
1871        'put-unicode-property-internal', 'puthash', 'query-font',
1872        'query-fontset', 'quit-process', 'raise-frame', 'random', 'rassoc',
1873        'rassq', 're-search-backward', 're-search-forward', 'read',
1874        'read-buffer', 'read-char', 'read-char-exclusive',
1875        'read-coding-system', 'read-command', 'read-event',
1876        'read-from-minibuffer', 'read-from-string', 'read-function',
1877        'read-key-sequence', 'read-key-sequence-vector',
1878        'read-no-blanks-input', 'read-non-nil-coding-system', 'read-string',
1879        'read-variable', 'recent-auto-save-p', 'recent-doskeys',
1880        'recent-keys', 'recenter', 'recursion-depth', 'recursive-edit',
1881        'redirect-debugging-output', 'redirect-frame-focus', 'redisplay',
1882        'redraw-display', 'redraw-frame', 'regexp-quote', 'region-beginning',
1883        'region-end', 'register-ccl-program', 'register-code-conversion-map',
1884        'remhash', 'remove-list-of-text-properties', 'remove-text-properties',
1885        'rename-buffer', 'rename-file', 'replace-match',
1886        'reset-this-command-lengths', 'resize-mini-window-internal',
1887        'restore-buffer-modified-p', 'resume-tty', 'reverse', 'round',
1888        'run-hook-with-args', 'run-hook-with-args-until-failure',
1889        'run-hook-with-args-until-success', 'run-hook-wrapped', 'run-hooks',
1890        'run-window-configuration-change-hook', 'run-window-scroll-functions',
1891        'safe-length', 'scan-lists', 'scan-sexps', 'scroll-down',
1892        'scroll-left', 'scroll-other-window', 'scroll-right', 'scroll-up',
1893        'search-backward', 'search-forward', 'secure-hash', 'select-frame',
1894        'select-window', 'selected-frame', 'selected-window',
1895        'self-insert-command', 'send-string-to-terminal', 'sequencep',
1896        'serial-process-configure', 'set', 'set-buffer',
1897        'set-buffer-auto-saved', 'set-buffer-major-mode',
1898        'set-buffer-modified-p', 'set-buffer-multibyte', 'set-case-table',
1899        'set-category-table', 'set-char-table-extra-slot',
1900        'set-char-table-parent', 'set-char-table-range', 'set-charset-plist',
1901        'set-charset-priority', 'set-coding-system-priority',
1902        'set-cursor-size', 'set-default', 'set-default-file-modes',
1903        'set-default-toplevel-value', 'set-file-acl', 'set-file-modes',
1904        'set-file-selinux-context', 'set-file-times', 'set-fontset-font',
1905        'set-frame-height', 'set-frame-position', 'set-frame-selected-window',
1906        'set-frame-size', 'set-frame-width', 'set-fringe-bitmap-face',
1907        'set-input-interrupt-mode', 'set-input-meta-mode', 'set-input-mode',
1908        'set-keyboard-coding-system-internal', 'set-keymap-parent',
1909        'set-marker', 'set-marker-insertion-type', 'set-match-data',
1910        'set-message-beep', 'set-minibuffer-window',
1911        'set-mouse-pixel-position', 'set-mouse-position',
1912        'set-network-process-option', 'set-output-flow-control',
1913        'set-process-buffer', 'set-process-coding-system',
1914        'set-process-datagram-address', 'set-process-filter',
1915        'set-process-filter-multibyte',
1916        'set-process-inherit-coding-system-flag', 'set-process-plist',
1917        'set-process-query-on-exit-flag', 'set-process-sentinel',
1918        'set-process-window-size', 'set-quit-char',
1919        'set-safe-terminal-coding-system-internal', 'set-screen-color',
1920        'set-standard-case-table', 'set-syntax-table',
1921        'set-terminal-coding-system-internal', 'set-terminal-local-value',
1922        'set-terminal-parameter', 'set-text-properties', 'set-time-zone-rule',
1923        'set-visited-file-modtime', 'set-window-buffer',
1924        'set-window-combination-limit', 'set-window-configuration',
1925        'set-window-dedicated-p', 'set-window-display-table',
1926        'set-window-fringes', 'set-window-hscroll', 'set-window-margins',
1927        'set-window-new-normal', 'set-window-new-pixel',
1928        'set-window-new-total', 'set-window-next-buffers',
1929        'set-window-parameter', 'set-window-point', 'set-window-prev-buffers',
1930        'set-window-redisplay-end-trigger', 'set-window-scroll-bars',
1931        'set-window-start', 'set-window-vscroll', 'setcar', 'setcdr',
1932        'setplist', 'show-face-resources', 'signal', 'signal-process', 'sin',
1933        'single-key-description', 'skip-chars-backward', 'skip-chars-forward',
1934        'skip-syntax-backward', 'skip-syntax-forward', 'sleep-for', 'sort',
1935        'sort-charsets', 'special-variable-p', 'split-char',
1936        'split-window-internal', 'sqrt', 'standard-case-table',
1937        'standard-category-table', 'standard-syntax-table', 'start-kbd-macro',
1938        'start-process', 'stop-process', 'store-kbd-macro-event', 'string',
1939        'string=', 'string<', 'string>', 'string-as-multibyte',
1940        'string-as-unibyte', 'string-bytes', 'string-collate-equalp',
1941        'string-collate-lessp', 'string-equal', 'string-greaterp',
1942        'string-lessp', 'string-make-multibyte', 'string-make-unibyte',
1943        'string-match', 'string-to-char', 'string-to-multibyte',
1944        'string-to-number', 'string-to-syntax', 'string-to-unibyte',
1945        'string-width', 'stringp', 'subr-name', 'subrp',
1946        'subst-char-in-region', 'substitute-command-keys',
1947        'substitute-in-file-name', 'substring', 'substring-no-properties',
1948        'suspend-emacs', 'suspend-tty', 'suspicious-object', 'sxhash',
1949        'symbol-function', 'symbol-name', 'symbol-plist', 'symbol-value',
1950        'symbolp', 'syntax-table', 'syntax-table-p', 'system-groups',
1951        'system-move-file-to-trash', 'system-name', 'system-users', 'tan',
1952        'terminal-coding-system', 'terminal-list', 'terminal-live-p',
1953        'terminal-local-value', 'terminal-name', 'terminal-parameter',
1954        'terminal-parameters', 'terpri', 'test-completion',
1955        'text-char-description', 'text-properties-at', 'text-property-any',
1956        'text-property-not-all', 'this-command-keys',
1957        'this-command-keys-vector', 'this-single-command-keys',
1958        'this-single-command-raw-keys', 'time-add', 'time-less-p',
1959        'time-subtract', 'tool-bar-get-system-style', 'tool-bar-height',
1960        'tool-bar-pixel-width', 'top-level', 'trace-redisplay',
1961        'trace-to-stderr', 'translate-region-internal', 'transpose-regions',
1962        'truncate', 'try-completion', 'tty-display-color-cells',
1963        'tty-display-color-p', 'tty-no-underline',
1964        'tty-suppress-bold-inverse-default-colors', 'tty-top-frame',
1965        'tty-type', 'type-of', 'undo-boundary', 'unencodable-char-position',
1966        'unhandled-file-name-directory', 'unibyte-char-to-multibyte',
1967        'unibyte-string', 'unicode-property-table-internal', 'unify-charset',
1968        'unintern', 'unix-sync', 'unlock-buffer', 'upcase', 'upcase-initials',
1969        'upcase-initials-region', 'upcase-region', 'upcase-word',
1970        'use-global-map', 'use-local-map', 'user-full-name',
1971        'user-login-name', 'user-real-login-name', 'user-real-uid',
1972        'user-uid', 'variable-binding-locus', 'vconcat', 'vector',
1973        'vector-or-char-table-p', 'vectorp', 'verify-visited-file-modtime',
1974        'vertical-motion', 'visible-frame-list', 'visited-file-modtime',
1975        'w16-get-clipboard-data', 'w16-selection-exists-p',
1976        'w16-set-clipboard-data', 'w32-battery-status',
1977        'w32-default-color-map', 'w32-define-rgb-color',
1978        'w32-display-monitor-attributes-list', 'w32-frame-menu-bar-size',
1979        'w32-frame-rect', 'w32-get-clipboard-data',
1980        'w32-get-codepage-charset', 'w32-get-console-codepage',
1981        'w32-get-console-output-codepage', 'w32-get-current-locale-id',
1982        'w32-get-default-locale-id', 'w32-get-keyboard-layout',
1983        'w32-get-locale-info', 'w32-get-valid-codepages',
1984        'w32-get-valid-keyboard-layouts', 'w32-get-valid-locale-ids',
1985        'w32-has-winsock', 'w32-long-file-name', 'w32-reconstruct-hot-key',
1986        'w32-register-hot-key', 'w32-registered-hot-keys',
1987        'w32-selection-exists-p', 'w32-send-sys-command',
1988        'w32-set-clipboard-data', 'w32-set-console-codepage',
1989        'w32-set-console-output-codepage', 'w32-set-current-locale',
1990        'w32-set-keyboard-layout', 'w32-set-process-priority',
1991        'w32-shell-execute', 'w32-short-file-name', 'w32-toggle-lock-key',
1992        'w32-unload-winsock', 'w32-unregister-hot-key', 'w32-window-exists-p',
1993        'w32notify-add-watch', 'w32notify-rm-watch',
1994        'waiting-for-user-input-p', 'where-is-internal', 'widen',
1995        'widget-apply', 'widget-get', 'widget-put',
1996        'window-absolute-pixel-edges', 'window-at', 'window-body-height',
1997        'window-body-width', 'window-bottom-divider-width', 'window-buffer',
1998        'window-combination-limit', 'window-configuration-frame',
1999        'window-configuration-p', 'window-dedicated-p',
2000        'window-display-table', 'window-edges', 'window-end', 'window-frame',
2001        'window-fringes', 'window-header-line-height', 'window-hscroll',
2002        'window-inside-absolute-pixel-edges', 'window-inside-edges',
2003        'window-inside-pixel-edges', 'window-left-child',
2004        'window-left-column', 'window-line-height', 'window-list',
2005        'window-list-1', 'window-live-p', 'window-margins',
2006        'window-minibuffer-p', 'window-mode-line-height', 'window-new-normal',
2007        'window-new-pixel', 'window-new-total', 'window-next-buffers',
2008        'window-next-sibling', 'window-normal-size', 'window-old-point',
2009        'window-parameter', 'window-parameters', 'window-parent',
2010        'window-pixel-edges', 'window-pixel-height', 'window-pixel-left',
2011        'window-pixel-top', 'window-pixel-width', 'window-point',
2012        'window-prev-buffers', 'window-prev-sibling',
2013        'window-redisplay-end-trigger', 'window-resize-apply',
2014        'window-resize-apply-total', 'window-right-divider-width',
2015        'window-scroll-bar-height', 'window-scroll-bar-width',
2016        'window-scroll-bars', 'window-start', 'window-system',
2017        'window-text-height', 'window-text-pixel-size', 'window-text-width',
2018        'window-top-child', 'window-top-line', 'window-total-height',
2019        'window-total-width', 'window-use-time', 'window-valid-p',
2020        'window-vscroll', 'windowp', 'write-char', 'write-region',
2021        'x-backspace-delete-keys-p', 'x-change-window-property',
2022        'x-change-window-property', 'x-close-connection',
2023        'x-close-connection', 'x-create-frame', 'x-create-frame',
2024        'x-delete-window-property', 'x-delete-window-property',
2025        'x-disown-selection-internal', 'x-display-backing-store',
2026        'x-display-backing-store', 'x-display-color-cells',
2027        'x-display-color-cells', 'x-display-grayscale-p',
2028        'x-display-grayscale-p', 'x-display-list', 'x-display-list',
2029        'x-display-mm-height', 'x-display-mm-height', 'x-display-mm-width',
2030        'x-display-mm-width', 'x-display-monitor-attributes-list',
2031        'x-display-pixel-height', 'x-display-pixel-height',
2032        'x-display-pixel-width', 'x-display-pixel-width', 'x-display-planes',
2033        'x-display-planes', 'x-display-save-under', 'x-display-save-under',
2034        'x-display-screens', 'x-display-screens', 'x-display-visual-class',
2035        'x-display-visual-class', 'x-family-fonts', 'x-file-dialog',
2036        'x-file-dialog', 'x-file-dialog', 'x-focus-frame', 'x-frame-geometry',
2037        'x-frame-geometry', 'x-get-atom-name', 'x-get-resource',
2038        'x-get-selection-internal', 'x-hide-tip', 'x-hide-tip',
2039        'x-list-fonts', 'x-load-color-file', 'x-menu-bar-open-internal',
2040        'x-menu-bar-open-internal', 'x-open-connection', 'x-open-connection',
2041        'x-own-selection-internal', 'x-parse-geometry', 'x-popup-dialog',
2042        'x-popup-menu', 'x-register-dnd-atom', 'x-select-font',
2043        'x-select-font', 'x-selection-exists-p', 'x-selection-owner-p',
2044        'x-send-client-message', 'x-server-max-request-size',
2045        'x-server-max-request-size', 'x-server-vendor', 'x-server-vendor',
2046        'x-server-version', 'x-server-version', 'x-show-tip', 'x-show-tip',
2047        'x-synchronize', 'x-synchronize', 'x-uses-old-gtk-dialog',
2048        'x-window-property', 'x-window-property', 'x-wm-set-size-hint',
2049        'xw-color-defined-p', 'xw-color-defined-p', 'xw-color-values',
2050        'xw-color-values', 'xw-display-color-p', 'xw-display-color-p',
2051        'yes-or-no-p', 'zlib-available-p', 'zlib-decompress-region',
2052        'forward-point',
2053    }
2054
2055    builtin_function_highlighted = {
2056        'defvaralias', 'provide', 'require',
2057        'with-no-warnings', 'define-widget', 'with-electric-help',
2058        'throw', 'defalias', 'featurep'
2059    }
2060
2061    lambda_list_keywords = {
2062        '&allow-other-keys', '&aux', '&body', '&environment', '&key', '&optional',
2063        '&rest', '&whole',
2064    }
2065
2066    error_keywords = {
2067        'cl-assert', 'cl-check-type', 'error', 'signal',
2068        'user-error', 'warn',
2069    }
2070
2071    def get_tokens_unprocessed(self, text):
2072        stack = ['root']
2073        for index, token, value in RegexLexer.get_tokens_unprocessed(self, text, stack):
2074            if token is Name.Variable:
2075                if value in EmacsLispLexer.builtin_function:
2076                    yield index, Name.Function, value
2077                    continue
2078                if value in EmacsLispLexer.special_forms:
2079                    yield index, Keyword, value
2080                    continue
2081                if value in EmacsLispLexer.error_keywords:
2082                    yield index, Name.Exception, value
2083                    continue
2084                if value in EmacsLispLexer.builtin_function_highlighted:
2085                    yield index, Name.Builtin, value
2086                    continue
2087                if value in EmacsLispLexer.macros:
2088                    yield index, Name.Builtin, value
2089                    continue
2090                if value in EmacsLispLexer.lambda_list_keywords:
2091                    yield index, Keyword.Pseudo, value
2092                    continue
2093            yield index, token, value
2094
2095    tokens = {
2096        'root': [
2097            default('body'),
2098        ],
2099        'body': [
2100            # whitespace
2101            (r'\s+', Text),
2102
2103            # single-line comment
2104            (r';.*$', Comment.Single),
2105
2106            # strings and characters
2107            (r'"', String, 'string'),
2108            (r'\?([^\\]|\\.)', String.Char),
2109            # quoting
2110            (r":" + symbol, Name.Builtin),
2111            (r"::" + symbol, String.Symbol),
2112            (r"'" + symbol, String.Symbol),
2113            (r"'", Operator),
2114            (r"`", Operator),
2115
2116            # decimal numbers
2117            (r'[-+]?\d+\.?' + terminated, Number.Integer),
2118            (r'[-+]?\d+/\d+' + terminated, Number),
2119            (r'[-+]?(\d*\.\d+([defls][-+]?\d+)?|\d+(\.\d*)?[defls][-+]?\d+)' +
2120             terminated, Number.Float),
2121
2122            # vectors
2123            (r'\[|\]', Punctuation),
2124
2125            # uninterned symbol
2126            (r'#:' + symbol, String.Symbol),
2127
2128            # read syntax for char tables
2129            (r'#\^\^?', Operator),
2130
2131            # function shorthand
2132            (r'#\'', Name.Function),
2133
2134            # binary rational
2135            (r'#[bB][+-]?[01]+(/[01]+)?', Number.Bin),
2136
2137            # octal rational
2138            (r'#[oO][+-]?[0-7]+(/[0-7]+)?', Number.Oct),
2139
2140            # hex rational
2141            (r'#[xX][+-]?[0-9a-fA-F]+(/[0-9a-fA-F]+)?', Number.Hex),
2142
2143            # radix rational
2144            (r'#\d+r[+-]?[0-9a-zA-Z]+(/[0-9a-zA-Z]+)?', Number),
2145
2146            # reference
2147            (r'#\d+=', Operator),
2148            (r'#\d+#', Operator),
2149
2150            # special operators that should have been parsed already
2151            (r'(,@|,|\.|:)', Operator),
2152
2153            # special constants
2154            (r'(t|nil)' + terminated, Name.Constant),
2155
2156            # functions and variables
2157            (r'\*' + symbol + r'\*', Name.Variable.Global),
2158            (symbol, Name.Variable),
2159
2160            # parentheses
2161            (r'#\(', Operator, 'body'),
2162            (r'\(', Punctuation, 'body'),
2163            (r'\)', Punctuation, '#pop'),
2164        ],
2165        'string': [
2166            (r'[^"\\`]+', String),
2167            (r'`%s\'' % symbol, String.Symbol),
2168            (r'`', String),
2169            (r'\\.', String),
2170            (r'\\\n', String),
2171            (r'"', String, '#pop'),
2172        ],
2173    }
2174
2175
2176class ShenLexer(RegexLexer):
2177    """
2178    Lexer for `Shen <http://shenlanguage.org/>`_ source code.
2179
2180    .. versionadded:: 2.1
2181    """
2182    name = 'Shen'
2183    aliases = ['shen']
2184    filenames = ['*.shen']
2185    mimetypes = ['text/x-shen', 'application/x-shen']
2186
2187    DECLARATIONS = (
2188        'datatype', 'define', 'defmacro', 'defprolog', 'defcc',
2189        'synonyms', 'declare', 'package', 'type', 'function',
2190    )
2191
2192    SPECIAL_FORMS = (
2193        'lambda', 'get', 'let', 'if', 'cases', 'cond', 'put', 'time', 'freeze',
2194        'value', 'load', '$', 'protect', 'or', 'and', 'not', 'do', 'output',
2195        'prolog?', 'trap-error', 'error', 'make-string', '/.', 'set', '@p',
2196        '@s', '@v',
2197    )
2198
2199    BUILTINS = (
2200        '==', '=', '*', '+', '-', '/', '<', '>', '>=', '<=', '<-address',
2201        '<-vector', 'abort', 'absvector', 'absvector?', 'address->', 'adjoin',
2202        'append', 'arity', 'assoc', 'bind', 'boolean?', 'bound?', 'call', 'cd',
2203        'close', 'cn', 'compile', 'concat', 'cons', 'cons?', 'cut', 'destroy',
2204        'difference', 'element?', 'empty?', 'enable-type-theory',
2205        'error-to-string', 'eval', 'eval-kl', 'exception', 'explode', 'external',
2206        'fail', 'fail-if', 'file', 'findall', 'fix', 'fst', 'fwhen', 'gensym',
2207        'get-time', 'hash', 'hd', 'hdstr', 'hdv', 'head', 'identical',
2208        'implementation', 'in', 'include', 'include-all-but', 'inferences',
2209        'input', 'input+', 'integer?', 'intern', 'intersection', 'is', 'kill',
2210        'language', 'length', 'limit', 'lineread', 'loaded', 'macro', 'macroexpand',
2211        'map', 'mapcan', 'maxinferences', 'mode', 'n->string', 'nl', 'nth', 'null',
2212        'number?', 'occurrences', 'occurs-check', 'open', 'os', 'out', 'port',
2213        'porters', 'pos', 'pr', 'preclude', 'preclude-all-but', 'print', 'profile',
2214        'profile-results', 'ps', 'quit', 'read', 'read+', 'read-byte', 'read-file',
2215        'read-file-as-bytelist', 'read-file-as-string', 'read-from-string',
2216        'release', 'remove', 'return', 'reverse', 'run', 'save', 'set',
2217        'simple-error', 'snd', 'specialise', 'spy', 'step', 'stinput', 'stoutput',
2218        'str', 'string->n', 'string->symbol', 'string?', 'subst', 'symbol?',
2219        'systemf', 'tail', 'tc', 'tc?', 'thaw', 'tl', 'tlstr', 'tlv', 'track',
2220        'tuple?', 'undefmacro', 'unify', 'unify!', 'union', 'unprofile',
2221        'unspecialise', 'untrack', 'variable?', 'vector', 'vector->', 'vector?',
2222        'verified', 'version', 'warn', 'when', 'write-byte', 'write-to-file',
2223        'y-or-n?',
2224    )
2225
2226    BUILTINS_ANYWHERE = ('where', 'skip', '>>', '_', '!', '<e>', '<!>')
2227
2228    MAPPINGS = {s: Keyword for s in DECLARATIONS}
2229    MAPPINGS.update((s, Name.Builtin) for s in BUILTINS)
2230    MAPPINGS.update((s, Keyword) for s in SPECIAL_FORMS)
2231
2232    valid_symbol_chars = r'[\w!$%*+,<=>?/.\'@&#:-]'
2233    valid_name = '%s+' % valid_symbol_chars
2234    symbol_name = r'[a-z!$%%*+,<=>?/.\'@&#_-]%s*' % valid_symbol_chars
2235    variable = r'[A-Z]%s*' % valid_symbol_chars
2236
2237    tokens = {
2238        'string': [
2239            (r'"', String, '#pop'),
2240            (r'c#\d{1,3};', String.Escape),
2241            (r'~[ARS%]', String.Interpol),
2242            (r'(?s).', String),
2243        ],
2244
2245        'root': [
2246            (r'(?s)\\\*.*?\*\\', Comment.Multiline),  # \* ... *\
2247            (r'\\\\.*', Comment.Single),              # \\ ...
2248            (r'\s+', Text),
2249            (r'_{5,}', Punctuation),
2250            (r'={5,}', Punctuation),
2251            (r'(;|:=|\||--?>|<--?)', Punctuation),
2252            (r'(:-|:|\{|\})', Literal),
2253            (r'[+-]*\d*\.\d+(e[+-]?\d+)?', Number.Float),
2254            (r'[+-]*\d+', Number.Integer),
2255            (r'"', String, 'string'),
2256            (variable, Name.Variable),
2257            (r'(true|false|<>|\[\])', Keyword.Pseudo),
2258            (symbol_name, Literal),
2259            (r'(\[|\]|\(|\))', Punctuation),
2260        ],
2261    }
2262
2263    def get_tokens_unprocessed(self, text):
2264        tokens = RegexLexer.get_tokens_unprocessed(self, text)
2265        tokens = self._process_symbols(tokens)
2266        tokens = self._process_declarations(tokens)
2267        return tokens
2268
2269    def _relevant(self, token):
2270        return token not in (Text, Comment.Single, Comment.Multiline)
2271
2272    def _process_declarations(self, tokens):
2273        opening_paren = False
2274        for index, token, value in tokens:
2275            yield index, token, value
2276            if self._relevant(token):
2277                if opening_paren and token == Keyword and value in self.DECLARATIONS:
2278                    declaration = value
2279                    yield from self._process_declaration(declaration, tokens)
2280                opening_paren = value == '(' and token == Punctuation
2281
2282    def _process_symbols(self, tokens):
2283        opening_paren = False
2284        for index, token, value in tokens:
2285            if opening_paren and token in (Literal, Name.Variable):
2286                token = self.MAPPINGS.get(value, Name.Function)
2287            elif token == Literal and value in self.BUILTINS_ANYWHERE:
2288                token = Name.Builtin
2289            opening_paren = value == '(' and token == Punctuation
2290            yield index, token, value
2291
2292    def _process_declaration(self, declaration, tokens):
2293        for index, token, value in tokens:
2294            if self._relevant(token):
2295                break
2296            yield index, token, value
2297
2298        if declaration == 'datatype':
2299            prev_was_colon = False
2300            token = Keyword.Type if token == Literal else token
2301            yield index, token, value
2302            for index, token, value in tokens:
2303                if prev_was_colon and token == Literal:
2304                    token = Keyword.Type
2305                yield index, token, value
2306                if self._relevant(token):
2307                    prev_was_colon = token == Literal and value == ':'
2308        elif declaration == 'package':
2309            token = Name.Namespace if token == Literal else token
2310            yield index, token, value
2311        elif declaration == 'define':
2312            token = Name.Function if token == Literal else token
2313            yield index, token, value
2314            for index, token, value in tokens:
2315                if self._relevant(token):
2316                    break
2317                yield index, token, value
2318            if value == '{' and token == Literal:
2319                yield index, Punctuation, value
2320                for index, token, value in self._process_signature(tokens):
2321                    yield index, token, value
2322            else:
2323                yield index, token, value
2324        else:
2325            token = Name.Function if token == Literal else token
2326            yield index, token, value
2327
2328        return
2329
2330    def _process_signature(self, tokens):
2331        for index, token, value in tokens:
2332            if token == Literal and value == '}':
2333                yield index, Punctuation, value
2334                return
2335            elif token in (Literal, Name.Function):
2336                token = Name.Variable if value.istitle() else Keyword.Type
2337            yield index, token, value
2338
2339
2340class CPSALexer(SchemeLexer):
2341    """
2342    A CPSA lexer based on the CPSA language as of version 2.2.12
2343
2344    .. versionadded:: 2.1
2345    """
2346    name = 'CPSA'
2347    aliases = ['cpsa']
2348    filenames = ['*.cpsa']
2349    mimetypes = []
2350
2351    # list of known keywords and builtins taken form vim 6.4 scheme.vim
2352    # syntax file.
2353    _keywords = (
2354        'herald', 'vars', 'defmacro', 'include', 'defprotocol', 'defrole',
2355        'defskeleton', 'defstrand', 'deflistener', 'non-orig', 'uniq-orig',
2356        'pen-non-orig', 'precedes', 'trace', 'send', 'recv', 'name', 'text',
2357        'skey', 'akey', 'data', 'mesg',
2358    )
2359    _builtins = (
2360        'cat', 'enc', 'hash', 'privk', 'pubk', 'invk', 'ltk', 'gen', 'exp',
2361    )
2362
2363    # valid names for identifiers
2364    # well, names can only not consist fully of numbers
2365    # but this should be good enough for now
2366    valid_name = r'[\w!$%&*+,/:<=>?@^~|-]+'
2367
2368    tokens = {
2369        'root': [
2370            # the comments - always starting with semicolon
2371            # and going to the end of the line
2372            (r';.*$', Comment.Single),
2373
2374            # whitespaces - usually not relevant
2375            (r'\s+', Text),
2376
2377            # numbers
2378            (r'-?\d+\.\d+', Number.Float),
2379            (r'-?\d+', Number.Integer),
2380            # support for uncommon kinds of numbers -
2381            # have to figure out what the characters mean
2382            # (r'(#e|#i|#b|#o|#d|#x)[\d.]+', Number),
2383
2384            # strings, symbols and characters
2385            (r'"(\\\\|\\[^\\]|[^"\\])*"', String),
2386            (r"'" + valid_name, String.Symbol),
2387            (r"#\\([()/'\"._!§$%& ?=+-]|[a-zA-Z0-9]+)", String.Char),
2388
2389            # constants
2390            (r'(#t|#f)', Name.Constant),
2391
2392            # special operators
2393            (r"('|#|`|,@|,|\.)", Operator),
2394
2395            # highlight the keywords
2396            (words(_keywords, suffix=r'\b'), Keyword),
2397
2398            # first variable in a quoted string like
2399            # '(this is syntactic sugar)
2400            (r"(?<='\()" + valid_name, Name.Variable),
2401            (r"(?<=#\()" + valid_name, Name.Variable),
2402
2403            # highlight the builtins
2404            (words(_builtins, prefix=r'(?<=\()', suffix=r'\b'), Name.Builtin),
2405
2406            # the remaining functions
2407            (r'(?<=\()' + valid_name, Name.Function),
2408            # find the remaining variables
2409            (valid_name, Name.Variable),
2410
2411            # the famous parentheses!
2412            (r'(\(|\))', Punctuation),
2413            (r'(\[|\])', Punctuation),
2414        ],
2415    }
2416
2417
2418class XtlangLexer(RegexLexer):
2419    """An xtlang lexer for the `Extempore programming environment
2420    <http://extempore.moso.com.au>`_.
2421
2422    This is a mixture of Scheme and xtlang, really. Keyword lists are
2423    taken from the Extempore Emacs mode
2424    (https://github.com/extemporelang/extempore-emacs-mode)
2425
2426    .. versionadded:: 2.2
2427    """
2428    name = 'xtlang'
2429    aliases = ['extempore']
2430    filenames = ['*.xtm']
2431    mimetypes = []
2432
2433    common_keywords = (
2434        'lambda', 'define', 'if', 'else', 'cond', 'and',
2435        'or', 'let', 'begin', 'set!', 'map', 'for-each',
2436    )
2437    scheme_keywords = (
2438        'do', 'delay', 'quasiquote', 'unquote', 'unquote-splicing', 'eval',
2439        'case', 'let*', 'letrec', 'quote',
2440    )
2441    xtlang_bind_keywords = (
2442        'bind-func', 'bind-val', 'bind-lib', 'bind-type', 'bind-alias',
2443        'bind-poly', 'bind-dylib', 'bind-lib-func', 'bind-lib-val',
2444    )
2445    xtlang_keywords = (
2446        'letz', 'memzone', 'cast', 'convert', 'dotimes', 'doloop',
2447    )
2448    common_functions = (
2449        '*', '+', '-', '/', '<', '<=', '=', '>', '>=', '%', 'abs', 'acos',
2450        'angle', 'append', 'apply', 'asin', 'assoc', 'assq', 'assv',
2451        'atan', 'boolean?', 'caaaar', 'caaadr', 'caaar', 'caadar',
2452        'caaddr', 'caadr', 'caar', 'cadaar', 'cadadr', 'cadar',
2453        'caddar', 'cadddr', 'caddr', 'cadr', 'car', 'cdaaar',
2454        'cdaadr', 'cdaar', 'cdadar', 'cdaddr', 'cdadr', 'cdar',
2455        'cddaar', 'cddadr', 'cddar', 'cdddar', 'cddddr', 'cdddr',
2456        'cddr', 'cdr', 'ceiling', 'cons', 'cos', 'floor', 'length',
2457        'list', 'log', 'max', 'member', 'min', 'modulo', 'not',
2458        'reverse', 'round', 'sin', 'sqrt', 'substring', 'tan',
2459        'println', 'random', 'null?', 'callback', 'now',
2460    )
2461    scheme_functions = (
2462        'call-with-current-continuation', 'call-with-input-file',
2463        'call-with-output-file', 'call-with-values', 'call/cc',
2464        'char->integer', 'char-alphabetic?', 'char-ci<=?', 'char-ci<?',
2465        'char-ci=?', 'char-ci>=?', 'char-ci>?', 'char-downcase',
2466        'char-lower-case?', 'char-numeric?', 'char-ready?',
2467        'char-upcase', 'char-upper-case?', 'char-whitespace?',
2468        'char<=?', 'char<?', 'char=?', 'char>=?', 'char>?', 'char?',
2469        'close-input-port', 'close-output-port', 'complex?',
2470        'current-input-port', 'current-output-port', 'denominator',
2471        'display', 'dynamic-wind', 'eof-object?', 'eq?', 'equal?',
2472        'eqv?', 'even?', 'exact->inexact', 'exact?', 'exp', 'expt',
2473        'force', 'gcd', 'imag-part', 'inexact->exact', 'inexact?',
2474        'input-port?', 'integer->char', 'integer?',
2475        'interaction-environment', 'lcm', 'list->string',
2476        'list->vector', 'list-ref', 'list-tail', 'list?', 'load',
2477        'magnitude', 'make-polar', 'make-rectangular', 'make-string',
2478        'make-vector', 'memq', 'memv', 'negative?', 'newline',
2479        'null-environment', 'number->string', 'number?',
2480        'numerator', 'odd?', 'open-input-file', 'open-output-file',
2481        'output-port?', 'pair?', 'peek-char', 'port?', 'positive?',
2482        'procedure?', 'quotient', 'rational?', 'rationalize', 'read',
2483        'read-char', 'real-part', 'real?',
2484        'remainder', 'scheme-report-environment', 'set-car!', 'set-cdr!',
2485        'string', 'string->list', 'string->number', 'string->symbol',
2486        'string-append', 'string-ci<=?', 'string-ci<?', 'string-ci=?',
2487        'string-ci>=?', 'string-ci>?', 'string-copy', 'string-fill!',
2488        'string-length', 'string-ref', 'string-set!', 'string<=?',
2489        'string<?', 'string=?', 'string>=?', 'string>?', 'string?',
2490        'symbol->string', 'symbol?', 'transcript-off', 'transcript-on',
2491        'truncate', 'values', 'vector', 'vector->list', 'vector-fill!',
2492        'vector-length', 'vector?',
2493        'with-input-from-file', 'with-output-to-file', 'write',
2494        'write-char', 'zero?',
2495    )
2496    xtlang_functions = (
2497        'toString', 'afill!', 'pfill!', 'tfill!', 'tbind', 'vfill!',
2498        'array-fill!', 'pointer-fill!', 'tuple-fill!', 'vector-fill!', 'free',
2499        'array', 'tuple', 'list', '~', 'cset!', 'cref', '&', 'bor',
2500        'ang-names', '<<', '>>', 'nil', 'printf', 'sprintf', 'null', 'now',
2501        'pset!', 'pref-ptr', 'vset!', 'vref', 'aset!', 'aref', 'aref-ptr',
2502        'tset!', 'tref', 'tref-ptr', 'salloc', 'halloc', 'zalloc', 'alloc',
2503        'schedule', 'exp', 'log', 'sin', 'cos', 'tan', 'asin', 'acos', 'atan',
2504        'sqrt', 'expt', 'floor', 'ceiling', 'truncate', 'round',
2505        'llvm_printf', 'push_zone', 'pop_zone', 'memzone', 'callback',
2506        'llvm_sprintf', 'make-array', 'array-set!', 'array-ref',
2507        'array-ref-ptr', 'pointer-set!', 'pointer-ref', 'pointer-ref-ptr',
2508        'stack-alloc', 'heap-alloc', 'zone-alloc', 'make-tuple', 'tuple-set!',
2509        'tuple-ref', 'tuple-ref-ptr', 'closure-set!', 'closure-ref', 'pref',
2510        'pdref', 'impc_null', 'bitcast', 'void', 'ifret', 'ret->', 'clrun->',
2511        'make-env-zone', 'make-env', '<>', 'dtof', 'ftod', 'i1tof',
2512        'i1tod', 'i1toi8', 'i1toi32', 'i1toi64', 'i8tof', 'i8tod',
2513        'i8toi1', 'i8toi32', 'i8toi64', 'i32tof', 'i32tod', 'i32toi1',
2514        'i32toi8', 'i32toi64', 'i64tof', 'i64tod', 'i64toi1',
2515        'i64toi8', 'i64toi32',
2516    )
2517
2518    # valid names for Scheme identifiers (names cannot consist fully
2519    # of numbers, but this should be good enough for now)
2520    valid_scheme_name = r'[\w!$%&*+,/:<=>?@^~|-]+'
2521
2522    # valid characters in xtlang names & types
2523    valid_xtlang_name = r'[\w.!-]+'
2524    valid_xtlang_type = r'[]{}[\w<>,*/|!-]+'
2525
2526    tokens = {
2527        # keep track of when we're exiting the xtlang form
2528        'xtlang': [
2529            (r'\(', Punctuation, '#push'),
2530            (r'\)', Punctuation, '#pop'),
2531
2532            (r'(?<=bind-func\s)' + valid_xtlang_name, Name.Function),
2533            (r'(?<=bind-val\s)' + valid_xtlang_name, Name.Function),
2534            (r'(?<=bind-type\s)' + valid_xtlang_name, Name.Function),
2535            (r'(?<=bind-alias\s)' + valid_xtlang_name, Name.Function),
2536            (r'(?<=bind-poly\s)' + valid_xtlang_name, Name.Function),
2537            (r'(?<=bind-lib\s)' + valid_xtlang_name, Name.Function),
2538            (r'(?<=bind-dylib\s)' + valid_xtlang_name, Name.Function),
2539            (r'(?<=bind-lib-func\s)' + valid_xtlang_name, Name.Function),
2540            (r'(?<=bind-lib-val\s)' + valid_xtlang_name, Name.Function),
2541
2542            # type annotations
2543            (r':' + valid_xtlang_type, Keyword.Type),
2544
2545            # types
2546            (r'(<' + valid_xtlang_type + r'>|\|' + valid_xtlang_type + r'\||/' +
2547             valid_xtlang_type + r'/|' + valid_xtlang_type + r'\*)\**',
2548             Keyword.Type),
2549
2550            # keywords
2551            (words(xtlang_keywords, prefix=r'(?<=\()'), Keyword),
2552
2553            # builtins
2554            (words(xtlang_functions, prefix=r'(?<=\()'), Name.Function),
2555
2556            include('common'),
2557
2558            # variables
2559            (valid_xtlang_name, Name.Variable),
2560        ],
2561        'scheme': [
2562            # quoted symbols
2563            (r"'" + valid_scheme_name, String.Symbol),
2564
2565            # char literals
2566            (r"#\\([()/'\"._!§$%& ?=+-]|[a-zA-Z0-9]+)", String.Char),
2567
2568            # special operators
2569            (r"('|#|`|,@|,|\.)", Operator),
2570
2571            # keywords
2572            (words(scheme_keywords, prefix=r'(?<=\()'), Keyword),
2573
2574            # builtins
2575            (words(scheme_functions, prefix=r'(?<=\()'), Name.Function),
2576
2577            include('common'),
2578
2579            # variables
2580            (valid_scheme_name, Name.Variable),
2581        ],
2582        # common to both xtlang and Scheme
2583        'common': [
2584            # comments
2585            (r';.*$', Comment.Single),
2586
2587            # whitespaces - usually not relevant
2588            (r'\s+', Text),
2589
2590            # numbers
2591            (r'-?\d+\.\d+', Number.Float),
2592            (r'-?\d+', Number.Integer),
2593
2594            # binary/oct/hex literals
2595            (r'(#b|#o|#x)[\d.]+', Number),
2596
2597            # strings
2598            (r'"(\\\\|\\[^\\]|[^"\\])*"', String),
2599
2600            # true/false constants
2601            (r'(#t|#f)', Name.Constant),
2602
2603            # keywords
2604            (words(common_keywords, prefix=r'(?<=\()'), Keyword),
2605
2606            # builtins
2607            (words(common_functions, prefix=r'(?<=\()'), Name.Function),
2608
2609            # the famous parentheses!
2610            (r'(\(|\))', Punctuation),
2611        ],
2612        'root': [
2613            # go into xtlang mode
2614            (words(xtlang_bind_keywords, prefix=r'(?<=\()', suffix=r'\b'),
2615             Keyword, 'xtlang'),
2616
2617            include('scheme')
2618        ],
2619    }
2620
2621
2622class FennelLexer(RegexLexer):
2623    """A lexer for the `Fennel programming language <https://fennel-lang.org>`_.
2624
2625    Fennel compiles to Lua, so all the Lua builtins are recognized as well
2626    as the special forms that are particular to the Fennel compiler.
2627
2628    .. versionadded:: 2.3
2629    """
2630    name = 'Fennel'
2631    aliases = ['fennel', 'fnl']
2632    filenames = ['*.fnl']
2633
2634    # these two lists are taken from fennel-mode.el:
2635    # https://gitlab.com/technomancy/fennel-mode
2636    # this list is current as of Fennel version 0.6.0.
2637    special_forms = (
2638        'require-macros', 'eval-compiler', 'doc', 'lua', 'hashfn',
2639        'macro', 'macros', 'import-macros', 'pick-args', 'pick-values',
2640        'macroexpand', 'macrodebug', 'do', 'values', 'if', 'when',
2641        'each', 'for', 'fn', 'lambda', 'λ', 'partial', 'while',
2642        'set', 'global', 'var', 'local', 'let', 'tset', 'set-forcibly!',
2643        'doto', 'match', 'or', 'and', 'true', 'false', 'nil', 'not',
2644        'not=', '.', '+', '..', '^', '-', '*', '%', '/', '>',
2645        '<', '>=', '<=', '=', '...', ':', '->', '->>', '-?>',
2646        '-?>>', 'rshift', 'lshift', 'bor', 'band', 'bnot', 'bxor',
2647        'with-open', 'length'
2648    )
2649
2650    # Might be nicer to use the list from _lua_builtins.py but it's unclear how?
2651    builtins = (
2652        '_G', '_VERSION', 'arg', 'assert', 'bit32', 'collectgarbage',
2653        'coroutine', 'debug', 'dofile', 'error', 'getfenv',
2654        'getmetatable', 'io', 'ipairs', 'load', 'loadfile', 'loadstring',
2655        'math', 'next', 'os', 'package', 'pairs', 'pcall', 'print',
2656        'rawequal', 'rawget', 'rawlen', 'rawset', 'require', 'select',
2657        'setfenv', 'setmetatable', 'string', 'table', 'tonumber',
2658        'tostring', 'type', 'unpack', 'xpcall'
2659    )
2660
2661    # based on the scheme definition, but disallowing leading digits and
2662    # commas, and @ is not allowed.
2663    valid_name = r'[a-zA-Z_!$%&*+/:<=>?^~|-][\w!$%&*+/:<=>?^~|\.-]*'
2664
2665    tokens = {
2666        'root': [
2667            # the only comment form is a semicolon; goes to the end of the line
2668            (r';.*$', Comment.Single),
2669
2670            (r'[,\s]+', Text),
2671            (r'-?\d+\.\d+', Number.Float),
2672            (r'-?\d+', Number.Integer),
2673
2674            (r'"(\\\\|\\[^\\]|[^"\\])*"', String),
2675
2676            # these are technically strings, but it's worth visually
2677            # distinguishing them because their intent is different
2678            # from regular strings.
2679            (r':' + valid_name, String.Symbol),
2680
2681            # special forms are keywords
2682            (words(special_forms, suffix=' '), Keyword),
2683            # lua standard library are builtins
2684            (words(builtins, suffix=' '), Name.Builtin),
2685            # special-case the vararg symbol
2686            (r'\.\.\.', Name.Variable),
2687            # regular identifiers
2688            (valid_name, Name.Variable),
2689
2690            # all your normal paired delimiters for your programming enjoyment
2691            (r'(\(|\))', Punctuation),
2692            (r'(\[|\])', Punctuation),
2693            (r'(\{|\})', Punctuation),
2694
2695            # the # symbol is shorthand for a lambda function
2696            (r'#', Punctuation),
2697        ]
2698    }
2699