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