]> git.lizzy.rs Git - micro.git/blobdiff - runtime/syntax/rust.yaml
Add support for rust async/await keywords
[micro.git] / runtime / syntax / rust.yaml
index f24bcfb95b40211cef7231f07394cb3787cc7dfd..e6ed639562ccfb4f11424a4e302f472ad3c19a8e 100644 (file)
@@ -7,7 +7,7 @@ rules:
     # function definition
     - identifier: "fn [a-z0-9_]+"
       # Reserved words
-    - statement: "\\b(abstract|alignof|as|become|box|break|const|continue|crate|do|dyn|else|enum|extern|false|final|fn|for|if|impl|in|let|loop|macro|match|mod|move|mut|offsetof|override|priv|pub|pure|ref|return|sizeof|static|self|struct|super|true|trait|type|typeof|unsafe|unsized|use|virtual|where|while|yield)\\b"
+    - statement: "\\b(abstract|alignof|as|async|await|become|box|break|const|continue|crate|do|dyn|else|enum|extern|false|final|fn|for|if|impl|in|let|loop|macro|match|mod|move|mut|offsetof|override|priv|pub|pure|ref|return|sizeof|static|self|struct|super|true|trait|type|typeof|unsafe|unsized|use|virtual|where|while|yield)\\b"
       # macros
     - special: "[a-z_]+!"
       # Constants
@@ -24,15 +24,27 @@ rules:
     - constant.string:
         start: "\""
         end: "\""
-        skip: "\\\\."
+        skip: '\\.'
         rules:
-            - constant.specialChar: "\\\\."
+            - constant.specialChar: '\\.'
 
     - constant.string:
         start: "r#+\""
         end: "\"#+"
         rules: []
 
+    # Character literals
+    # NOTE: This is an ugly hack to work around the fact that rust uses
+    # single quotes both for character literals and lifetimes.
+    # Match all character literals.
+    - constant.string: "'(\\\\.|.)'"
+    # Match the '"' literal which would otherwise match
+    # as a double quoted string and destroy the highlighting.
+    - constant.string:
+        start: "'\""
+        end: "'"
+        rules: []
+
     - comment:
         start: "//"
         end: "$"
@@ -49,4 +61,3 @@ rules:
         start: "#!\\["
         end: "\\]"
         rules: []
-