eric6/ThirdParty/Pygments/pygments/lexers/lisp.py

changeset 7547
21b0534faebc
parent 6942
2602857055c5
child 7701
25f42e208e08
equal deleted inserted replaced
7546:bf5f777260a6 7547:21b0534faebc
3 pygments.lexers.lisp 3 pygments.lexers.lisp
4 ~~~~~~~~~~~~~~~~~~~~ 4 ~~~~~~~~~~~~~~~~~~~~
5 5
6 Lexers for Lispy languages. 6 Lexers for Lispy languages.
7 7
8 :copyright: Copyright 2006-2017 by the Pygments team, see AUTHORS. 8 :copyright: Copyright 2006-2019 by the Pygments team, see AUTHORS.
9 :license: BSD, see LICENSE for details. 9 :license: BSD, see LICENSE for details.
10 """ 10 """
11 11
12 import re 12 import re
13 13
1398 } 1398 }
1399 1399
1400 1400
1401 class NewLispLexer(RegexLexer): 1401 class NewLispLexer(RegexLexer):
1402 """ 1402 """
1403 For `newLISP. <www.newlisp.org>`_ source code (version 10.3.0). 1403 For `newLISP. <http://www.newlisp.org/>`_ source code (version 10.3.0).
1404 1404
1405 .. versionadded:: 1.5 1405 .. versionadded:: 1.5
1406 """ 1406 """
1407 1407
1408 name = 'NewLisp' 1408 name = 'NewLisp'
1552 1552
1553 # symbol token, reverse-engineered from hyperspec 1553 # symbol token, reverse-engineered from hyperspec
1554 # Take a deep breath... 1554 # Take a deep breath...
1555 symbol = r'((?:%s)(?:%s)*)' % (nonmacro, constituent) 1555 symbol = r'((?:%s)(?:%s)*)' % (nonmacro, constituent)
1556 1556
1557 macros = set(( 1557 macros = {
1558 'atomic-change-group', 'case', 'block', 'cl-block', 'cl-callf', 'cl-callf2', 1558 'atomic-change-group', 'case', 'block', 'cl-block', 'cl-callf', 'cl-callf2',
1559 'cl-case', 'cl-decf', 'cl-declaim', 'cl-declare', 1559 'cl-case', 'cl-decf', 'cl-declaim', 'cl-declare',
1560 'cl-define-compiler-macro', 'cl-defmacro', 'cl-defstruct', 1560 'cl-define-compiler-macro', 'cl-defmacro', 'cl-defstruct',
1561 'cl-defsubst', 'cl-deftype', 'cl-defun', 'cl-destructuring-bind', 1561 'cl-defsubst', 'cl-deftype', 'cl-defun', 'cl-destructuring-bind',
1562 'cl-do', 'cl-do*', 'cl-do-all-symbols', 'cl-do-symbols', 'cl-dolist', 1562 'cl-do', 'cl-do*', 'cl-do-all-symbols', 'cl-do-symbols', 'cl-dolist',
1599 'with-syntax-table', 'with-temp-buffer', 'with-temp-file', 1599 'with-syntax-table', 'with-temp-buffer', 'with-temp-file',
1600 'with-temp-message', 'with-timeout', 'with-tramp-connection-property', 1600 'with-temp-message', 'with-timeout', 'with-tramp-connection-property',
1601 'with-tramp-file-property', 'with-tramp-progress-reporter', 1601 'with-tramp-file-property', 'with-tramp-progress-reporter',
1602 'with-wrapper-hook', 'load-time-value', 'locally', 'macrolet', 'progv', 1602 'with-wrapper-hook', 'load-time-value', 'locally', 'macrolet', 'progv',
1603 'return-from', 1603 'return-from',
1604 )) 1604 }
1605 1605
1606 special_forms = set(( 1606 special_forms = {
1607 'and', 'catch', 'cond', 'condition-case', 'defconst', 'defvar', 1607 'and', 'catch', 'cond', 'condition-case', 'defconst', 'defvar',
1608 'function', 'if', 'interactive', 'let', 'let*', 'or', 'prog1', 1608 'function', 'if', 'interactive', 'let', 'let*', 'or', 'prog1',
1609 'prog2', 'progn', 'quote', 'save-current-buffer', 'save-excursion', 1609 'prog2', 'progn', 'quote', 'save-current-buffer', 'save-excursion',
1610 'save-restriction', 'setq', 'setq-default', 'subr-arity', 1610 'save-restriction', 'setq', 'setq-default', 'subr-arity',
1611 'unwind-protect', 'while', 1611 'unwind-protect', 'while',
1612 )) 1612 }
1613 1613
1614 builtin_function = set(( 1614 builtin_function = {
1615 '%', '*', '+', '-', '/', '/=', '1+', '1-', '<', '<=', '=', '>', '>=', 1615 '%', '*', '+', '-', '/', '/=', '1+', '1-', '<', '<=', '=', '>', '>=',
1616 'Snarf-documentation', 'abort-recursive-edit', 'abs', 1616 'Snarf-documentation', 'abort-recursive-edit', 'abs',
1617 'accept-process-output', 'access-file', 'accessible-keymaps', 'acos', 1617 'accept-process-output', 'access-file', 'accessible-keymaps', 'acos',
1618 'active-minibuffer-window', 'add-face-text-property', 1618 'active-minibuffer-window', 'add-face-text-property',
1619 'add-name-to-file', 'add-text-properties', 'all-completions', 1619 'add-name-to-file', 'add-text-properties', 'all-completions',
1935 'skip-syntax-backward', 'skip-syntax-forward', 'sleep-for', 'sort', 1935 'skip-syntax-backward', 'skip-syntax-forward', 'sleep-for', 'sort',
1936 'sort-charsets', 'special-variable-p', 'split-char', 1936 'sort-charsets', 'special-variable-p', 'split-char',
1937 'split-window-internal', 'sqrt', 'standard-case-table', 1937 'split-window-internal', 'sqrt', 'standard-case-table',
1938 'standard-category-table', 'standard-syntax-table', 'start-kbd-macro', 1938 'standard-category-table', 'standard-syntax-table', 'start-kbd-macro',
1939 'start-process', 'stop-process', 'store-kbd-macro-event', 'string', 1939 'start-process', 'stop-process', 'store-kbd-macro-event', 'string',
1940 'string-as-multibyte', 'string-as-unibyte', 'string-bytes', 1940 'string=', 'string<', 'string>', 'string-as-multibyte',
1941 'string-collate-equalp', 'string-collate-lessp', 'string-equal', 1941 'string-as-unibyte', 'string-bytes', 'string-collate-equalp',
1942 'string-collate-lessp', 'string-equal', 'string-greaterp',
1942 'string-lessp', 'string-make-multibyte', 'string-make-unibyte', 1943 'string-lessp', 'string-make-multibyte', 'string-make-unibyte',
1943 'string-match', 'string-to-char', 'string-to-multibyte', 1944 'string-match', 'string-to-char', 'string-to-multibyte',
1944 'string-to-number', 'string-to-syntax', 'string-to-unibyte', 1945 'string-to-number', 'string-to-syntax', 'string-to-unibyte',
1945 'string-width', 'stringp', 'subr-name', 'subrp', 1946 'string-width', 'stringp', 'subr-name', 'subrp',
1946 'subst-char-in-region', 'substitute-command-keys', 1947 'subst-char-in-region', 'substitute-command-keys',
2048 'x-window-property', 'x-window-property', 'x-wm-set-size-hint', 2049 '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-defined-p', 'xw-color-defined-p', 'xw-color-values',
2050 'xw-color-values', 'xw-display-color-p', 'xw-display-color-p', 2051 'xw-color-values', 'xw-display-color-p', 'xw-display-color-p',
2051 'yes-or-no-p', 'zlib-available-p', 'zlib-decompress-region', 2052 'yes-or-no-p', 'zlib-available-p', 'zlib-decompress-region',
2052 'forward-point', 2053 'forward-point',
2053 )) 2054 }
2054 2055
2055 builtin_function_highlighted = set(( 2056 builtin_function_highlighted = {
2056 'defvaralias', 'provide', 'require', 2057 'defvaralias', 'provide', 'require',
2057 'with-no-warnings', 'define-widget', 'with-electric-help', 2058 'with-no-warnings', 'define-widget', 'with-electric-help',
2058 'throw', 'defalias', 'featurep' 2059 'throw', 'defalias', 'featurep'
2059 )) 2060 }
2060 2061
2061 lambda_list_keywords = set(( 2062 lambda_list_keywords = {
2062 '&allow-other-keys', '&aux', '&body', '&environment', '&key', '&optional', 2063 '&allow-other-keys', '&aux', '&body', '&environment', '&key', '&optional',
2063 '&rest', '&whole', 2064 '&rest', '&whole',
2064 )) 2065 }
2065 2066
2066 error_keywords = set(( 2067 error_keywords = {
2067 'cl-assert', 'cl-check-type', 'error', 'signal', 2068 'cl-assert', 'cl-check-type', 'error', 'signal',
2068 'user-error', 'warn', 2069 'user-error', 'warn',
2069 )) 2070 }
2070 2071
2071 def get_tokens_unprocessed(self, text): 2072 def get_tokens_unprocessed(self, text):
2072 stack = ['root'] 2073 stack = ['root']
2073 for index, token, value in RegexLexer.get_tokens_unprocessed(self, text, stack): 2074 for index, token, value in RegexLexer.get_tokens_unprocessed(self, text, stack):
2074 if token is Name.Variable: 2075 if token is Name.Variable:
2223 'y-or-n?', 2224 'y-or-n?',
2224 ) 2225 )
2225 2226
2226 BUILTINS_ANYWHERE = ('where', 'skip', '>>', '_', '!', '<e>', '<!>') 2227 BUILTINS_ANYWHERE = ('where', 'skip', '>>', '_', '!', '<e>', '<!>')
2227 2228
2228 MAPPINGS = dict((s, Keyword) for s in DECLARATIONS) 2229 MAPPINGS = {s: Keyword for s in DECLARATIONS}
2229 MAPPINGS.update((s, Name.Builtin) for s in BUILTINS) 2230 MAPPINGS.update((s, Name.Builtin) for s in BUILTINS)
2230 MAPPINGS.update((s, Keyword) for s in SPECIAL_FORMS) 2231 MAPPINGS.update((s, Keyword) for s in SPECIAL_FORMS)
2231 2232
2232 valid_symbol_chars = r'[\w!$%*+,<=>?/.\'@&#:-]' 2233 valid_symbol_chars = r'[\w!$%*+,<=>?/.\'@&#:-]'
2233 valid_name = '%s+' % valid_symbol_chars 2234 valid_name = '%s+' % valid_symbol_chars

eric ide

mercurial