]> git.xonotic.org Git - xonotic/gmqcc.git/blob - syntax/gtksourceview/qc.lang
Remove fs.c ansi.c and PORTING guide
[xonotic/gmqcc.git] / syntax / gtksourceview / qc.lang
1 <?xml version="1.0" encoding="UTF-8"?>
2 <language id="qc" _name="QuakeC" version="1.0" _section="Sources">
3   <metadata>
4     <property name="globs">*.qc</property>
5     <property name="line-comment-start">//</property>
6     <property name="block-comment-start">/*</property>
7     <property name="block-comment-end">*/</property>
8   </metadata>
9
10   <styles>
11     <style id="comment"           _name="Comment"               map-to="def:comment"/>
12     <style id="string"            _name="String"                map-to="def:string"/>
13     <style id="preprocessor"      _name="Preprocessor"          map-to="def:preprocessor"/>
14     <style id="common-defines"    _name="Common Defines"        map-to="def:special-constant"/>
15     <style id="included-file"     _name="Included File"         map-to="def:string"/>
16     <style id="keyword"           _name="Keyword"               map-to="def:keyword"/>
17     <style id="type"              _name="Data Type"             map-to="def:type"/>
18     <style id="escaped-character" _name="Escaped Character"     map-to="def:special-char"/>
19     <style id="floating-point"    _name="Floating point number" map-to="def:floating-point"/>
20     <style id="decimal"           _name="Decimal number"        map-to="def:decimal"/>
21     <style id="hexadecimal"       _name="Hexadecimal number"    map-to="def:base-n-integer"/>
22     <style id="boolean"           _name="Boolean value"         map-to="def:boolean"/>
23   </styles>
24
25   <definitions>
26
27     <!--regexs-->
28     <define-regex id="preproc-start">^\s*#\s*</define-regex>
29     <define-regex id="escaped-character" extended="true">
30       \\(                   # leading backslash
31       [\\\"\'nrbtfav\?] |   # escaped character
32       [0-7]{1,3} |          # one, two, or three octal digits
33       x[0-9A-Fa-f]+         # 'x' followed by hex digits
34       )
35     </define-regex>
36
37     <!-- Preprocessor -->
38     <context id="if0-comment" style-ref="comment">
39       <start>\%{preproc-start}if\b\s*0\b</start>
40       <end>\%{preproc-start}(endif|else|elif)\b</end>
41       <include>
42         <context id="if-in-if0">
43           <start>\%{preproc-start}if(n?def)?\b</start>
44           <end>\%{preproc-start}endif\b</end>
45           <include>
46             <context ref="if-in-if0"/>
47             <context ref="def:in-comment"/>
48           </include>
49         </context>
50         <context ref="def:in-comment"/>
51       </include>
52     </context>
53     <context id="include" style-ref="preprocessor">
54       <match extended="true">
55         \%{preproc-start}
56         (include|import)\s*
57         (".*?"|&lt;.*&gt;)
58       </match>
59       <include>
60         <context id="included-file" sub-pattern="2" style-ref="included-file"/>
61       </include>
62     </context>
63     <context id="preprocessor" style-ref="preprocessor" end-at-line-end="true">
64       <start extended="true">
65         \%{preproc-start}
66         (define|undef|error|pragma|ident|if(n?def)?|else|elif|endif|line|warning)
67         \b
68       </start>
69       <include>
70         <context ref="def:line-continue" ignore-style="true"/>
71         <context ref="string" ignore-style="true"/>
72         <context ref="def:qc-like-comment"/>
73         <context ref="def:qc-like-comment-multiline"/>
74       </include>
75     </context>
76
77     <context id="float" style-ref="floating-point">
78       <match extended="true">
79         (?&lt;![\w\.])
80         ((\.[0-9]+ | [0-9]+\.[0-9]*) ([Ee][+-]?[0-9]*)? |
81          ([0-9]+[Ee][+-]?[0-9]*))
82         [fFlL]?
83         (?![\w\.])
84       </match>
85     </context>
86
87     <context id="hexadecimal" style-ref="hexadecimal">
88       <match extended="true">
89         (?&lt;![\w\.])
90         0[xX][a-fA-F0-9]+[uUlL]*
91         (?![\w\.])
92       </match>
93     </context>
94
95     <context id="invalid-hexadecimal" style-ref="error">
96       <match extended="true">
97         (?&lt;![\w\.])
98         0[xX][a-fA-F0-9]*[g-zG-Z][a-zA-Z0-9]*[uUlL]*
99         (?![\w\.])
100       </match>
101     </context>
102
103     <context id="decimal" style-ref="decimal">
104       <match extended="true">
105         (?&lt;![\w\.])
106         (0|[1-9][0-9]*)[uUlL]*
107         (?![\w\.])
108       </match>
109     </context>
110
111     <context id="keywords" style-ref="keyword">
112       <keyword>break</keyword>
113       <keyword>case</keyword>
114       <keyword>continue</keyword>
115       <keyword>default</keyword>
116       <keyword>do</keyword>
117       <keyword>else</keyword>
118       <keyword>enum</keyword>
119       <keyword>for</keyword>
120       <keyword>goto</keyword>
121       <keyword>if</keyword>
122       <keyword>return</keyword>
123       <keyword>switch</keyword>
124       <keyword>typedef</keyword>
125       <keyword>while</keyword>
126       <keyword>nil</keyword>
127     </context>
128
129     <context id="types" style-ref="type">
130       <keyword>bool</keyword>
131       <keyword>string</keyword>
132       <keyword>vector</keyword>
133       <keyword>float</keyword>
134       <keyword>void</keyword>
135     </context>
136
137     <context id="boolean" style-ref="boolean">
138       <keyword>true</keyword>
139       <keyword>false</keyword>
140     </context>
141
142     <context id="common-defines" style-ref="common-defines">
143       <keyword>__LINE__</keyword>
144       <keyword>__FILE__</keyword>
145       <keyword>__TIME__</keyword>
146       <keyword>__RANDOM__</keyword>
147       <keyword>__RANDOM_LAST__</keyword>
148       <keyword>__COUNTER__</keyword>
149       <keyword>__COUNTER_LAST__</keyword>
150       <keyword>__DATE__</keyword>
151     </context>
152
153     <context id="qc" class="no-spell-check">
154       <include>
155         <context ref="def:qc-like-comment"/>
156         <context ref="def:qc-like-comment-multiline"/>
157         <context ref="def:qc-like-close-comment-outside-comment"/>
158         <context ref="if0-comment"/>
159         <context ref="include"/>
160         <context ref="preprocessor"/>
161         <context ref="string"/>
162         <context ref="float"/>
163         <context ref="hexadecimal"/>
164         <context ref="invalid-hexadecimal"/>
165         <context ref="decimal"/>
166         <context ref="keywords"/>
167         <context ref="types"/>
168         <context ref="boolean"/>
169         <context ref="common-defines"/>
170       </include>
171     </context>
172   </definitions>
173 </language>