1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 | function actionscript(hljs) {
|
10 | const regex = hljs.regex;
|
11 | const IDENT_RE = /[a-zA-Z_$][a-zA-Z0-9_$]*/;
|
12 | const PKG_NAME_RE = regex.concat(
|
13 | IDENT_RE,
|
14 | regex.concat("(\\.", IDENT_RE, ")*")
|
15 | );
|
16 | const IDENT_FUNC_RETURN_TYPE_RE = /([*]|[a-zA-Z_$][a-zA-Z0-9_$]*)/;
|
17 |
|
18 | const AS3_REST_ARG_MODE = {
|
19 | className: 'rest_arg',
|
20 | begin: /[.]{3}/,
|
21 | end: IDENT_RE,
|
22 | relevance: 10
|
23 | };
|
24 |
|
25 | const KEYWORDS = [
|
26 | "as",
|
27 | "break",
|
28 | "case",
|
29 | "catch",
|
30 | "class",
|
31 | "const",
|
32 | "continue",
|
33 | "default",
|
34 | "delete",
|
35 | "do",
|
36 | "dynamic",
|
37 | "each",
|
38 | "else",
|
39 | "extends",
|
40 | "final",
|
41 | "finally",
|
42 | "for",
|
43 | "function",
|
44 | "get",
|
45 | "if",
|
46 | "implements",
|
47 | "import",
|
48 | "in",
|
49 | "include",
|
50 | "instanceof",
|
51 | "interface",
|
52 | "internal",
|
53 | "is",
|
54 | "namespace",
|
55 | "native",
|
56 | "new",
|
57 | "override",
|
58 | "package",
|
59 | "private",
|
60 | "protected",
|
61 | "public",
|
62 | "return",
|
63 | "set",
|
64 | "static",
|
65 | "super",
|
66 | "switch",
|
67 | "this",
|
68 | "throw",
|
69 | "try",
|
70 | "typeof",
|
71 | "use",
|
72 | "var",
|
73 | "void",
|
74 | "while",
|
75 | "with"
|
76 | ];
|
77 | const LITERALS = [
|
78 | "true",
|
79 | "false",
|
80 | "null",
|
81 | "undefined"
|
82 | ];
|
83 |
|
84 | return {
|
85 | name: 'ActionScript',
|
86 | aliases: [ 'as' ],
|
87 | keywords: {
|
88 | keyword: KEYWORDS,
|
89 | literal: LITERALS
|
90 | },
|
91 | contains: [
|
92 | hljs.APOS_STRING_MODE,
|
93 | hljs.QUOTE_STRING_MODE,
|
94 | hljs.C_LINE_COMMENT_MODE,
|
95 | hljs.C_BLOCK_COMMENT_MODE,
|
96 | hljs.C_NUMBER_MODE,
|
97 | {
|
98 | match: [
|
99 | /\bpackage/,
|
100 | /\s+/,
|
101 | PKG_NAME_RE
|
102 | ],
|
103 | className: {
|
104 | 1: "keyword",
|
105 | 3: "title.class"
|
106 | }
|
107 | },
|
108 | {
|
109 | match: [
|
110 | /\b(?:class|interface|extends|implements)/,
|
111 | /\s+/,
|
112 | IDENT_RE
|
113 | ],
|
114 | className: {
|
115 | 1: "keyword",
|
116 | 3: "title.class"
|
117 | }
|
118 | },
|
119 | {
|
120 | className: 'meta',
|
121 | beginKeywords: 'import include',
|
122 | end: /;/,
|
123 | keywords: { keyword: 'import include' }
|
124 | },
|
125 | {
|
126 | beginKeywords: 'function',
|
127 | end: /[{;]/,
|
128 | excludeEnd: true,
|
129 | illegal: /\S/,
|
130 | contains: [
|
131 | hljs.inherit(hljs.TITLE_MODE, { className: "title.function" }),
|
132 | {
|
133 | className: 'params',
|
134 | begin: /\(/,
|
135 | end: /\)/,
|
136 | contains: [
|
137 | hljs.APOS_STRING_MODE,
|
138 | hljs.QUOTE_STRING_MODE,
|
139 | hljs.C_LINE_COMMENT_MODE,
|
140 | hljs.C_BLOCK_COMMENT_MODE,
|
141 | AS3_REST_ARG_MODE
|
142 | ]
|
143 | },
|
144 | { begin: regex.concat(/:\s*/, IDENT_FUNC_RETURN_TYPE_RE) }
|
145 | ]
|
146 | },
|
147 | hljs.METHOD_GUARD
|
148 | ],
|
149 | illegal: /#/
|
150 | };
|
151 | }
|
152 |
|
153 | export { actionscript as default };
|