From a620e610c92f26cf34ecba03f2fe76cb54b71608 Mon Sep 17 00:00:00 2001 From: Erik Osheim Date: Thu, 9 Dec 2021 15:49:33 -0500 Subject: [PATCH] rust changes --HG-- branch : pmacs2 --- mode/rust.py | 42 ++++++++++-------------------------------- 1 file changed, 10 insertions(+), 32 deletions(-) diff --git a/mode/rust.py b/mode/rust.py index 54e1083..ffaaa7a 100644 --- a/mode/rust.py +++ b/mode/rust.py @@ -1,38 +1,8 @@ import os.path -#from subprocess import Popen, PIPE, STDOUT -#from method import Method, arg -#from method.shell import Exec -#from method.tags import InitTags from mode import Fundamental import tab -#import completer from lex import Grammar, PatternRule, RegionRule, PatternMatchRule, OverridePatternRule from mode.python import StringGrammar2 -#from etags import TagManager - -#class CommentGrammar(Grammar): -# rules = [ -# PatternRule(r'data', r'(?:[^\*]|\*(?!/))+'), -# ] -# -#class ErrorGrammar(Grammar): -# rules = [ -# PatternRule(r'data', r'[^\\\n]+'), -# PatternRule('continuation', r'\\\n$'), -# ] - -#class MacroGrammar(Grammar): -# rules = [ -# PatternRule('continuation', r'\\\n$'), -# PatternRule('name', '(?<=#define ) *' + word), -# PatternRule('name', '(?<=#ifdef ) *' + word), -# PatternRule('name', '(?<=#ifndef ) *' + word), -# PatternRule('name', '(?<=#undef ) *' + word), -# PatternRule('concat', '##' + chr2 + '+'), -# PatternRule('quoted', '#' + chr2 + '+'), -# PatternMatchRule('x', r'(defined)(\()(' + word + r')(\))', -# 'function', 'delimiter', 'name', 'delimiter'), -# ] chr1 = '[a-zA-Z_]' chr2 = '[a-zA-Z0-9_]' @@ -66,7 +36,15 @@ class RustGrammar(Grammar): PatternRule("rust.float", r"-?[0-9]+\.[0-9]+|-?\.[0-9]+|-?(?:[0-9]|[0-9]+\.[0-9]*|-?\.[0-9]+)[eE][\+-]?[0-9]+"), PatternRule("rust.integer", r"(?:0(?![x0-9])|-?[1-9][0-9]*|0[0-7]+|0[xX][0-9a-fA-F]+)[lL]?"), - PatternRule('rust.keyword', r"(?:fn)(?!" + chr2 + ")"), + #PatternRule('rust.keyword', r"(?<=[a-zA-Z0-9_])(?:while|where|use|unsafe|type|true|trait|super|struct|static|Self|self|return|ref|pub|mut|move|mod|match|loop|let|in|impl|if|for|fn|false|extern|enum|else|dyn|crate|continue|const|break|await|async|as)"), + PatternRule('rust.keyword', r"(?|\.\.|%|==)"), @@ -118,7 +96,7 @@ hi_blue = ('blue225', 'default') class Rust(Fundamental): name = 'rust' - extensions = ['.rust'] + extensions = ['.rs'] grammar = RustGrammar opentokens = ('delimiter',) opentags = {'(': ')', '[': ']', '{': '}'}