2024-01-16 21:26:16 +08:00
|
|
|
/*
|
|
|
|
Language: XL
|
|
|
|
Author: Christophe de Dinechin <christophe@taodyne.com>
|
|
|
|
Description: An extensible programming language, based on parse tree rewriting
|
|
|
|
Website: http://xlr.sf.net
|
|
|
|
*/
|
|
|
|
|
|
|
|
function xl(hljs) {
|
|
|
|
const BUILTIN_MODULES =
|
2023-12-18 13:12:25 +08:00
|
|
|
'ObjectLoader Animate MovieCredits Slides Filters Shading Materials LensFlare Mapping VLCAudioVideo ' +
|
|
|
|
'StereoDecoder PointCloud NetworkAccess RemoteControl RegExp ChromaKey Snowfall NodeJS Speech Charts';
|
|
|
|
|
2024-01-16 21:26:16 +08:00
|
|
|
const XL_KEYWORDS = {
|
|
|
|
$pattern: /[a-zA-Z][a-zA-Z0-9_?]*/,
|
2023-12-18 13:12:25 +08:00
|
|
|
keyword:
|
|
|
|
'if then else do while until for loop import with is as where when by data constant ' +
|
|
|
|
'integer real text name boolean symbol infix prefix postfix block tree',
|
|
|
|
literal:
|
|
|
|
'true false nil',
|
|
|
|
built_in:
|
|
|
|
'in mod rem and or xor not abs sign floor ceil sqrt sin cos tan asin ' +
|
|
|
|
'acos atan exp expm1 log log2 log10 log1p pi at text_length text_range ' +
|
|
|
|
'text_find text_replace contains page slide basic_slide title_slide ' +
|
|
|
|
'title subtitle fade_in fade_out fade_at clear_color color line_color ' +
|
|
|
|
'line_width texture_wrap texture_transform texture scale_?x scale_?y ' +
|
|
|
|
'scale_?z? translate_?x translate_?y translate_?z? rotate_?x rotate_?y ' +
|
|
|
|
'rotate_?z? rectangle circle ellipse sphere path line_to move_to ' +
|
|
|
|
'quad_to curve_to theme background contents locally time mouse_?x ' +
|
|
|
|
'mouse_?y mouse_buttons ' +
|
|
|
|
BUILTIN_MODULES
|
|
|
|
};
|
|
|
|
|
2024-01-16 21:26:16 +08:00
|
|
|
const DOUBLE_QUOTE_TEXT = {
|
2023-12-18 13:12:25 +08:00
|
|
|
className: 'string',
|
2024-01-16 21:26:16 +08:00
|
|
|
begin: '"',
|
|
|
|
end: '"',
|
|
|
|
illegal: '\\n'
|
2023-12-18 13:12:25 +08:00
|
|
|
};
|
2024-01-16 21:26:16 +08:00
|
|
|
const SINGLE_QUOTE_TEXT = {
|
2023-12-18 13:12:25 +08:00
|
|
|
className: 'string',
|
2024-01-16 21:26:16 +08:00
|
|
|
begin: '\'',
|
|
|
|
end: '\'',
|
|
|
|
illegal: '\\n'
|
2023-12-18 13:12:25 +08:00
|
|
|
};
|
2024-01-16 21:26:16 +08:00
|
|
|
const LONG_TEXT = {
|
2023-12-18 13:12:25 +08:00
|
|
|
className: 'string',
|
2024-01-16 21:26:16 +08:00
|
|
|
begin: '<<',
|
|
|
|
end: '>>'
|
2023-12-18 13:12:25 +08:00
|
|
|
};
|
2024-01-16 21:26:16 +08:00
|
|
|
const BASED_NUMBER = {
|
2023-12-18 13:12:25 +08:00
|
|
|
className: 'number',
|
|
|
|
begin: '[0-9]+#[0-9A-Z_]+(\\.[0-9-A-Z_]+)?#?([Ee][+-]?[0-9]+)?'
|
|
|
|
};
|
2024-01-16 21:26:16 +08:00
|
|
|
const IMPORT = {
|
|
|
|
beginKeywords: 'import',
|
|
|
|
end: '$',
|
2023-12-18 13:12:25 +08:00
|
|
|
keywords: XL_KEYWORDS,
|
2024-01-16 21:26:16 +08:00
|
|
|
contains: [ DOUBLE_QUOTE_TEXT ]
|
2023-12-18 13:12:25 +08:00
|
|
|
};
|
2024-01-16 21:26:16 +08:00
|
|
|
const FUNCTION_DEFINITION = {
|
2023-12-18 13:12:25 +08:00
|
|
|
className: 'function',
|
2024-01-16 21:26:16 +08:00
|
|
|
begin: /[a-z][^\n]*->/,
|
|
|
|
returnBegin: true,
|
|
|
|
end: /->/,
|
2023-12-18 13:12:25 +08:00
|
|
|
contains: [
|
2024-01-16 21:26:16 +08:00
|
|
|
hljs.inherit(hljs.TITLE_MODE, {
|
|
|
|
starts: {
|
|
|
|
endsWithParent: true,
|
|
|
|
keywords: XL_KEYWORDS
|
|
|
|
}
|
|
|
|
})
|
2023-12-18 13:12:25 +08:00
|
|
|
]
|
|
|
|
};
|
|
|
|
return {
|
2024-01-16 21:26:16 +08:00
|
|
|
name: 'XL',
|
|
|
|
aliases: [ 'tao' ],
|
2023-12-18 13:12:25 +08:00
|
|
|
keywords: XL_KEYWORDS,
|
|
|
|
contains: [
|
2024-01-16 21:26:16 +08:00
|
|
|
hljs.C_LINE_COMMENT_MODE,
|
|
|
|
hljs.C_BLOCK_COMMENT_MODE,
|
|
|
|
DOUBLE_QUOTE_TEXT,
|
|
|
|
SINGLE_QUOTE_TEXT,
|
|
|
|
LONG_TEXT,
|
|
|
|
FUNCTION_DEFINITION,
|
|
|
|
IMPORT,
|
|
|
|
BASED_NUMBER,
|
|
|
|
hljs.NUMBER_MODE
|
2023-12-18 13:12:25 +08:00
|
|
|
]
|
|
|
|
};
|
2024-01-16 21:26:16 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = xl;
|