38 lines
1008 B
Plaintext
38 lines
1008 B
Plaintext
;; TODO very WIP
|
|
(define-syntax
|
|
"rust"
|
|
:styles
|
|
("keyword" :fg 'red)
|
|
("symbol" :fg 'cyan)
|
|
("comment" :fg 'white :bold)
|
|
("string" :fg 'yellow)
|
|
("number" :fg 'cyan :bold)
|
|
("constant" :fg 'cyan :bold)
|
|
:rules
|
|
;; Keywords
|
|
(:keyword
|
|
"use" "pub" "mod" "enum" "struct" "impl"
|
|
"for" "=>" "->" "match" "for" "while" "loop"
|
|
"if" "fn" "&mut" "&" "let" "where" "?"
|
|
:category "keyword"
|
|
)
|
|
;; Identifiers
|
|
(:keyword
|
|
"Rc" "RefCell" "Clone" "Copy" "PartialEq" "Eq"
|
|
"PartialOrd" "Ord" "Debug" "Result" "Option"
|
|
"bool" "i8" "i16" "i32" "i64" "i128" "u8" "u16"
|
|
"u32" "u64" "u128" "str" "&str"
|
|
"Self" "self" "&self" "&mut self" "Ok" "Err"
|
|
:category "symbol"
|
|
)
|
|
(:keyword "true" "false" :category "constant")
|
|
;; strings
|
|
(:regex "." "string" :prev-state 1)
|
|
(:regex "[^\\\\]*\"" "string" :prev-state 1 :next-state 0)
|
|
(:regex "\"" "string" :next-state 1)
|
|
;; numbers
|
|
(:regex "(0x|0o|0b)?\\d+" "number")
|
|
;; Comments
|
|
(:regex "//.*$" "comment")
|
|
)
|