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