[d24f17c] | 1 | /**
|
---|
| 2 | * @param {string} value
|
---|
| 3 | * @returns {RegExp}
|
---|
| 4 | * */
|
---|
| 5 |
|
---|
| 6 | /**
|
---|
| 7 | * @param {RegExp | string } re
|
---|
| 8 | * @returns {string}
|
---|
| 9 | */
|
---|
| 10 | function source(re) {
|
---|
| 11 | if (!re) return null;
|
---|
| 12 | if (typeof re === "string") return re;
|
---|
| 13 |
|
---|
| 14 | return re.source;
|
---|
| 15 | }
|
---|
| 16 |
|
---|
| 17 | /**
|
---|
| 18 | * @param {...(RegExp | string) } args
|
---|
| 19 | * @returns {string}
|
---|
| 20 | */
|
---|
| 21 | function concat(...args) {
|
---|
| 22 | const joined = args.map((x) => source(x)).join("");
|
---|
| 23 | return joined;
|
---|
| 24 | }
|
---|
| 25 |
|
---|
| 26 | /*
|
---|
| 27 | Language: ActionScript
|
---|
| 28 | Author: Alexander Myadzel <myadzel@gmail.com>
|
---|
| 29 | Category: scripting
|
---|
| 30 | Audit: 2020
|
---|
| 31 | */
|
---|
| 32 |
|
---|
| 33 | /** @type LanguageFn */
|
---|
| 34 | function actionscript(hljs) {
|
---|
| 35 | const IDENT_RE = /[a-zA-Z_$][a-zA-Z0-9_$]*/;
|
---|
| 36 | const IDENT_FUNC_RETURN_TYPE_RE = /([*]|[a-zA-Z_$][a-zA-Z0-9_$]*)/;
|
---|
| 37 |
|
---|
| 38 | const AS3_REST_ARG_MODE = {
|
---|
| 39 | className: 'rest_arg',
|
---|
| 40 | begin: /[.]{3}/,
|
---|
| 41 | end: IDENT_RE,
|
---|
| 42 | relevance: 10
|
---|
| 43 | };
|
---|
| 44 |
|
---|
| 45 | return {
|
---|
| 46 | name: 'ActionScript',
|
---|
| 47 | aliases: [ 'as' ],
|
---|
| 48 | keywords: {
|
---|
| 49 | keyword: 'as break case catch class const continue default delete do dynamic each ' +
|
---|
| 50 | 'else extends final finally for function get if implements import in include ' +
|
---|
| 51 | 'instanceof interface internal is namespace native new override package private ' +
|
---|
| 52 | 'protected public return set static super switch this throw try typeof use var void ' +
|
---|
| 53 | 'while with',
|
---|
| 54 | literal: 'true false null undefined'
|
---|
| 55 | },
|
---|
| 56 | contains: [
|
---|
| 57 | hljs.APOS_STRING_MODE,
|
---|
| 58 | hljs.QUOTE_STRING_MODE,
|
---|
| 59 | hljs.C_LINE_COMMENT_MODE,
|
---|
| 60 | hljs.C_BLOCK_COMMENT_MODE,
|
---|
| 61 | hljs.C_NUMBER_MODE,
|
---|
| 62 | {
|
---|
| 63 | className: 'class',
|
---|
| 64 | beginKeywords: 'package',
|
---|
| 65 | end: /\{/,
|
---|
| 66 | contains: [ hljs.TITLE_MODE ]
|
---|
| 67 | },
|
---|
| 68 | {
|
---|
| 69 | className: 'class',
|
---|
| 70 | beginKeywords: 'class interface',
|
---|
| 71 | end: /\{/,
|
---|
| 72 | excludeEnd: true,
|
---|
| 73 | contains: [
|
---|
| 74 | { beginKeywords: 'extends implements' },
|
---|
| 75 | hljs.TITLE_MODE
|
---|
| 76 | ]
|
---|
| 77 | },
|
---|
| 78 | {
|
---|
| 79 | className: 'meta',
|
---|
| 80 | beginKeywords: 'import include',
|
---|
| 81 | end: /;/,
|
---|
| 82 | keywords: { 'meta-keyword': 'import include' }
|
---|
| 83 | },
|
---|
| 84 | {
|
---|
| 85 | className: 'function',
|
---|
| 86 | beginKeywords: 'function',
|
---|
| 87 | end: /[{;]/,
|
---|
| 88 | excludeEnd: true,
|
---|
| 89 | illegal: /\S/,
|
---|
| 90 | contains: [
|
---|
| 91 | hljs.TITLE_MODE,
|
---|
| 92 | {
|
---|
| 93 | className: 'params',
|
---|
| 94 | begin: /\(/,
|
---|
| 95 | end: /\)/,
|
---|
| 96 | contains: [
|
---|
| 97 | hljs.APOS_STRING_MODE,
|
---|
| 98 | hljs.QUOTE_STRING_MODE,
|
---|
| 99 | hljs.C_LINE_COMMENT_MODE,
|
---|
| 100 | hljs.C_BLOCK_COMMENT_MODE,
|
---|
| 101 | AS3_REST_ARG_MODE
|
---|
| 102 | ]
|
---|
| 103 | },
|
---|
| 104 | { begin: concat(/:\s*/, IDENT_FUNC_RETURN_TYPE_RE) }
|
---|
| 105 | ]
|
---|
| 106 | },
|
---|
| 107 | hljs.METHOD_GUARD
|
---|
| 108 | ],
|
---|
| 109 | illegal: /#/
|
---|
| 110 | };
|
---|
| 111 | }
|
---|
| 112 |
|
---|
| 113 | module.exports = actionscript;
|
---|