66
|
1 package lexers
|
|
2
|
|
3 import (
|
|
4 . "github.com/alecthomas/chroma/v2" // nolint
|
|
5 )
|
|
6
|
|
7 var (
|
|
8 clBuiltinFunctions = []string{
|
|
9 "<", "<=", "=", ">", ">=", "-", "/", "/=", "*", "+", "1-", "1+",
|
|
10 "abort", "abs", "acons", "acos", "acosh", "add-method", "adjoin",
|
|
11 "adjustable-array-p", "adjust-array", "allocate-instance",
|
|
12 "alpha-char-p", "alphanumericp", "append", "apply", "apropos",
|
|
13 "apropos-list", "aref", "arithmetic-error-operands",
|
|
14 "arithmetic-error-operation", "array-dimension", "array-dimensions",
|
|
15 "array-displacement", "array-element-type", "array-has-fill-pointer-p",
|
|
16 "array-in-bounds-p", "arrayp", "array-rank", "array-row-major-index",
|
|
17 "array-total-size", "ash", "asin", "asinh", "assoc", "assoc-if",
|
|
18 "assoc-if-not", "atan", "atanh", "atom", "bit", "bit-and", "bit-andc1",
|
|
19 "bit-andc2", "bit-eqv", "bit-ior", "bit-nand", "bit-nor", "bit-not",
|
|
20 "bit-orc1", "bit-orc2", "bit-vector-p", "bit-xor", "boole",
|
|
21 "both-case-p", "boundp", "break", "broadcast-stream-streams",
|
|
22 "butlast", "byte", "byte-position", "byte-size", "caaaar", "caaadr",
|
|
23 "caaar", "caadar", "caaddr", "caadr", "caar", "cadaar", "cadadr",
|
|
24 "cadar", "caddar", "cadddr", "caddr", "cadr", "call-next-method", "car",
|
|
25 "cdaaar", "cdaadr", "cdaar", "cdadar", "cdaddr", "cdadr", "cdar",
|
|
26 "cddaar", "cddadr", "cddar", "cdddar", "cddddr", "cdddr", "cddr", "cdr",
|
|
27 "ceiling", "cell-error-name", "cerror", "change-class", "char", "char<",
|
|
28 "char<=", "char=", "char>", "char>=", "char/=", "character",
|
|
29 "characterp", "char-code", "char-downcase", "char-equal",
|
|
30 "char-greaterp", "char-int", "char-lessp", "char-name",
|
|
31 "char-not-equal", "char-not-greaterp", "char-not-lessp", "char-upcase",
|
|
32 "cis", "class-name", "class-of", "clear-input", "clear-output",
|
|
33 "close", "clrhash", "code-char", "coerce", "compile",
|
|
34 "compiled-function-p", "compile-file", "compile-file-pathname",
|
|
35 "compiler-macro-function", "complement", "complex", "complexp",
|
|
36 "compute-applicable-methods", "compute-restarts", "concatenate",
|
|
37 "concatenated-stream-streams", "conjugate", "cons", "consp",
|
|
38 "constantly", "constantp", "continue", "copy-alist", "copy-list",
|
|
39 "copy-pprint-dispatch", "copy-readtable", "copy-seq", "copy-structure",
|
|
40 "copy-symbol", "copy-tree", "cos", "cosh", "count", "count-if",
|
|
41 "count-if-not", "decode-float", "decode-universal-time", "delete",
|
|
42 "delete-duplicates", "delete-file", "delete-if", "delete-if-not",
|
|
43 "delete-package", "denominator", "deposit-field", "describe",
|
|
44 "describe-object", "digit-char", "digit-char-p", "directory",
|
|
45 "directory-namestring", "disassemble", "documentation", "dpb",
|
|
46 "dribble", "echo-stream-input-stream", "echo-stream-output-stream",
|
|
47 "ed", "eighth", "elt", "encode-universal-time", "endp",
|
|
48 "enough-namestring", "ensure-directories-exist",
|
|
49 "ensure-generic-function", "eq", "eql", "equal", "equalp", "error",
|
|
50 "eval", "evenp", "every", "exp", "export", "expt", "fboundp",
|
|
51 "fceiling", "fdefinition", "ffloor", "fifth", "file-author",
|
|
52 "file-error-pathname", "file-length", "file-namestring",
|
|
53 "file-position", "file-string-length", "file-write-date",
|
|
54 "fill", "fill-pointer", "find", "find-all-symbols", "find-class",
|
|
55 "find-if", "find-if-not", "find-method", "find-package", "find-restart",
|
|
56 "find-symbol", "finish-output", "first", "float", "float-digits",
|
|
57 "floatp", "float-precision", "float-radix", "float-sign", "floor",
|
|
58 "fmakunbound", "force-output", "format", "fourth", "fresh-line",
|
|
59 "fround", "ftruncate", "funcall", "function-keywords",
|
|
60 "function-lambda-expression", "functionp", "gcd", "gensym", "gentemp",
|
|
61 "get", "get-decoded-time", "get-dispatch-macro-character", "getf",
|
|
62 "gethash", "get-internal-real-time", "get-internal-run-time",
|
|
63 "get-macro-character", "get-output-stream-string", "get-properties",
|
|
64 "get-setf-expansion", "get-universal-time", "graphic-char-p",
|
|
65 "hash-table-count", "hash-table-p", "hash-table-rehash-size",
|
|
66 "hash-table-rehash-threshold", "hash-table-size", "hash-table-test",
|
|
67 "host-namestring", "identity", "imagpart", "import",
|
|
68 "initialize-instance", "input-stream-p", "inspect",
|
|
69 "integer-decode-float", "integer-length", "integerp",
|
|
70 "interactive-stream-p", "intern", "intersection",
|
|
71 "invalid-method-error", "invoke-debugger", "invoke-restart",
|
|
72 "invoke-restart-interactively", "isqrt", "keywordp", "last", "lcm",
|
|
73 "ldb", "ldb-test", "ldiff", "length", "lisp-implementation-type",
|
|
74 "lisp-implementation-version", "list", "list*", "list-all-packages",
|
|
75 "listen", "list-length", "listp", "load",
|
|
76 "load-logical-pathname-translations", "log", "logand", "logandc1",
|
|
77 "logandc2", "logbitp", "logcount", "logeqv", "logical-pathname",
|
|
78 "logical-pathname-translations", "logior", "lognand", "lognor",
|
|
79 "lognot", "logorc1", "logorc2", "logtest", "logxor", "long-site-name",
|
|
80 "lower-case-p", "machine-instance", "machine-type", "machine-version",
|
|
81 "macroexpand", "macroexpand-1", "macro-function", "make-array",
|
|
82 "make-broadcast-stream", "make-concatenated-stream", "make-condition",
|
|
83 "make-dispatch-macro-character", "make-echo-stream", "make-hash-table",
|
|
84 "make-instance", "make-instances-obsolete", "make-list",
|
|
85 "make-load-form", "make-load-form-saving-slots", "make-package",
|
|
86 "make-pathname", "make-random-state", "make-sequence", "make-string",
|
|
87 "make-string-input-stream", "make-string-output-stream", "make-symbol",
|
|
88 "make-synonym-stream", "make-two-way-stream", "makunbound", "map",
|
|
89 "mapc", "mapcan", "mapcar", "mapcon", "maphash", "map-into", "mapl",
|
|
90 "maplist", "mask-field", "max", "member", "member-if", "member-if-not",
|
|
91 "merge", "merge-pathnames", "method-combination-error",
|
|
92 "method-qualifiers", "min", "minusp", "mismatch", "mod",
|
|
93 "muffle-warning", "name-char", "namestring", "nbutlast", "nconc",
|
|
94 "next-method-p", "nintersection", "ninth", "no-applicable-method",
|
|
95 "no-next-method", "not", "notany", "notevery", "nreconc", "nreverse",
|
|
96 "nset-difference", "nset-exclusive-or", "nstring-capitalize",
|
|
97 "nstring-downcase", "nstring-upcase", "nsublis", "nsubst", "nsubst-if",
|
|
98 "nsubst-if-not", "nsubstitute", "nsubstitute-if", "nsubstitute-if-not",
|
|
99 "nth", "nthcdr", "null", "numberp", "numerator", "nunion", "oddp",
|
|
100 "open", "open-stream-p", "output-stream-p", "package-error-package",
|
|
101 "package-name", "package-nicknames", "packagep",
|
|
102 "package-shadowing-symbols", "package-used-by-list", "package-use-list",
|
|
103 "pairlis", "parse-integer", "parse-namestring", "pathname",
|
|
104 "pathname-device", "pathname-directory", "pathname-host",
|
|
105 "pathname-match-p", "pathname-name", "pathnamep", "pathname-type",
|
|
106 "pathname-version", "peek-char", "phase", "plusp", "position",
|
|
107 "position-if", "position-if-not", "pprint", "pprint-dispatch",
|
|
108 "pprint-fill", "pprint-indent", "pprint-linear", "pprint-newline",
|
|
109 "pprint-tab", "pprint-tabular", "prin1", "prin1-to-string", "princ",
|
|
110 "princ-to-string", "print", "print-object", "probe-file", "proclaim",
|
|
111 "provide", "random", "random-state-p", "rassoc", "rassoc-if",
|
|
112 "rassoc-if-not", "rational", "rationalize", "rationalp", "read",
|
|
113 "read-byte", "read-char", "read-char-no-hang", "read-delimited-list",
|
|
114 "read-from-string", "read-line", "read-preserving-whitespace",
|
|
115 "read-sequence", "readtable-case", "readtablep", "realp", "realpart",
|
|
116 "reduce", "reinitialize-instance", "rem", "remhash", "remove",
|
|
117 "remove-duplicates", "remove-if", "remove-if-not", "remove-method",
|
|
118 "remprop", "rename-file", "rename-package", "replace", "require",
|
|
119 "rest", "restart-name", "revappend", "reverse", "room", "round",
|
|
120 "row-major-aref", "rplaca", "rplacd", "sbit", "scale-float", "schar",
|
|
121 "search", "second", "set", "set-difference",
|
|
122 "set-dispatch-macro-character", "set-exclusive-or",
|
|
123 "set-macro-character", "set-pprint-dispatch", "set-syntax-from-char",
|
|
124 "seventh", "shadow", "shadowing-import", "shared-initialize",
|
|
125 "short-site-name", "signal", "signum", "simple-bit-vector-p",
|
|
126 "simple-condition-format-arguments", "simple-condition-format-control",
|
|
127 "simple-string-p", "simple-vector-p", "sin", "sinh", "sixth", "sleep",
|
|
128 "slot-boundp", "slot-exists-p", "slot-makunbound", "slot-missing",
|
|
129 "slot-unbound", "slot-value", "software-type", "software-version",
|
|
130 "some", "sort", "special-operator-p", "sqrt", "stable-sort",
|
|
131 "standard-char-p", "store-value", "stream-element-type",
|
|
132 "stream-error-stream", "stream-external-format", "streamp", "string",
|
|
133 "string<", "string<=", "string=", "string>", "string>=", "string/=",
|
|
134 "string-capitalize", "string-downcase", "string-equal",
|
|
135 "string-greaterp", "string-left-trim", "string-lessp",
|
|
136 "string-not-equal", "string-not-greaterp", "string-not-lessp",
|
|
137 "stringp", "string-right-trim", "string-trim", "string-upcase",
|
|
138 "sublis", "subseq", "subsetp", "subst", "subst-if", "subst-if-not",
|
|
139 "substitute", "substitute-if", "substitute-if-not", "subtypep", "svref",
|
|
140 "sxhash", "symbol-function", "symbol-name", "symbolp", "symbol-package",
|
|
141 "symbol-plist", "symbol-value", "synonym-stream-symbol", "syntax:",
|
|
142 "tailp", "tan", "tanh", "tenth", "terpri", "third",
|
|
143 "translate-logical-pathname", "translate-pathname", "tree-equal",
|
|
144 "truename", "truncate", "two-way-stream-input-stream",
|
|
145 "two-way-stream-output-stream", "type-error-datum",
|
|
146 "type-error-expected-type", "type-of", "typep", "unbound-slot-instance",
|
|
147 "unexport", "unintern", "union", "unread-char", "unuse-package",
|
|
148 "update-instance-for-different-class",
|
|
149 "update-instance-for-redefined-class", "upgraded-array-element-type",
|
|
150 "upgraded-complex-part-type", "upper-case-p", "use-package",
|
|
151 "user-homedir-pathname", "use-value", "values", "values-list", "vector",
|
|
152 "vectorp", "vector-pop", "vector-push", "vector-push-extend", "warn",
|
|
153 "wild-pathname-p", "write", "write-byte", "write-char", "write-line",
|
|
154 "write-sequence", "write-string", "write-to-string", "yes-or-no-p",
|
|
155 "y-or-n-p", "zerop",
|
|
156 }
|
|
157
|
|
158 clSpecialForms = []string{
|
|
159 "block", "catch", "declare", "eval-when", "flet", "function", "go", "if",
|
|
160 "labels", "lambda", "let", "let*", "load-time-value", "locally", "macrolet",
|
|
161 "multiple-value-call", "multiple-value-prog1", "progn", "progv", "quote",
|
|
162 "return-from", "setq", "symbol-macrolet", "tagbody", "the", "throw",
|
|
163 "unwind-protect",
|
|
164 }
|
|
165
|
|
166 clMacros = []string{
|
|
167 "and", "assert", "call-method", "case", "ccase", "check-type", "cond",
|
|
168 "ctypecase", "decf", "declaim", "defclass", "defconstant", "defgeneric",
|
|
169 "define-compiler-macro", "define-condition", "define-method-combination",
|
|
170 "define-modify-macro", "define-setf-expander", "define-symbol-macro",
|
|
171 "defmacro", "defmethod", "defpackage", "defparameter", "defsetf",
|
|
172 "defstruct", "deftype", "defun", "defvar", "destructuring-bind", "do",
|
|
173 "do*", "do-all-symbols", "do-external-symbols", "dolist", "do-symbols",
|
|
174 "dotimes", "ecase", "etypecase", "formatter", "handler-bind",
|
|
175 "handler-case", "ignore-errors", "incf", "in-package", "lambda", "loop",
|
|
176 "loop-finish", "make-method", "multiple-value-bind", "multiple-value-list",
|
|
177 "multiple-value-setq", "nth-value", "or", "pop",
|
|
178 "pprint-exit-if-list-exhausted", "pprint-logical-block", "pprint-pop",
|
|
179 "print-unreadable-object", "prog", "prog*", "prog1", "prog2", "psetf",
|
|
180 "psetq", "push", "pushnew", "remf", "restart-bind", "restart-case",
|
|
181 "return", "rotatef", "setf", "shiftf", "step", "time", "trace", "typecase",
|
|
182 "unless", "untrace", "when", "with-accessors", "with-compilation-unit",
|
|
183 "with-condition-restarts", "with-hash-table-iterator",
|
|
184 "with-input-from-string", "with-open-file", "with-open-stream",
|
|
185 "with-output-to-string", "with-package-iterator", "with-simple-restart",
|
|
186 "with-slots", "with-standard-io-syntax",
|
|
187 }
|
|
188
|
|
189 clLambdaListKeywords = []string{
|
|
190 "&allow-other-keys", "&aux", "&body", "&environment", "&key", "&optional",
|
|
191 "&rest", "&whole",
|
|
192 }
|
|
193
|
|
194 clDeclarations = []string{
|
|
195 "dynamic-extent", "ignore", "optimize", "ftype", "inline", "special",
|
|
196 "ignorable", "notinline", "type",
|
|
197 }
|
|
198
|
|
199 clBuiltinTypes = []string{
|
|
200 "atom", "boolean", "base-char", "base-string", "bignum", "bit",
|
|
201 "compiled-function", "extended-char", "fixnum", "keyword", "nil",
|
|
202 "signed-byte", "short-float", "single-float", "double-float", "long-float",
|
|
203 "simple-array", "simple-base-string", "simple-bit-vector", "simple-string",
|
|
204 "simple-vector", "standard-char", "unsigned-byte",
|
|
205
|
|
206 // Condition Types
|
|
207 "arithmetic-error", "cell-error", "condition", "control-error",
|
|
208 "division-by-zero", "end-of-file", "error", "file-error",
|
|
209 "floating-point-inexact", "floating-point-overflow",
|
|
210 "floating-point-underflow", "floating-point-invalid-operation",
|
|
211 "parse-error", "package-error", "print-not-readable", "program-error",
|
|
212 "reader-error", "serious-condition", "simple-condition", "simple-error",
|
|
213 "simple-type-error", "simple-warning", "stream-error", "storage-condition",
|
|
214 "style-warning", "type-error", "unbound-variable", "unbound-slot",
|
|
215 "undefined-function", "warning",
|
|
216 }
|
|
217
|
|
218 clBuiltinClasses = []string{
|
|
219 "array", "broadcast-stream", "bit-vector", "built-in-class", "character",
|
|
220 "class", "complex", "concatenated-stream", "cons", "echo-stream",
|
|
221 "file-stream", "float", "function", "generic-function", "hash-table",
|
|
222 "integer", "list", "logical-pathname", "method-combination", "method",
|
|
223 "null", "number", "package", "pathname", "ratio", "rational", "readtable",
|
|
224 "real", "random-state", "restart", "sequence", "standard-class",
|
|
225 "standard-generic-function", "standard-method", "standard-object",
|
|
226 "string-stream", "stream", "string", "structure-class", "structure-object",
|
|
227 "symbol", "synonym-stream", "t", "two-way-stream", "vector",
|
|
228 }
|
|
229 )
|
|
230
|
|
231 // Common Lisp lexer.
|
|
232 var CommonLisp = Register(TypeRemappingLexer(MustNewXMLLexer(
|
|
233 embedded,
|
|
234 "embedded/common_lisp.xml",
|
|
235 ), TypeMapping{
|
|
236 {NameVariable, NameFunction, clBuiltinFunctions},
|
|
237 {NameVariable, Keyword, clSpecialForms},
|
|
238 {NameVariable, NameBuiltin, clMacros},
|
|
239 {NameVariable, Keyword, clLambdaListKeywords},
|
|
240 {NameVariable, Keyword, clDeclarations},
|
|
241 {NameVariable, KeywordType, clBuiltinTypes},
|
|
242 {NameVariable, NameClass, clBuiltinClasses},
|
|
243 }))
|