1
0
Fork 0
management/front/dkha-web-sz-main/node_modules/highlight.js/lib/languages/actionscript.js

114 lines
2.6 KiB
JavaScript
Raw Normal View History

2024-01-16 21:26:16 +08:00
/**
* @param {string} value
* @returns {RegExp}
* */
2023-12-18 13:12:25 +08:00
2024-01-16 21:26:16 +08:00
/**
* @param {RegExp | string } re
* @returns {string}
*/
function source(re) {
if (!re) return null;
if (typeof re === "string") return re;
return re.source;
}
/**
* @param {...(RegExp | string) } args
* @returns {string}
*/
function concat(...args) {
const joined = args.map((x) => source(x)).join("");
return joined;
}
/*
Language: ActionScript
Author: Alexander Myadzel <myadzel@gmail.com>
Category: scripting
Audit: 2020
*/
/** @type LanguageFn */
function actionscript(hljs) {
const IDENT_RE = /[a-zA-Z_$][a-zA-Z0-9_$]*/;
const IDENT_FUNC_RETURN_TYPE_RE = /([*]|[a-zA-Z_$][a-zA-Z0-9_$]*)/;
const AS3_REST_ARG_MODE = {
2023-12-18 13:12:25 +08:00
className: 'rest_arg',
2024-01-16 21:26:16 +08:00
begin: /[.]{3}/,
end: IDENT_RE,
2023-12-18 13:12:25 +08:00
relevance: 10
};
return {
2024-01-16 21:26:16 +08:00
name: 'ActionScript',
aliases: [ 'as' ],
2023-12-18 13:12:25 +08:00
keywords: {
keyword: 'as break case catch class const continue default delete do dynamic each ' +
'else extends final finally for function get if implements import in include ' +
'instanceof interface internal is namespace native new override package private ' +
'protected public return set static super switch this throw try typeof use var void ' +
'while with',
literal: 'true false null undefined'
},
contains: [
hljs.APOS_STRING_MODE,
hljs.QUOTE_STRING_MODE,
hljs.C_LINE_COMMENT_MODE,
hljs.C_BLOCK_COMMENT_MODE,
hljs.C_NUMBER_MODE,
{
className: 'class',
2024-01-16 21:26:16 +08:00
beginKeywords: 'package',
end: /\{/,
contains: [ hljs.TITLE_MODE ]
2023-12-18 13:12:25 +08:00
},
{
className: 'class',
2024-01-16 21:26:16 +08:00
beginKeywords: 'class interface',
end: /\{/,
excludeEnd: true,
2023-12-18 13:12:25 +08:00
contains: [
2024-01-16 21:26:16 +08:00
{ beginKeywords: 'extends implements' },
2023-12-18 13:12:25 +08:00
hljs.TITLE_MODE
]
},
{
className: 'meta',
2024-01-16 21:26:16 +08:00
beginKeywords: 'import include',
end: /;/,
keywords: { 'meta-keyword': 'import include' }
2023-12-18 13:12:25 +08:00
},
{
className: 'function',
2024-01-16 21:26:16 +08:00
beginKeywords: 'function',
end: /[{;]/,
excludeEnd: true,
illegal: /\S/,
2023-12-18 13:12:25 +08:00
contains: [
hljs.TITLE_MODE,
{
className: 'params',
2024-01-16 21:26:16 +08:00
begin: /\(/,
end: /\)/,
2023-12-18 13:12:25 +08:00
contains: [
hljs.APOS_STRING_MODE,
hljs.QUOTE_STRING_MODE,
hljs.C_LINE_COMMENT_MODE,
hljs.C_BLOCK_COMMENT_MODE,
AS3_REST_ARG_MODE
]
},
2024-01-16 21:26:16 +08:00
{ begin: concat(/:\s*/, IDENT_FUNC_RETURN_TYPE_RE) }
2023-12-18 13:12:25 +08:00
]
},
hljs.METHOD_GUARD
],
illegal: /#/
};
2024-01-16 21:26:16 +08:00
}
module.exports = actionscript;