30 keyword_types = (words(( |
30 keyword_types = (words(( |
31 'u8', 'u16', 'u32', 'u64', 'u128', 'i8', 'i16', 'i32', 'i64', 'i128', |
31 'u8', 'u16', 'u32', 'u64', 'u128', 'i8', 'i16', 'i32', 'i64', 'i128', |
32 'usize', 'isize', 'f32', 'f64', 'char', 'str', 'bool', |
32 'usize', 'isize', 'f32', 'f64', 'char', 'str', 'bool', |
33 ), suffix=r'\b'), Keyword.Type) |
33 ), suffix=r'\b'), Keyword.Type) |
34 |
34 |
35 builtin_types = (words(( |
35 builtin_funcs_types = (words(( |
36 'Send', 'Sized', 'Sync', 'Unpin', |
36 'Copy', 'Send', 'Sized', 'Sync', 'Unpin', |
37 'Drop', 'Fn', 'FnMut', 'FnOnce', |
37 'Drop', 'Fn', 'FnMut', 'FnOnce', 'drop', |
38 'AsRef', 'AsMut', 'Into', 'From', |
38 'Box', 'ToOwned', 'Clone', |
|
39 'PartialEq', 'PartialOrd', 'Eq', 'Ord', |
|
40 'AsRef', 'AsMut', 'Into', 'From', 'Default', |
39 'Iterator', 'Extend', 'IntoIterator', 'DoubleEndedIterator', |
41 'Iterator', 'Extend', 'IntoIterator', 'DoubleEndedIterator', |
40 'ExactSizeIterator', 'Option', 'Result', |
42 'ExactSizeIterator', |
41 'Box', 'ToOwned', 'String', 'ToString', 'Vec', |
43 'Option', 'Some', 'None', |
42 'Clone', 'Copy', 'Default', 'Eq', 'Hash', 'Ord', 'PartialEq', |
44 'Result', 'Ok', 'Err', |
43 'PartialOrd', 'Ord', |
45 'String', 'ToString', 'Vec', |
44 ), suffix=r'\b'), Name.Builtin) |
46 ), suffix=r'\b'), Name.Builtin) |
45 |
47 |
46 builtin_funcs_macros = (words(( |
48 builtin_macros = (words(( |
47 'drop', 'Some', 'None', 'Ok', 'Err', |
49 'asm', 'assert', 'assert_eq', 'assert_ne', 'cfg', 'column', |
48 'asm!', 'assert!', 'assert_eq!', 'assert_ne!', 'cfg!', 'column!', |
50 'compile_error', 'concat', 'concat_idents', 'dbg', 'debug_assert', |
49 'compile_error!', 'concat!', 'concat_idents!', 'dbg!', 'debug_assert!', |
51 'debug_assert_eq', 'debug_assert_ne', 'env', 'eprint', 'eprintln', |
50 'debug_assert_eq!', 'debug_assert_ne!', 'env!', 'eprint!', 'eprintln!', |
52 'file', 'format', 'format_args', 'format_args_nl', 'global_asm', |
51 'file!', 'format_args!', 'format_args_nl!', 'global_asm!', 'include!', |
53 'include', 'include_bytes', 'include_str', |
52 'include_bytes!', 'include_str!', 'line!', 'log_syntax!', |
54 'is_aarch64_feature_detected', |
53 'module_path!', 'option_env!', 'panic!', 'print!', 'println!', |
55 'is_arm_feature_detected', |
54 'stringify!', 'thread_local!', 'todo!', 'trace_macros!', |
56 'is_mips64_feature_detected', |
55 'unimplemented!', 'unreachable!', 'vec!', 'write!', 'writeln!', |
57 'is_mips_feature_detected', |
56 ), suffix=r'\b'), Name.Builtin) |
58 'is_powerpc64_feature_detected', |
|
59 'is_powerpc_feature_detected', |
|
60 'is_x86_feature_detected', |
|
61 'line', 'llvm_asm', 'log_syntax', 'macro_rules', 'matches', |
|
62 'module_path', 'option_env', 'panic', 'print', 'println', 'stringify', |
|
63 'thread_local', 'todo', 'trace_macros', 'unimplemented', 'unreachable', |
|
64 'vec', 'write', 'writeln', |
|
65 ), suffix=r'!'), Name.Function.Magic) |
57 |
66 |
58 tokens = { |
67 tokens = { |
59 'root': [ |
68 'root': [ |
60 # rust allows a file to start with a shebang, but if the first line |
69 # rust allows a file to start with a shebang, but if the first line |
61 # starts with #![ then it's not a shebang but a crate attribute. |
70 # starts with #![ then it's not a shebang but a crate attribute. |
74 (r'/\*', Comment.Multiline, 'comment'), |
83 (r'/\*', Comment.Multiline, 'comment'), |
75 |
84 |
76 # Macro parameters |
85 # Macro parameters |
77 (r"""\$([a-zA-Z_]\w*|\(,?|\),?|,?)""", Comment.Preproc), |
86 (r"""\$([a-zA-Z_]\w*|\(,?|\),?|,?)""", Comment.Preproc), |
78 # Keywords |
87 # Keywords |
79 (words(( |
88 (words(('as', 'async', 'await', 'box', 'const', 'crate', 'dyn', |
80 'as', 'async', 'await', 'box', 'const', 'crate', 'dyn', 'else', |
89 'else', 'extern', 'for', 'if', 'impl', 'in', 'loop', |
81 'extern', 'for', 'if', 'impl', 'in', 'loop', 'match', 'move', |
90 'match', 'move', 'mut', 'pub', 'ref', 'return', 'static', |
82 'mut', 'pub', 'ref', 'return', 'static', 'super', 'trait', |
91 'super', 'trait', 'unsafe', 'use', 'where', 'while'), |
83 'try', 'unsafe', 'use', 'where', 'while', 'macro_rules!', |
92 suffix=r'\b'), Keyword), |
84 ), suffix=r'\b'), Keyword), |
93 (words(('abstract', 'become', 'do', 'final', 'macro', 'override', |
85 (words(('abstract', 'alignof', 'become', 'do', 'final', 'macro', |
94 'priv', 'typeof', 'try', 'unsized', 'virtual', 'yield'), |
86 'offsetof', 'override', 'priv', 'proc', 'pure', 'sizeof', |
95 suffix=r'\b'), Keyword.Reserved), |
87 'typeof', 'unsized', 'virtual', 'yield'), suffix=r'\b'), |
|
88 Keyword.Reserved), |
|
89 (r'(true|false)\b', Keyword.Constant), |
96 (r'(true|false)\b', Keyword.Constant), |
|
97 (r'self\b', Name.Builtin.Pseudo), |
90 (r'mod\b', Keyword, 'modname'), |
98 (r'mod\b', Keyword, 'modname'), |
91 (r'let\b', Keyword.Declaration), |
99 (r'let\b', Keyword.Declaration), |
92 (r'fn\b', Keyword, 'funcname'), |
100 (r'fn\b', Keyword, 'funcname'), |
93 (r'(struct|enum|type|union)\b', Keyword, 'typename'), |
101 (r'(struct|enum|type|union)\b', Keyword, 'typename'), |
94 (r'(default)(\s+)(type|fn)\b', bygroups(Keyword, Text, Keyword)), |
102 (r'(default)(\s+)(type|fn)\b', bygroups(Keyword, Text, Keyword)), |
95 keyword_types, |
103 keyword_types, |
96 (r'[sS]elf\b', Name.Builtin.Pseudo), |
104 (r'[sS]elf\b', Name.Builtin.Pseudo), |
97 # Prelude (taken from Rust's src/libstd/prelude.rs) |
105 # Prelude (taken from Rust's src/libstd/prelude.rs) |
98 builtin_types, |
106 builtin_funcs_types, |
99 builtin_funcs_macros, |
107 builtin_macros, |
100 # Path seperators, so types don't catch them. |
108 # Path seperators, so types don't catch them. |
101 (r'::\b', Text), |
109 (r'::\b', Text), |
102 # Types in positions. |
110 # Types in positions. |
103 (r'(?::|->)', Text, 'typename'), |
111 (r'(?::|->)', Text, 'typename'), |
104 # Labels |
112 # Labels |