]> luflow.net public git repositories - flow-web.git/blob - static/highlight/es/languages/scheme.js
Initial commit.
[flow-web.git] / static / highlight / es / languages / scheme.js
1 /*! `scheme` grammar compiled for Highlight.js 11.11.1 */
2 var hljsGrammar = (function () {
3 'use strict';
4
5 /*
6 Language: Scheme
7 Description: Scheme is a programming language in the Lisp family.
8 (keywords based on http://community.schemewiki.org/?scheme-keywords)
9 Author: JP Verkamp <me@jverkamp.com>
10 Contributors: Ivan Sagalaev <maniac@softwaremaniacs.org>
11 Origin: clojure.js
12 Website: http://community.schemewiki.org/?what-is-scheme
13 Category: lisp
14 */
15
16 function scheme(hljs) {
17 const SCHEME_IDENT_RE = '[^\\(\\)\\[\\]\\{\\}",\'`;#|\\\\\\s]+';
18 const SCHEME_SIMPLE_NUMBER_RE = '(-|\\+)?\\d+([./]\\d+)?';
19 const SCHEME_COMPLEX_NUMBER_RE = SCHEME_SIMPLE_NUMBER_RE + '[+\\-]' + SCHEME_SIMPLE_NUMBER_RE + 'i';
20 const KEYWORDS = {
21 $pattern: SCHEME_IDENT_RE,
22 built_in:
23 'case-lambda call/cc class define-class exit-handler field import '
24 + 'inherit init-field interface let*-values let-values let/ec mixin '
25 + 'opt-lambda override protect provide public rename require '
26 + 'require-for-syntax syntax syntax-case syntax-error unit/sig unless '
27 + 'when with-syntax and begin call-with-current-continuation '
28 + 'call-with-input-file call-with-output-file case cond define '
29 + 'define-syntax delay do dynamic-wind else for-each if lambda let let* '
30 + 'let-syntax letrec letrec-syntax map or syntax-rules \' * + , ,@ - ... / '
31 + '; < <= = => > >= ` abs acos angle append apply asin assoc assq assv atan '
32 + 'boolean? caar cadr call-with-input-file call-with-output-file '
33 + 'call-with-values car cdddar cddddr cdr ceiling char->integer '
34 + 'char-alphabetic? char-ci<=? char-ci<? char-ci=? char-ci>=? char-ci>? '
35 + 'char-downcase char-lower-case? char-numeric? char-ready? char-upcase '
36 + 'char-upper-case? char-whitespace? char<=? char<? char=? char>=? char>? '
37 + 'char? close-input-port close-output-port complex? cons cos '
38 + 'current-input-port current-output-port denominator display eof-object? '
39 + 'eq? equal? eqv? eval even? exact->inexact exact? exp expt floor '
40 + 'force gcd imag-part inexact->exact inexact? input-port? integer->char '
41 + 'integer? interaction-environment lcm length list list->string '
42 + 'list->vector list-ref list-tail list? load log magnitude make-polar '
43 + 'make-rectangular make-string make-vector max member memq memv min '
44 + 'modulo negative? newline not null-environment null? number->string '
45 + 'number? numerator odd? open-input-file open-output-file output-port? '
46 + 'pair? peek-char port? positive? procedure? quasiquote quote quotient '
47 + 'rational? rationalize read read-char real-part real? remainder reverse '
48 + 'round scheme-report-environment set! set-car! set-cdr! sin sqrt string '
49 + 'string->list string->number string->symbol string-append string-ci<=? '
50 + 'string-ci<? string-ci=? string-ci>=? string-ci>? string-copy '
51 + 'string-fill! string-length string-ref string-set! string<=? string<? '
52 + 'string=? string>=? string>? string? substring symbol->string symbol? '
53 + 'tan transcript-off transcript-on truncate values vector '
54 + 'vector->list vector-fill! vector-length vector-ref vector-set! '
55 + 'with-input-from-file with-output-to-file write write-char zero?'
56 };
57
58 const LITERAL = {
59 className: 'literal',
60 begin: '(#t|#f|#\\\\' + SCHEME_IDENT_RE + '|#\\\\.)'
61 };
62
63 const NUMBER = {
64 className: 'number',
65 variants: [
66 {
67 begin: SCHEME_SIMPLE_NUMBER_RE,
68 relevance: 0
69 },
70 {
71 begin: SCHEME_COMPLEX_NUMBER_RE,
72 relevance: 0
73 },
74 { begin: '#b[0-1]+(/[0-1]+)?' },
75 { begin: '#o[0-7]+(/[0-7]+)?' },
76 { begin: '#x[0-9a-f]+(/[0-9a-f]+)?' }
77 ]
78 };
79
80 const STRING = hljs.QUOTE_STRING_MODE;
81
82 const COMMENT_MODES = [
83 hljs.COMMENT(
84 ';',
85 '$',
86 { relevance: 0 }
87 ),
88 hljs.COMMENT('#\\|', '\\|#')
89 ];
90
91 const IDENT = {
92 begin: SCHEME_IDENT_RE,
93 relevance: 0
94 };
95
96 const QUOTED_IDENT = {
97 className: 'symbol',
98 begin: '\'' + SCHEME_IDENT_RE
99 };
100
101 const BODY = {
102 endsWithParent: true,
103 relevance: 0
104 };
105
106 const QUOTED_LIST = {
107 variants: [
108 { begin: /'/ },
109 { begin: '`' }
110 ],
111 contains: [
112 {
113 begin: '\\(',
114 end: '\\)',
115 contains: [
116 'self',
117 LITERAL,
118 STRING,
119 NUMBER,
120 IDENT,
121 QUOTED_IDENT
122 ]
123 }
124 ]
125 };
126
127 const NAME = {
128 className: 'name',
129 relevance: 0,
130 begin: SCHEME_IDENT_RE,
131 keywords: KEYWORDS
132 };
133
134 const LAMBDA = {
135 begin: /lambda/,
136 endsWithParent: true,
137 returnBegin: true,
138 contains: [
139 NAME,
140 {
141 endsParent: true,
142 variants: [
143 {
144 begin: /\(/,
145 end: /\)/
146 },
147 {
148 begin: /\[/,
149 end: /\]/
150 }
151 ],
152 contains: [ IDENT ]
153 }
154 ]
155 };
156
157 const LIST = {
158 variants: [
159 {
160 begin: '\\(',
161 end: '\\)'
162 },
163 {
164 begin: '\\[',
165 end: '\\]'
166 }
167 ],
168 contains: [
169 LAMBDA,
170 NAME,
171 BODY
172 ]
173 };
174
175 BODY.contains = [
176 LITERAL,
177 NUMBER,
178 STRING,
179 IDENT,
180 QUOTED_IDENT,
181 QUOTED_LIST,
182 LIST
183 ].concat(COMMENT_MODES);
184
185 return {
186 name: 'Scheme',
187 aliases: ['scm'],
188 illegal: /\S/,
189 contains: [
190 hljs.SHEBANG(),
191 NUMBER,
192 STRING,
193 QUOTED_IDENT,
194 QUOTED_LIST,
195 LIST
196 ].concat(COMMENT_MODES)
197 };
198 }
199
200 return scheme;
201
202 })();
203 ;
204 export default hljsGrammar;