about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/etc/kate/rust.xml74
1 files changed, 62 insertions, 12 deletions
diff --git a/src/etc/kate/rust.xml b/src/etc/kate/rust.xml
index 16a205ddc16..0359a56f7c1 100644
--- a/src/etc/kate/rust.xml
+++ b/src/etc/kate/rust.xml
@@ -1,6 +1,13 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE language SYSTEM "language.dtd">
-<language name="Rust" version="0.4.0" kateversion="2.4" section="Sources" extensions="*.rs;*.rc" mimetype="text/x-rust" priority="15">
+<!DOCTYPE language SYSTEM "language.dtd"
+[
+	<!-- TODO: Kate's regex engine has very limited support for
+	predefined char classes, so making rustIdent consistent with actual
+	Rust identifiers will be a bit difficult -->
+	<!ENTITY rustIdent "[a-zA-Z_][a-zA-Z_0-9]*">
+	<!ENTITY rustIntSuf "([iu](8|16|32|64)?)?">
+]>
+<language name="Rust" version="0.6" kateversion="2.4" section="Sources" extensions="*.rs;*.rc" mimetype="text/x-rust" priority="15">
 <highlighting>
 	<list name="fn">
 		<item> fn </item>
@@ -18,9 +25,7 @@
 		<item> drop </item>
 		<item> else </item>
 		<item> enum </item>
-		<item> export </item>
 		<item> extern </item>
-		<item> fail </item>
 		<item> for </item>
 		<item> if </item>
 		<item> impl </item>
@@ -29,7 +34,6 @@
 		<item> loop </item>
 		<item> match </item>
 		<item> mod </item>
-		<item> move </item>
 		<item> mut </item>
 		<item> priv </item>
 		<item> pub </item>
@@ -43,6 +47,29 @@
 		<item> use </item>
 		<item> while </item>
 	</list>
+	<list name="traits">
+		<item> Const </item>
+		<item> Copy </item>
+		<item> Send </item>
+		<item> Owned </item>
+		<item> Eq </item>
+		<item> Ord </item>
+		<item> Num </item>
+		<item> Ptr </item>
+		<item> Drop </item>
+		<item> Add </item>
+		<item> Sub </item>
+		<item> Mul </item>
+		<item> Div </item>
+		<item> Modulo </item>
+		<item> Neg </item>
+		<item> BitAnd </item>
+		<item> BitOr </item>
+		<item> BitXor </item>
+		<item> Shl </item>
+		<item> Shr </item>
+		<item> Index </item>
+	</list>
 	<list name="types">
 		<item> bool </item>
 		<item> int </item>
@@ -63,6 +90,7 @@
 		<item> Either </item>
 		<item> Option </item>
 		<item> Result </item>
+		<item> Self </item>
 	</list>
 	<list name="ctypes">
 		<item> c_float </item>
@@ -164,23 +192,33 @@
 			<keyword String="type" attribute="Keyword" context="Type"/>
 			<keyword String="keywords" attribute="Keyword" context="#stay"/>
 			<keyword String="types" attribute="Type" context="#stay"/>
+			<keyword String="traits" attribute="Trait" context="#stay"/>
 			<keyword String="ctypes" attribute="CType" context="#stay"/>
 			<keyword String="self" attribute="Self" context="#stay"/>
 			<keyword String="constants" attribute="Constant" context="#stay"/>
 			<keyword String="cconstants" attribute="CConstant" context="#stay"/>
 			<Detect2Chars char="/" char1="/" attribute="Comment" context="Commentar 1"/>
 			<Detect2Chars char="/" char1="*" attribute="Comment" context="Commentar 2" beginRegion="Comment"/>
-			<RegExpr String="0x[0-9a-fA-F_]+(u8|u16|u32|u64|i8|i16|i32|i64|u|i)?" attribute="Number" context="#stay"/>
-			<RegExpr String="0b[0-1_]+(u8|u16|u32|u64|i8|i16|i32|i64|u|i)?" attribute="Number" context="#stay"/>
+			<RegExpr String="0x[0-9a-fA-F_]+&rustIntSuf;" attribute="Number" context="#stay"/>
+			<RegExpr String="0b[0-1_]+&rustIntSuf;" attribute="Number" context="#stay"/>
 			<RegExpr String="[0-9][0-9_]*\.[0-9_]*([eE][+-]?[0-9_]+)?(f32|f64|f)?" attribute="Number" context="#stay"/>
-			<RegExpr String="[0-9][0-9_]*(u8|u16|u32|u64|i8|i16|i32|i64|u|i)?" attribute="Number" context="#stay"/>
-			<RegExpr String="[a-zA-Z_][a-zA-Z0-9_]*::" attribute="Scope"/>
+			<RegExpr String="[0-9][0-9_]*&rustIntSuf;" attribute="Number" context="#stay"/>
+			<Detect2Chars char="#" char1="[" attribute="Attribute" context="Attribute" beginRegion="Attribute"/>
+			<RegExpr String="&rustIdent;::" attribute="Scope"/>
+			<RegExpr String="&rustIdent;!" attribute="Macro"/>
+			<RegExpr String="&apos;&rustIdent;(?!&apos;)" attribute="Lifetime"/>
 			<DetectChar char="{" attribute="Symbol" context="#stay" beginRegion="Brace" />
 			<DetectChar char="}" attribute="Symbol" context="#stay" endRegion="Brace" />
 			<DetectChar char="&quot;" attribute="String" context="String"/>
 			<DetectChar char="&apos;" attribute="Character" context="Character"/>
+			<DetectChar char="[" attribute="Symbol" context="#stay" beginRegion="Bracket" />
+			<DetectChar char="]" attribute="Symbol" context="#stay" endRegion="Bracket" />
 			<DetectIdentifier/>
 		</context>
+		<context attribute="Attribute" lineEndContext="#stay" name="Attribute">
+			<DetectChar char="]" attribute="Attribute" context="#pop" endRegion="Attribute"/>
+			<IncludeRules context="Normal"/>
+		</context>
 		<context attribute="Definition" lineEndContext="#stay" name="Function">
 			<DetectSpaces/>
 			<DetectChar char="(" attribute="Normal Text" context="#pop"/>
@@ -193,13 +231,20 @@
 		</context>
 		<context attribute="String" lineEndContext="#stay" name="String">
 			<LineContinue attribute="String" context="#stay"/>
-			<HlCStringChar attribute="String Char" context="#stay"/>
+			<DetectChar char="\" attribute="CharEscape" context="CharEscape"/>
 			<DetectChar attribute="String" context="#pop" char="&quot;"/>
 		</context>
 		<context attribute="Character" lineEndContext="#pop" name="Character">
-			<HlCStringChar attribute="Character" context="#stay"/>
+			<DetectChar char="\" attribute="CharEscape" context="CharEscape"/>
 			<DetectChar attribute="Character" context="#pop" char="&apos;"/>
 		</context>
+		<context attribute="CharEscape" lineEndContext="#pop" name="CharEscape">
+			<AnyChar String="nrt\&apos;&quot;" attribute="CharEscape" context="#pop"/>
+			<RegExpr String="x[0-9a-fA-F]{2}" attribute="CharEscape" context="#pop"/>
+			<RegExpr String="u[0-9a-fA-F]{4}" attribute="CharEscape" context="#pop"/>
+			<RegExpr String="U[0-9a-fA-F]{8}" attribute="CharEscape" context="#pop"/>
+			<RegExpr String="." attribute="Error" context="#pop"/>
+		</context>
 		<context attribute="Comment" lineEndContext="#pop" name="Commentar 1"/>
 		<context attribute="Comment" lineEndContext="#stay" name="Commentar 2">
 			<DetectSpaces/>
@@ -211,6 +256,7 @@
 		<itemData name="Keyword"      defStyleNum="dsKeyword" color="#770088" bold="1"/>
 		<itemData name="Self"         defStyleNum="dsKeyword" color="#FF0000" bold="1"/>
 		<itemData name="Type"         defStyleNum="dsKeyword" color="#4e9a06" bold="1"/>
+		<itemData name="Trait"        defStyleNum="dsKeyword" color="#4e9a06" bold="1"/>
 		<itemData name="CType"        defStyleNum="dsNormal" color="#4e9a06"/>
 		<itemData name="Constant"     defStyleNum="dsKeyword" color="#116644"/>
 		<itemData name="CConstant"    defStyleNum="dsNormal" color="#116644"/>
@@ -219,8 +265,12 @@
 		<itemData name="Scope"        defStyleNum="dsNormal" color="#0055AA"/>
 		<itemData name="Number"       defStyleNum="dsDecVal" color="#116644"/>
 		<itemData name="String"       defStyleNum="dsString" color="#FF0000"/>
-		<itemData name="String Char"  defStyleNum="dsChar" color="#FF0000"/>
+		<itemData name="CharEscape"   defStyleNum="dsChar" color="#FF0000" bold="1"/>
 		<itemData name="Character"    defStyleNum="dsChar" color="#FF0000"/>
+		<itemData name="Macro"        defStyleNum="dsOthers"/>
+		<itemData name="Attribute"    defStyleNum="dsOthers"/>
+		<itemData name="Lifetime"     defStyleNum="dsOthers" bold="1"/>
+		<itemData name="Error"        defStyleNum="dsError"/>
 	</itemDatas>
 </highlighting>
 <general>