UNPKG

3.42 kBJavaScriptView Raw
1/*
2Language: XL
3Author: Christophe de Dinechin <christophe@taodyne.com>
4Description: An extensible programming language, based on parse tree rewriting
5Website: http://xlr.sf.net
6*/
7
8function xl(hljs) {
9 const KWS = [
10 "if",
11 "then",
12 "else",
13 "do",
14 "while",
15 "until",
16 "for",
17 "loop",
18 "import",
19 "with",
20 "is",
21 "as",
22 "where",
23 "when",
24 "by",
25 "data",
26 "constant",
27 "integer",
28 "real",
29 "text",
30 "name",
31 "boolean",
32 "symbol",
33 "infix",
34 "prefix",
35 "postfix",
36 "block",
37 "tree"
38 ];
39 const BUILT_INS = [
40 "in",
41 "mod",
42 "rem",
43 "and",
44 "or",
45 "xor",
46 "not",
47 "abs",
48 "sign",
49 "floor",
50 "ceil",
51 "sqrt",
52 "sin",
53 "cos",
54 "tan",
55 "asin",
56 "acos",
57 "atan",
58 "exp",
59 "expm1",
60 "log",
61 "log2",
62 "log10",
63 "log1p",
64 "pi",
65 "at",
66 "text_length",
67 "text_range",
68 "text_find",
69 "text_replace",
70 "contains",
71 "page",
72 "slide",
73 "basic_slide",
74 "title_slide",
75 "title",
76 "subtitle",
77 "fade_in",
78 "fade_out",
79 "fade_at",
80 "clear_color",
81 "color",
82 "line_color",
83 "line_width",
84 "texture_wrap",
85 "texture_transform",
86 "texture",
87 "scale_?x",
88 "scale_?y",
89 "scale_?z?",
90 "translate_?x",
91 "translate_?y",
92 "translate_?z?",
93 "rotate_?x",
94 "rotate_?y",
95 "rotate_?z?",
96 "rectangle",
97 "circle",
98 "ellipse",
99 "sphere",
100 "path",
101 "line_to",
102 "move_to",
103 "quad_to",
104 "curve_to",
105 "theme",
106 "background",
107 "contents",
108 "locally",
109 "time",
110 "mouse_?x",
111 "mouse_?y",
112 "mouse_buttons"
113 ];
114 const BUILTIN_MODULES = [
115 "ObjectLoader",
116 "Animate",
117 "MovieCredits",
118 "Slides",
119 "Filters",
120 "Shading",
121 "Materials",
122 "LensFlare",
123 "Mapping",
124 "VLCAudioVideo",
125 "StereoDecoder",
126 "PointCloud",
127 "NetworkAccess",
128 "RemoteControl",
129 "RegExp",
130 "ChromaKey",
131 "Snowfall",
132 "NodeJS",
133 "Speech",
134 "Charts"
135 ];
136 const LITERALS = [
137 "true",
138 "false",
139 "nil"
140 ];
141 const KEYWORDS = {
142 $pattern: /[a-zA-Z][a-zA-Z0-9_?]*/,
143 keyword: KWS,
144 literal: LITERALS,
145 built_in: BUILT_INS.concat(BUILTIN_MODULES)
146 };
147
148 const DOUBLE_QUOTE_TEXT = {
149 className: 'string',
150 begin: '"',
151 end: '"',
152 illegal: '\\n'
153 };
154 const SINGLE_QUOTE_TEXT = {
155 className: 'string',
156 begin: '\'',
157 end: '\'',
158 illegal: '\\n'
159 };
160 const LONG_TEXT = {
161 className: 'string',
162 begin: '<<',
163 end: '>>'
164 };
165 const BASED_NUMBER = {
166 className: 'number',
167 begin: '[0-9]+#[0-9A-Z_]+(\\.[0-9-A-Z_]+)?#?([Ee][+-]?[0-9]+)?'
168 };
169 const IMPORT = {
170 beginKeywords: 'import',
171 end: '$',
172 keywords: KEYWORDS,
173 contains: [ DOUBLE_QUOTE_TEXT ]
174 };
175 const FUNCTION_DEFINITION = {
176 className: 'function',
177 begin: /[a-z][^\n]*->/,
178 returnBegin: true,
179 end: /->/,
180 contains: [
181 hljs.inherit(hljs.TITLE_MODE, { starts: {
182 endsWithParent: true,
183 keywords: KEYWORDS
184 } })
185 ]
186 };
187 return {
188 name: 'XL',
189 aliases: [ 'tao' ],
190 keywords: KEYWORDS,
191 contains: [
192 hljs.C_LINE_COMMENT_MODE,
193 hljs.C_BLOCK_COMMENT_MODE,
194 DOUBLE_QUOTE_TEXT,
195 SINGLE_QUOTE_TEXT,
196 LONG_TEXT,
197 FUNCTION_DEFINITION,
198 IMPORT,
199 BASED_NUMBER,
200 hljs.NUMBER_MODE
201 ]
202 };
203}
204
205module.exports = xl;