1<?xml version="1.0" encoding="UTF-8"?>
2<!--
3
4 This file is part of GtkSourceView
5
6 Author: Ian Liu Rodrigues <ian.liu88@gmail.com> (modified from java.lang)
7 Copyright (C) 2003 Gustavo Giráldez <gustavo.giraldez@gmx.net>
8 Copyright (C) 2006 Jeff Walden <jwalden@mit.edu>
9 Copyright (C) 2012 Sapphire Becker <guess@logicplace.com>
10 Copyright (C) 2016 Wolfang Torres <wolfang.torres@gmail.com>
11
12 GtkSourceView is free software; you can redistribute it and/or
13 modify it under the terms of the GNU Lesser General Public
14 License as published by the Free Software Foundation; either
15 version 2.1 of the License, or (at your option) any later version.
16
17 GtkSourceView is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
20 Lesser General Public License for more details.
21
22 You should have received a copy of the GNU Lesser General Public License
23 along with this library; if not, see <http://www.gnu.org/licenses/>.
24
25-->
26
27<!--
28References:
29  https://en.wikipedia.org/wiki/Haxe
30  https://haxe.org/documentation/
31  https://haxe.org/manual/expression.html
32-->
33
34<language id="haxe" name="Haxe" version="2.0" _section="Source">
35
36  <metadata>
37
38    <property name="mimetypes">text/x-haxe</property>
39    <property name="globs">*.hx</property>
40    <property name="line-comment-start">//</property>
41    <property name="block-comment-start">/*</property>
42    <property name="block-comment-end">*/</property>
43  </metadata>
44
45
46  <styles>
47    <style id="comment"           name="Comment"           map-to="def:comment" />
48    <style id="external"          name="External"          map-to="def:preprocessor" />
49    <style id="preprocessor"      name="Preprocessor"      map-to="def:preprocessor" />
50    <style id="declaration"       name="Declaration"       map-to="def:type" />
51    <style id="storage-class"     name="Storage Class"     map-to="def:type" />
52    <style id="scope"             name="Scope"             map-to="def:type" />
53    <style id="keyword"           name="Keyword"           map-to="def:keyword" />
54    <style id="string"            name="String"            map-to="def:string" />
55    <style id="number"            name="Number"            map-to="def:decimal" />
56    <style id="boolean"           name="Boolean value"     map-to="def:boolean" />
57    <style id="null-value"        name="Null Value"        map-to="def:special-constant" />
58    <style id="type"              name="Data Type"         map-to="def:identifier" />
59    <style id="metadata"          name="Metadata"          map-to="def:constant" />
60    <style id="macro"             name="Macro"             map-to="def:preprocessor" />
61    <style id="error"             name="Error"             map-to="def:error" />
62    <style id="escaped-char"      name="Escaped Character" map-to="def:special-char" />
63    <style id="identifier-prefix" name="Identifier Prefix" map-to="def:warning" />
64  </styles>
65
66  <definitions>
67
68    <define-regex id="escaped-char" extended="true">\\(x?\d+|[\\\?\"\'nt])</define-regex>
69
70    <define-regex id="escaped-char-error" extended="true">\\[^\\\?\"\'ntx\d]</define-regex>
71
72    <context id="line-comment" style-ref="comment" end-at-line-end="true">
73      <start>//</start>
74      <include>
75        <context ref="def:in-line-comment" />
76      </include>
77    </context>
78
79    <context id="block-comment" style-ref="comment">
80      <start>/\*</start>
81      <end>\*/</end>
82      <include>
83        <context ref="def:in-comment" />
84      </include>
85    </context>
86
87    <context id="close-comment-outside-comment" style-ref="error">
88      <match>\*/(?!\*)</match>
89    </context>
90
91    <context id="escaped-char" style-ref="escaped-char">
92      <match>\%{escaped-char}</match>
93    </context>
94
95    <context id="escaped-char-error" style-ref="error">
96      <match>\%{escaped-char-error}</match>
97    </context>
98
99    <context id="externals" style-ref="external">
100      <keyword>import</keyword>
101      <keyword>package</keyword>
102      <keyword>extern</keyword>
103      <keyword>using</keyword>
104    </context>
105
106    <context id="preo-proc" style-ref="preprocessor">
107      <prefix>^\s*#\s*</prefix>
108      <keyword>if</keyword>
109      <keyword>else</keyword>
110      <keyword>elseif</keyword>
111      <keyword>end</keyword>
112    </context>
113
114    <context id="declarations" style-ref="declaration">
115      <keyword>class</keyword>
116      <keyword>enum</keyword>
117      <keyword>extends</keyword>
118      <keyword>function</keyword>
119      <keyword>implements</keyword>
120      <keyword>interface</keyword>
121      <keyword>typedef</keyword>
122      <keyword>var</keyword>
123      <keyword>macro</keyword>
124    </context>
125
126    <context id="primitive-types" style-ref="type">
127      <match>[A-Z][a-zA-Z0-9]*</match>
128    </context>
129
130    <context id="storage-class" style-ref="storage-class">
131      <keyword>static</keyword>
132      <keyword>inline</keyword>
133      <keyword>abstract</keyword>
134    </context>
135
136    <context id="scope" style-ref="scope">
137      <keyword>private</keyword>
138      <keyword>public</keyword>
139      <keyword>dynamic</keyword>
140      <keyword>override</keyword>
141    </context>
142
143    <context id="flow" style-ref="keyword">
144      <keyword>break</keyword>
145      <keyword>case</keyword>
146      <keyword>cast</keyword>
147      <keyword>catch</keyword>
148      <keyword>continue</keyword>
149      <keyword>default</keyword>
150      <keyword>do</keyword>
151      <keyword>else</keyword>
152      <keyword>for</keyword>
153      <keyword>if</keyword>
154      <keyword>in</keyword>
155      <keyword>return</keyword>
156      <keyword>switch</keyword>
157      <keyword>throw</keyword>
158      <keyword>try</keyword>
159      <keyword>untyped</keyword>
160      <keyword>while</keyword>
161    </context>
162
163    <context id="memory" style-ref="keyword">
164      <keyword>new</keyword>
165      <keyword>super</keyword>
166      <keyword>this</keyword>
167    </context>
168
169    <context id="string" style-ref="string">
170      <start>"</start>
171      <end>"</end>
172      <include>
173        <context ref="escaped-char" />
174        <context ref="escaped-char-error" />
175      </include>
176    </context>
177
178    <context id="string-2" style-ref="string">
179      <start>'</start>
180      <end>'</end>
181      <include>
182        <context ref="escaped-char" />
183        <context ref="escaped-char-error" />
184      </include>
185    </context>
186
187    <context id="numeric" style-ref="number">
188      <match extended="true">(\b([0-9]+|0[xX][0-9a-fA-F]+)[Ll]?\b| \b(([0-9]+[Ee][-]?[0-9]+| ([0-9]*\.[0-9]+|[0-9]+\.)([Ee][-]?[0-9]+)?)[fFdD]?| [0-9]+[FfDd]))</match>
189    </context>
190
191    <context id="boolean" style-ref="boolean">
192      <keyword>false</keyword>
193      <keyword>true</keyword>
194    </context>
195
196    <context id="null-value" style-ref="null-value">
197      <keyword>null</keyword>
198    </context>
199
200    <context id="metadata" style-ref="metadata">
201      <match>@\w+</match>
202    </context>
203
204    <context id="macro" style-ref="macro">
205      <match>@:\w+</match>
206    </context>
207
208    <context id="identifier-prefix" style-ref="identifier-prefix">
209      <match>_hx_\w+</match>
210    </context>
211
212    <context id="haxe">
213      <include>
214        <context ref="line-comment" />
215        <context ref="block-comment" />
216        <context ref="close-comment-outside-comment" />
217        <context ref="externals" />
218        <context ref="preo-proc" />
219        <context ref="declarations" />
220        <context ref="primitive-types" />
221        <context ref="storage-class" />
222        <context ref="scope" />
223        <context ref="flow" />
224        <context ref="memory" />
225        <context ref="string" />
226        <context ref="string-2" />
227        <context ref="numeric" />
228        <context ref="boolean" />
229        <context ref="null-value" />
230        <context ref="metadata" />
231        <context ref="macro" />
232        <context ref="identifier-prefix" />
233      </include>
234    </context>
235
236  </definitions>
237</language>
238