about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2013-07-14 21:58:19 -0700
committerbors <bors@rust-lang.org>2013-07-14 21:58:19 -0700
commitfd80291cdcd4e4fd2fd000a2cce5e65390682249 (patch)
treee1a9daef6d2633c0aa127105a1f1a4effceccc65
parentdb438ad786eec6faa15c0a464569fcf5c9ce1edc (diff)
parent9adad222a64063b698d82caa992482f0d9d1e5cc (diff)
downloadrust-fd80291cdcd4e4fd2fd000a2cce5e65390682249.tar.gz
rust-fd80291cdcd4e4fd2fd000a2cce5e65390682249.zip
auto merge of #7795 : sp3d/rust/master, r=z0w0
This should be pretty self-explanatory. The most important component is region/lifetime annotation highlighting, as previously they were interpreted as character literals and would ruin the rest of the line. The attribute regex is fairly crude, but it gets the job done and there's not much within attributes that would benefit from individual highlighting, so fancier handling didn't seem worth the trouble.

The ident regex was copied from the vim highlighter.
-rw-r--r--src/etc/gedit/share/gtksourceview-3.0/language-specs/rust.lang40
1 files changed, 32 insertions, 8 deletions
diff --git a/src/etc/gedit/share/gtksourceview-3.0/language-specs/rust.lang b/src/etc/gedit/share/gtksourceview-3.0/language-specs/rust.lang
index a413d0a9062..a6415beab36 100644
--- a/src/etc/gedit/share/gtksourceview-3.0/language-specs/rust.lang
+++ b/src/etc/gedit/share/gtksourceview-3.0/language-specs/rust.lang
@@ -19,8 +19,9 @@
     <style id="type" _name="Data Type" map-to="def:type"/>
     <style id="constant" _name="Constant" map-to="def:constant"/>
     <style id="identifier" _name="Identifier" map-to="def:identifier"/>
-    <style id="number" _name="Number" map-to="def:decimal"/>
+    <style id="number" _name="Number" map-to="def:number"/>
     <style id="scope" _name="Scope" map-to="def:preprocessor"/>
+    <style id="attribute" _name="Attribute" map-to="def:preprocessor"/>
   </styles>
 
   <definitions>
@@ -216,9 +217,19 @@
       </match>
     </context>
 
+    <define-regex id="ident" extended="true">
+      ([^[:cntrl:][:space:][:punct:][:digit:]]|_)([^[:cntrl:][:punct:][:space:]]|_)*
+    </define-regex>
+
     <context id="scope" style-ref="scope">
       <match extended="true">
-        [a-zA-Z_][a-zA-Z0-9_]*::
+        \%{ident}::
+      </match>
+    </context>
+
+    <context id="lifetime" style-ref="keyword">
+      <match extended="true">
+        '\%{ident}
       </match>
     </context>
 
@@ -231,12 +242,23 @@
       </include>
     </context>
 
-    <context id="char" style-ref="char" end-at-line-end="true" class="char" class-disabled="no-spell-check">
-      <start>'</start>
-      <end>'</end>
-      <include>
-        <context ref="def:escape"/>
-      </include>
+    <define-regex id="hex_digit" extended="true">
+      [0-9a-fA-F]
+    </define-regex>
+
+    <define-regex id="common_escape" extended="true">
+      (n|r|t)|
+      x\%{hex_digit}{2}|
+      u\%{hex_digit}{4}|
+      U\%{hex_digit}{8}
+    </define-regex>
+
+    <context id="char" style-ref="char" class="char">
+      <match extended="true">'([^\\]|\\\%{common_escape})'</match>
+    </context>
+
+    <context id="attribute" style-ref="attribute" class="attribute">
+      <match extended="true">\#\[[^\]]+\]</match>
     </context>
 
     <context id="rust" class="no-spell-check">
@@ -255,6 +277,8 @@
         <context ref="scope"/>
         <context ref="string"/>
         <context ref="char"/>
+        <context ref="lifetime"/>
+        <context ref="attribute"/>
       </include>
     </context>