Changeset View
Changeset View
Standalone View
Standalone View
data/syntax/javascript.xml
1 | <?xml version="1.0" encoding="UTF-8"?> | 1 | <?xml version="1.0" encoding="UTF-8"?> | ||
---|---|---|---|---|---|
2 | <!DOCTYPE language SYSTEM "language.dtd" | 2 | <!DOCTYPE language SYSTEM "language.dtd" | ||
3 | [ | 3 | [ | ||
4 | <!ENTITY identifier "([a-zA-Z_$]|[^[:ascii:]])([\w$]|[^[:ascii:]])*"> | 4 | <!ENTITY identifier "([a-zA-Z_$]|[^[:ascii:]])([\w$]|[^[:ascii:]])*"> | ||
5 | ]> | 5 | ]> | ||
6 | <!-- Author: Anders Lund <anders@alweb.dk> //--> | 6 | <!-- Author: Anders Lund <anders@alweb.dk> //--> | ||
7 | <!-- Minor changes: Joseph Wenninger <jowenn@kde.org> //--> | 7 | <!-- Minor changes: Joseph Wenninger <jowenn@kde.org> //--> | ||
8 | <!-- Full JavaScript 1.0 support by Whitehawk Stormchaser //--> | 8 | <!-- Full JavaScript 1.0 support by Whitehawk Stormchaser //--> | ||
9 | <!-- NOTE: This highlighter does not offer full support for TypeScript. The .ts files | 9 | <language name="JavaScript" version="10" kateversion="5.0" section="Scripts" extensions="*.js;*.kwinscript;*.julius" | ||
10 | are temporarily included, since a syntax highlighting file for TypeScript is required! --> | | |||
11 | <language name="JavaScript" version="9" kateversion="5.0" section="Scripts" extensions="*.js;*.kwinscript;*.julius;*.ts" | | |||
12 | mimetype="text/x-javascript;application/x-javascript;application/javascript;text/javascript" indenter="cstyle" | 10 | mimetype="text/x-javascript;application/x-javascript;application/javascript;text/javascript" indenter="cstyle" | ||
13 | author="Anders Lund (anders@alweb.dk), Joseph Wenninger (jowenn@kde.org), Whitehawk Stormchaser (zerokode@gmx.net)" license=""> | 11 | author="Anders Lund (anders@alweb.dk), Joseph Wenninger (jowenn@kde.org), Whitehawk Stormchaser (zerokode@gmx.net)" license=""> | ||
14 | <highlighting> | 12 | <highlighting> | ||
15 | <list name="controlflow"> | 13 | <list name="controlflow"> | ||
14 | <item>await</item> | ||||
16 | <item>break</item> | 15 | <item>break</item> | ||
17 | <item>case</item> | 16 | <item>case</item> | ||
18 | <item>catch</item> | 17 | <item>catch</item> | ||
19 | <item>continue</item> | 18 | <item>continue</item> | ||
20 | <item>debugger</item> | 19 | <item>debugger</item> | ||
21 | <item>do</item> | 20 | <item>do</item> | ||
22 | <item>else</item> | 21 | <item>else</item> | ||
23 | <item>finally</item> | 22 | <item>finally</item> | ||
24 | <item>for</item> | 23 | <item>for</item> | ||
25 | <item>if</item> | 24 | <item>if</item> | ||
26 | <item>return</item> | 25 | <item>return</item> | ||
27 | <item>switch</item> | 26 | <item>switch</item> | ||
28 | <item>throw</item> | 27 | <item>throw</item> | ||
29 | <item>try</item> | 28 | <item>try</item> | ||
30 | <item>while</item> | 29 | <item>while</item> | ||
31 | <item>with</item> | 30 | <item>with</item> | ||
32 | </list> | 31 | </list> | ||
33 | <list name="keywords"> | 32 | <list name="keywords"> | ||
34 | <item>const</item> | 33 | <item>const</item> | ||
35 | <item>delete</item> | 34 | <item>delete</item> | ||
36 | <item>function</item> | 35 | <item>function</item> | ||
37 | <item>in</item> | 36 | <item>in</item> | ||
38 | <item>instanceof</item> | 37 | <item>instanceof</item> | ||
39 | <item>new</item> | 38 | <item>new</item> | ||
39 | <item>of</item> | ||||
40 | <item>this</item> | 40 | <item>this</item> | ||
41 | <item>typeof</item> | 41 | <item>typeof</item> | ||
42 | <item>var</item> | 42 | <item>var</item> | ||
43 | <item>void</item> | 43 | <item>void</item> | ||
44 | </list> | 44 | </list> | ||
45 | <list name="reserved"> | 45 | <list name="reserved"> | ||
46 | <item>async</item> | ||||
46 | <item>class</item> | 47 | <item>class</item> | ||
47 | <item>enum</item> | 48 | <item>enum</item> | ||
48 | <item>extends</item> | 49 | <item>extends</item> | ||
49 | <item>super</item> | 50 | <item>super</item> | ||
50 | 51 | | |||
51 | <!-- The following keywords are reserved only in strict-mode --> | 52 | <!-- The following keywords are reserved only in strict-mode --> | ||
53 | <item>arguments</item> | ||||
52 | <item>implements</item> | 54 | <item>implements</item> | ||
53 | <item>interface</item> | 55 | <item>interface</item> | ||
54 | <item>let</item> | 56 | <item>let</item> | ||
55 | <item>private</item> | 57 | <item>private</item> | ||
56 | <item>protected</item> | 58 | <item>protected</item> | ||
57 | <item>public</item> | 59 | <item>public</item> | ||
58 | <item>static</item> | 60 | <item>static</item> | ||
59 | <item>yield</item> | 61 | <item>yield</item> | ||
Show All 12 Lines | 71 | <list name="primitives"> | |||
72 | <item>false</item> | 74 | <item>false</item> | ||
73 | <item>null</item> | 75 | <item>null</item> | ||
74 | <item>true</item> | 76 | <item>true</item> | ||
75 | <item>undefined</item> | 77 | <item>undefined</item> | ||
76 | </list> | 78 | </list> | ||
77 | <contexts> | 79 | <contexts> | ||
78 | 80 | | |||
79 | <!-- Shebang: ("#!") Detect shebang and fallthrough to Normal --> | 81 | <!-- Shebang: ("#!") Detect shebang and fallthrough to Normal --> | ||
80 | <!-- Based on the similar clause from prolog.xml, which notes the following BUG: | 82 | <!-- Based on the similar clause from prolog.xml. | ||
81 | If the file starts with whitespace and a shebang on a line other than the first line, | 83 | This uses "lineEmptyContext" & "lineEndContext" to force the highlight only on the first line. | ||
82 | this rule will still match it as a shebang, even tough the shebang is only valid on | | |||
83 | the very first line. | | |||
84 | --> | 84 | --> | ||
85 | <context name="Shebang" lineEndContext="Normal" attribute="Normal Text" fallthrough="true" fallthroughContext="Normal" > | 85 | <context name="Shebang" attribute="Normal Text" lineEndContext="Normal" lineEmptyContext="Normal" fallthrough="true" fallthroughContext="Normal" > | ||
86 | <Detect2Chars column="0" char="#" char1="!" context="Shebang Line" attribute="Comment" /> | 86 | <Detect2Chars column="0" char="#" char1="!" context="Shebang Line" attribute="Comment" /> | ||
87 | </context> | 87 | </context> | ||
88 | <context name="Shebang Line" attribute="Comment" lineEndContext="#pop!Normal"> | 88 | <context name="Shebang Line" attribute="Comment" lineEndContext="#pop!Normal"> | ||
89 | </context> | 89 | </context> | ||
90 | 90 | | |||
91 | <context attribute="Normal Text" lineEndContext="#stay" name="Normal"> | 91 | <context attribute="Normal Text" lineEndContext="#stay" name="Normal"> | ||
92 | <DetectSpaces/> | 92 | <DetectSpaces/> | ||
93 | <StringDetect attribute="Region Marker" context="region_marker" String="//BEGIN" beginRegion="Region1" /> | 93 | <StringDetect attribute="Region Marker" context="region_marker" String="//BEGIN" beginRegion="Region1" /> | ||
Show All 9 Lines | |||||
103 | <AnyChar context="NoRegExp" String="])" /> | 103 | <AnyChar context="NoRegExp" String="])" /> | ||
104 | 104 | | |||
105 | <keyword attribute="ControlFlow" String="controlflow" /> | 105 | <keyword attribute="ControlFlow" String="controlflow" /> | ||
106 | <keyword attribute="Keyword" String="keywords" /> | 106 | <keyword attribute="Keyword" String="keywords" /> | ||
107 | <keyword attribute="Reserved" String="reserved" /> | 107 | <keyword attribute="Reserved" String="reserved" /> | ||
108 | <keyword attribute="Keyword" context="NoRegExp" String="primitives" /> | 108 | <keyword attribute="Keyword" context="NoRegExp" String="primitives" /> | ||
109 | <keyword attribute="Module" String="module" /> | 109 | <keyword attribute="Module" String="module" /> | ||
110 | 110 | | |||
111 | <DetectChar attribute="Template" context="Template" char="`" /> | 111 | <IncludeRules context="FindStrings" /> | ||
112 | <StringDetect attribute="Template" context="RawTemplate" String="String.raw`" /> | | |||
113 | 112 | | |||
114 | <!--DetectIdentifier--> | 113 | <!--DetectIdentifier--> | ||
115 | <RegExpr attribute="Objects" context="Object Member" String="&identifier;(?=\s*\.)" /> | 114 | <RegExpr attribute="Objects" context="Object Member" String="&identifier;(?=\s*\.)" /> | ||
116 | <!--DetectIdentifier--> | 115 | <!--DetectIdentifier--> | ||
117 | <RegExpr attribute="Object Member" context="NoRegExp" String="&identifier;(?=\s*\()" /> | 116 | <RegExpr attribute="Object Member" context="NoRegExp" String="&identifier;(?=\s*\()" /> | ||
118 | <DetectChar context="Object Member" char="." /> | 117 | <DetectChar context="Object Member" char="." /> | ||
119 | <!--DetectIdentifier--> | 118 | <!--DetectIdentifier--> | ||
120 | <!-- Do not start RegExp after non-ASCII characters (see bug #393633) --> | 119 | <!-- Do not start RegExp after non-ASCII characters (see bug #393633) --> | ||
121 | <RegExpr context="NoRegExp" String="&identifier;" /> | 120 | <RegExpr context="NoRegExp" String="&identifier;" /> | ||
122 | <RegExpr context="NoRegExp" String="[a-zA-Z_$][\w$]*" /> | 121 | <RegExpr context="NoRegExp" String="[a-zA-Z_$][\w$]*" /> | ||
123 | 122 | | |||
124 | <DetectChar attribute="String" context="String" char=""" /> | 123 | <IncludeRules context="FindComments" /> | ||
125 | <DetectChar attribute="String" context="String SQ" char="'" /> | | |||
126 | | ||||
127 | <IncludeRules context="##Doxygen" /> | | |||
128 | <Detect2Chars attribute="Comment" context="Comment" char="/" char1="/" /> | | |||
129 | <Detect2Chars attribute="Comment" context="Multi/inline Comment" char="/" char1="*" beginRegion="Comment" /> | | |||
130 | 124 | | |||
131 | <!-- E4X extension (=xml inside JavaScript), see bug #373713 --> | 125 | <!-- E4X extension (=xml inside JavaScript), see bug #373713 --> | ||
132 | <Detect2Chars attribute="Normal Text" context="NoRegExp" char="<" char1="/" /> | 126 | <Detect2Chars attribute="Normal Text" context="NoRegExp" char="<" char1="/" /> | ||
133 | <Detect2Chars attribute="Normal Text" context="NoRegExp" char="/" char1=">" /> | 127 | <Detect2Chars attribute="Normal Text" context="NoRegExp" char="/" char1=">" /> | ||
134 | <DetectChar attribute="Regular Expression" context="(regex caret first check)" char="/" /> | 128 | <DetectChar attribute="Regular Expression" context="(regex caret first check)" char="/" /> | ||
135 | 129 | | |||
136 | <DetectChar attribute="Symbol" context="Object" char="{" beginRegion="Brace" /> | 130 | <DetectChar attribute="Symbol" context="Object" char="{" beginRegion="Brace" /> | ||
137 | <DetectChar attribute="Symbol" context="Conditional Expression" char="?" /> | 131 | <DetectChar attribute="Symbol" context="Conditional Expression" char="?" /> | ||
138 | 132 | | |||
133 | <Detect2Chars context="#stay" attribute="Special Operators" char="=" char1=">" /> | ||||
139 | <AnyChar attribute="Symbol" String=":!%&+,-/.*<=>?|~^;" /> | 134 | <AnyChar attribute="Symbol" String=":!%&+,-/.*<=>?|~^;" /> | ||
140 | </context> | 135 | </context> | ||
141 | 136 | | |||
142 | <context attribute="Normal Text" lineEndContext="#pop" fallthrough="true" fallthroughContext="#pop" name="Object Member"> | 137 | <context attribute="Normal Text" lineEndContext="#pop" fallthrough="true" fallthroughContext="#pop" name="Object Member"> | ||
143 | <DetectChar context="#stay" char="." /> | 138 | <DetectChar context="#stay" char="." /> | ||
144 | <!--DetectIdentifier--> | 139 | <!--DetectIdentifier--> | ||
145 | <RegExpr attribute="Objects" context="#stay" String="&identifier;(?=\s*\.)" /> | 140 | <RegExpr attribute="Objects" context="#stay" String="&identifier;(?=\s*\.)" /> | ||
146 | <!--DetectIdentifier--> | 141 | <!--DetectIdentifier--> | ||
Show All 11 Lines | |||||
158 | <context attribute="Normal Text" lineEndContext="#stay" name="Conditional Expression"> | 153 | <context attribute="Normal Text" lineEndContext="#stay" name="Conditional Expression"> | ||
159 | <DetectChar context="#pop" char=":" /> | 154 | <DetectChar context="#pop" char=":" /> | ||
160 | <IncludeRules context="Normal" /> | 155 | <IncludeRules context="Normal" /> | ||
161 | </context> | 156 | </context> | ||
162 | 157 | | |||
163 | <context attribute="Normal Text" lineEndContext="#stay" name="Object"> | 158 | <context attribute="Normal Text" lineEndContext="#stay" name="Object"> | ||
164 | <!-- Mostly required for define: in switch blocks --> | 159 | <!-- Mostly required for define: in switch blocks --> | ||
165 | <keyword attribute="Keyword" String="keywords" /> | 160 | <keyword attribute="Keyword" String="keywords" /> | ||
161 | <RegExpr attribute="ControlFlow" String="\bdefault(?=\s*:)" /> | ||||
166 | <!--DetectIdentifier--> | 162 | <!--DetectIdentifier--> | ||
167 | <RegExpr attribute="JSON" String="&identifier;\s*(?=:)" /> | 163 | <RegExpr attribute="JSON" String="&identifier;\s*(?=:)" /> | ||
168 | <DetectChar attribute="Symbol" char="}" endRegion="Brace" context="#pop" /> | 164 | <DetectChar attribute="Symbol" char="}" endRegion="Brace" context="#pop" /> | ||
169 | <IncludeRules context="Normal" /> | 165 | <IncludeRules context="Normal" /> | ||
170 | </context> | 166 | </context> | ||
171 | 167 | | |||
168 | <context name="FindStrings" attribute="Normal Text" lineEndContext="#stay"> | ||||
169 | <DetectChar attribute="Template" context="Template" char="`" /> | ||||
170 | <StringDetect attribute="Template" context="RawTemplate" String="String.raw`" /> | ||||
171 | | ||||
172 | <DetectChar attribute="String" context="String" char=""" /> | ||||
173 | <DetectChar attribute="String" context="String SQ" char="'" /> | ||||
174 | </context> | ||||
175 | | ||||
172 | <context attribute="String" lineEndContext="#pop" name="String"> | 176 | <context attribute="String" lineEndContext="#pop" name="String"> | ||
173 | <IncludeRules context="Escape" /> | 177 | <IncludeRules context="Escape" /> | ||
174 | <DetectChar attribute="String" context="#pop" char=""" /> | 178 | <DetectChar attribute="String" context="#pop" char=""" /> | ||
175 | </context> | 179 | </context> | ||
176 | <context attribute="String" lineEndContext="#pop" name="String SQ"> | 180 | <context attribute="String" lineEndContext="#pop" name="String SQ"> | ||
177 | <IncludeRules context="Escape" /> | 181 | <IncludeRules context="Escape" /> | ||
178 | <DetectChar attribute="String" context="#pop" char="'" /> | 182 | <DetectChar attribute="String" context="#pop" char="'" /> | ||
179 | </context> | 183 | </context> | ||
Show All 19 Lines | |||||
199 | <context attribute="Template" lineEndContext="#stay" name="RawTemplate"> | 203 | <context attribute="Template" lineEndContext="#stay" name="RawTemplate"> | ||
200 | <DetectChar attribute="Template" context="#pop" char="`" /> | 204 | <DetectChar attribute="Template" context="#pop" char="`" /> | ||
201 | </context> | 205 | </context> | ||
202 | <context name="Substitution" attribute="Normal Text" lineEndContext="#stay"> | 206 | <context name="Substitution" attribute="Normal Text" lineEndContext="#stay"> | ||
203 | <DetectChar attribute="Substitution" char="}" context="#pop"/> | 207 | <DetectChar attribute="Substitution" char="}" context="#pop"/> | ||
204 | <IncludeRules context="Normal"/> | 208 | <IncludeRules context="Normal"/> | ||
205 | </context> | 209 | </context> | ||
206 | 210 | | |||
211 | <context name="FindComments" attribute="Normal Text" lineEndContext="#stay"> | ||||
212 | <IncludeRules context="##Doxygen" /> | ||||
213 | <Detect2Chars attribute="Comment" context="Comment" char="/" char1="/" /> | ||||
214 | <Detect2Chars attribute="Comment" context="Multi/inline Comment" char="/" char1="*" beginRegion="Comment" /> | ||||
215 | </context> | ||||
207 | <context attribute="Comment" lineEndContext="#pop" name="Comment"> | 216 | <context attribute="Comment" lineEndContext="#pop" name="Comment"> | ||
208 | <IncludeRules context="##Alerts" /> | 217 | <IncludeRules context="##Alerts" /> | ||
209 | <IncludeRules context="##Modelines" /> | 218 | <IncludeRules context="##Modelines" /> | ||
210 | </context> | 219 | </context> | ||
211 | <context attribute="Comment" lineEndContext="#stay" name="Multi/inline Comment"> | 220 | <context attribute="Comment" lineEndContext="#stay" name="Multi/inline Comment"> | ||
212 | <IncludeRules context="##Alerts" /> | 221 | <IncludeRules context="##Alerts" /> | ||
213 | <IncludeRules context="##Modelines" /> | 222 | <IncludeRules context="##Modelines" /> | ||
214 | <Detect2Chars attribute="Comment" context="#pop" char="*" char1="/" endRegion="Comment" /> | 223 | <Detect2Chars attribute="Comment" context="#pop" char="*" char1="/" endRegion="Comment" /> | ||
Show All 29 Lines | |||||
244 | <itemDatas> | 253 | <itemDatas> | ||
245 | <itemData name="Normal Text" defStyleNum="dsNormal" spellChecking="false" /> | 254 | <itemData name="Normal Text" defStyleNum="dsNormal" spellChecking="false" /> | ||
246 | <itemData name="Keyword" defStyleNum="dsKeyword" spellChecking="false" /> | 255 | <itemData name="Keyword" defStyleNum="dsKeyword" spellChecking="false" /> | ||
247 | <itemData name="ControlFlow" defStyleNum="dsControlFlow" spellChecking="false" /> | 256 | <itemData name="ControlFlow" defStyleNum="dsControlFlow" spellChecking="false" /> | ||
248 | <itemData name="Reserved" defStyleNum="dsKeyword" italic="true" spellChecking="false" /> | 257 | <itemData name="Reserved" defStyleNum="dsKeyword" italic="true" spellChecking="false" /> | ||
249 | <itemData name="Module" defStyleNum="dsImport" spellChecking="false" /> | 258 | <itemData name="Module" defStyleNum="dsImport" spellChecking="false" /> | ||
250 | <itemData name="Objects" defStyleNum="dsVariable" spellChecking="false" /> | 259 | <itemData name="Objects" defStyleNum="dsVariable" spellChecking="false" /> | ||
251 | <itemData name="Object Member" defStyleNum="dsAttribute" spellChecking="false" /> | 260 | <itemData name="Object Member" defStyleNum="dsAttribute" spellChecking="false" /> | ||
261 | <itemData name="Special Operators" defStyleNum="dsKeyword" spellChecking="false" /> | ||||
252 | 262 | | |||
253 | <itemData name="Decimal" defStyleNum="dsDecVal" spellChecking="false" /> | 263 | <itemData name="Decimal" defStyleNum="dsDecVal" spellChecking="false" /> | ||
254 | <itemData name="Octal" defStyleNum="dsBaseN" spellChecking="false" /> | 264 | <itemData name="Octal" defStyleNum="dsBaseN" spellChecking="false" /> | ||
255 | <itemData name="Hex" defStyleNum="dsBaseN" spellChecking="false" /> | 265 | <itemData name="Hex" defStyleNum="dsBaseN" spellChecking="false" /> | ||
256 | <itemData name="Binary" defStyleNum="dsBaseN" spellChecking="false" /> | 266 | <itemData name="Binary" defStyleNum="dsBaseN" spellChecking="false" /> | ||
257 | <itemData name="Float" defStyleNum="dsFloat" spellChecking="false" /> | 267 | <itemData name="Float" defStyleNum="dsFloat" spellChecking="false" /> | ||
258 | <itemData name="Escape" defStyleNum="dsSpecialChar" spellChecking="false" /> | 268 | <itemData name="Escape" defStyleNum="dsSpecialChar" spellChecking="false" /> | ||
259 | <itemData name="Reserved Char. Escape" defStyleNum="dsSpecialChar" bold="1" spellChecking="false" /> | 269 | <itemData name="Reserved Char. Escape" defStyleNum="dsSpecialChar" bold="1" spellChecking="false" /> | ||
Show All 24 Lines |