|
1 | 1 | <?xml version="1.0" encoding="UTF-8"?> |
2 | | -<!DOCTYPE language SYSTEM "language.dtd"> |
3 | | -<language name="Rust" version="0.4.0" kateversion="2.4" section="Sources" extensions="*.rs;*.rc" mimetype="text/x-rust" priority="15"> |
| 2 | +<!DOCTYPE language SYSTEM "language.dtd" |
| 3 | +[ |
| 4 | + <!-- TODO: Kate's regex engine has very limited support for |
| 5 | + predefined char classes, so making rustIdent consistent with actual |
| 6 | + Rust identifiers will be a bit difficult --> |
| 7 | + <!ENTITY rustIdent "[a-zA-Z_][a-zA-Z_0-9]*"> |
| 8 | + <!ENTITY rustIntSuf "([iu](8|16|32|64)?)?"> |
| 9 | +]> |
| 10 | +<language name="Rust" version="0.6" kateversion="2.4" section="Sources" extensions="*.rs;*.rc" mimetype="text/x-rust" priority="15"> |
4 | 11 | <highlighting> |
5 | 12 | <list name="fn"> |
6 | 13 | <item> fn </item> |
|
18 | 25 | <item> drop </item> |
19 | 26 | <item> else </item> |
20 | 27 | <item> enum </item> |
21 | | - <item> export </item> |
22 | 28 | <item> extern </item> |
23 | | - <item> fail </item> |
24 | 29 | <item> for </item> |
25 | 30 | <item> if </item> |
26 | 31 | <item> impl </item> |
|
29 | 34 | <item> loop </item> |
30 | 35 | <item> match </item> |
31 | 36 | <item> mod </item> |
32 | | - <item> move </item> |
33 | 37 | <item> mut </item> |
34 | 38 | <item> priv </item> |
35 | 39 | <item> pub </item> |
|
43 | 47 | <item> use </item> |
44 | 48 | <item> while </item> |
45 | 49 | </list> |
| 50 | + <list name="traits"> |
| 51 | + <item> Const </item> |
| 52 | + <item> Copy </item> |
| 53 | + <item> Send </item> |
| 54 | + <item> Owned </item> |
| 55 | + <item> Eq </item> |
| 56 | + <item> Ord </item> |
| 57 | + <item> Num </item> |
| 58 | + <item> Ptr </item> |
| 59 | + <item> Drop </item> |
| 60 | + <item> Add </item> |
| 61 | + <item> Sub </item> |
| 62 | + <item> Mul </item> |
| 63 | + <item> Div </item> |
| 64 | + <item> Modulo </item> |
| 65 | + <item> Neg </item> |
| 66 | + <item> BitAnd </item> |
| 67 | + <item> BitOr </item> |
| 68 | + <item> BitXor </item> |
| 69 | + <item> Shl </item> |
| 70 | + <item> Shr </item> |
| 71 | + <item> Index </item> |
| 72 | + </list> |
46 | 73 | <list name="types"> |
47 | 74 | <item> bool </item> |
48 | 75 | <item> int </item> |
|
63 | 90 | <item> Either </item> |
64 | 91 | <item> Option </item> |
65 | 92 | <item> Result </item> |
| 93 | + <item> Self </item> |
66 | 94 | </list> |
67 | 95 | <list name="ctypes"> |
68 | 96 | <item> c_float </item> |
|
164 | 192 | <keyword String="type" attribute="Keyword" context="Type"/> |
165 | 193 | <keyword String="keywords" attribute="Keyword" context="#stay"/> |
166 | 194 | <keyword String="types" attribute="Type" context="#stay"/> |
| 195 | + <keyword String="traits" attribute="Trait" context="#stay"/> |
167 | 196 | <keyword String="ctypes" attribute="CType" context="#stay"/> |
168 | 197 | <keyword String="self" attribute="Self" context="#stay"/> |
169 | 198 | <keyword String="constants" attribute="Constant" context="#stay"/> |
170 | 199 | <keyword String="cconstants" attribute="CConstant" context="#stay"/> |
171 | 200 | <Detect2Chars char="/" char1="/" attribute="Comment" context="Commentar 1"/> |
172 | 201 | <Detect2Chars char="/" char1="*" attribute="Comment" context="Commentar 2" beginRegion="Comment"/> |
173 | | - <RegExpr String="0x[0-9a-fA-F_]+(u8|u16|u32|u64|i8|i16|i32|i64|u|i)?" attribute="Number" context="#stay"/> |
174 | | - <RegExpr String="0b[0-1_]+(u8|u16|u32|u64|i8|i16|i32|i64|u|i)?" attribute="Number" context="#stay"/> |
| 202 | + <RegExpr String="0x[0-9a-fA-F_]+&rustIntSuf;" attribute="Number" context="#stay"/> |
| 203 | + <RegExpr String="0b[0-1_]+&rustIntSuf;" attribute="Number" context="#stay"/> |
175 | 204 | <RegExpr String="[0-9][0-9_]*\.[0-9_]*([eE][+-]?[0-9_]+)?(f32|f64|f)?" attribute="Number" context="#stay"/> |
176 | | - <RegExpr String="[0-9][0-9_]*(u8|u16|u32|u64|i8|i16|i32|i64|u|i)?" attribute="Number" context="#stay"/> |
177 | | - <RegExpr String="[a-zA-Z_][a-zA-Z0-9_]*::" attribute="Scope"/> |
| 205 | + <RegExpr String="[0-9][0-9_]*&rustIntSuf;" attribute="Number" context="#stay"/> |
| 206 | + <Detect2Chars char="#" char1="[" attribute="Attribute" context="Attribute" beginRegion="Attribute"/> |
| 207 | + <RegExpr String="&rustIdent;::" attribute="Scope"/> |
| 208 | + <RegExpr String="&rustIdent;!" attribute="Macro"/> |
| 209 | + <RegExpr String="'&rustIdent;(?!')" attribute="Lifetime"/> |
178 | 210 | <DetectChar char="{" attribute="Symbol" context="#stay" beginRegion="Brace" /> |
179 | 211 | <DetectChar char="}" attribute="Symbol" context="#stay" endRegion="Brace" /> |
180 | 212 | <DetectChar char=""" attribute="String" context="String"/> |
181 | 213 | <DetectChar char="'" attribute="Character" context="Character"/> |
| 214 | + <DetectChar char="[" attribute="Symbol" context="#stay" beginRegion="Bracket" /> |
| 215 | + <DetectChar char="]" attribute="Symbol" context="#stay" endRegion="Bracket" /> |
182 | 216 | <DetectIdentifier/> |
183 | 217 | </context> |
| 218 | + <context attribute="Attribute" lineEndContext="#stay" name="Attribute"> |
| 219 | + <DetectChar char="]" attribute="Attribute" context="#pop" endRegion="Attribute"/> |
| 220 | + <IncludeRules context="Normal"/> |
| 221 | + </context> |
184 | 222 | <context attribute="Definition" lineEndContext="#stay" name="Function"> |
185 | 223 | <DetectSpaces/> |
186 | 224 | <DetectChar char="(" attribute="Normal Text" context="#pop"/> |
|
193 | 231 | </context> |
194 | 232 | <context attribute="String" lineEndContext="#stay" name="String"> |
195 | 233 | <LineContinue attribute="String" context="#stay"/> |
196 | | - <HlCStringChar attribute="String Char" context="#stay"/> |
| 234 | + <DetectChar char="\" attribute="CharEscape" context="CharEscape"/> |
197 | 235 | <DetectChar attribute="String" context="#pop" char="""/> |
198 | 236 | </context> |
199 | 237 | <context attribute="Character" lineEndContext="#pop" name="Character"> |
200 | | - <HlCStringChar attribute="Character" context="#stay"/> |
| 238 | + <DetectChar char="\" attribute="CharEscape" context="CharEscape"/> |
201 | 239 | <DetectChar attribute="Character" context="#pop" char="'"/> |
202 | 240 | </context> |
| 241 | + <context attribute="CharEscape" lineEndContext="#pop" name="CharEscape"> |
| 242 | + <AnyChar String="nrt\'"" attribute="CharEscape" context="#pop"/> |
| 243 | + <RegExpr String="x[0-9a-fA-F]{2}" attribute="CharEscape" context="#pop"/> |
| 244 | + <RegExpr String="u[0-9a-fA-F]{4}" attribute="CharEscape" context="#pop"/> |
| 245 | + <RegExpr String="U[0-9a-fA-F]{8}" attribute="CharEscape" context="#pop"/> |
| 246 | + <RegExpr String="." attribute="Error" context="#pop"/> |
| 247 | + </context> |
203 | 248 | <context attribute="Comment" lineEndContext="#pop" name="Commentar 1"/> |
204 | 249 | <context attribute="Comment" lineEndContext="#stay" name="Commentar 2"> |
205 | 250 | <DetectSpaces/> |
|
211 | 256 | <itemData name="Keyword" defStyleNum="dsKeyword" color="#770088" bold="1"/> |
212 | 257 | <itemData name="Self" defStyleNum="dsKeyword" color="#FF0000" bold="1"/> |
213 | 258 | <itemData name="Type" defStyleNum="dsKeyword" color="#4e9a06" bold="1"/> |
| 259 | + <itemData name="Trait" defStyleNum="dsKeyword" color="#4e9a06" bold="1"/> |
214 | 260 | <itemData name="CType" defStyleNum="dsNormal" color="#4e9a06"/> |
215 | 261 | <itemData name="Constant" defStyleNum="dsKeyword" color="#116644"/> |
216 | 262 | <itemData name="CConstant" defStyleNum="dsNormal" color="#116644"/> |
|
219 | 265 | <itemData name="Scope" defStyleNum="dsNormal" color="#0055AA"/> |
220 | 266 | <itemData name="Number" defStyleNum="dsDecVal" color="#116644"/> |
221 | 267 | <itemData name="String" defStyleNum="dsString" color="#FF0000"/> |
222 | | - <itemData name="String Char" defStyleNum="dsChar" color="#FF0000"/> |
| 268 | + <itemData name="CharEscape" defStyleNum="dsChar" color="#FF0000" bold="1"/> |
223 | 269 | <itemData name="Character" defStyleNum="dsChar" color="#FF0000"/> |
| 270 | + <itemData name="Macro" defStyleNum="dsOthers"/> |
| 271 | + <itemData name="Attribute" defStyleNum="dsOthers"/> |
| 272 | + <itemData name="Lifetime" defStyleNum="dsOthers" bold="1"/> |
| 273 | + <itemData name="Error" defStyleNum="dsError"/> |
224 | 274 | </itemDatas> |
225 | 275 | </highlighting> |
226 | 276 | <general> |
|
0 commit comments