diff options
author | shadchin <shadchin@yandex-team.ru> | 2022-02-10 16:44:39 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:44:39 +0300 |
commit | e9656aae26e0358d5378e5b63dcac5c8dbe0e4d0 (patch) | |
tree | 64175d5cadab313b3e7039ebaa06c5bc3295e274 /contrib/python/Pygments/py3/pygments/lexers/rust.py | |
parent | 2598ef1d0aee359b4b6d5fdd1758916d5907d04f (diff) | |
download | ydb-e9656aae26e0358d5378e5b63dcac5c8dbe0e4d0.tar.gz |
Restoring authorship annotation for <shadchin@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'contrib/python/Pygments/py3/pygments/lexers/rust.py')
-rw-r--r-- | contrib/python/Pygments/py3/pygments/lexers/rust.py | 172 |
1 files changed, 86 insertions, 86 deletions
diff --git a/contrib/python/Pygments/py3/pygments/lexers/rust.py b/contrib/python/Pygments/py3/pygments/lexers/rust.py index db6edd3b77b..d01f73e4a4d 100644 --- a/contrib/python/Pygments/py3/pygments/lexers/rust.py +++ b/contrib/python/Pygments/py3/pygments/lexers/rust.py @@ -4,7 +4,7 @@ Lexers for the Rust language. - :copyright: Copyright 2006-2021 by the Pygments team, see AUTHORS. + :copyright: Copyright 2006-2021 by the Pygments team, see AUTHORS. :license: BSD, see LICENSE for details. """ @@ -17,56 +17,56 @@ __all__ = ['RustLexer'] class RustLexer(RegexLexer): """ - Lexer for the Rust programming language (version 1.47). + Lexer for the Rust programming language (version 1.47). .. versionadded:: 1.6 """ name = 'Rust' filenames = ['*.rs', '*.rs.in'] aliases = ['rust', 'rs'] - mimetypes = ['text/rust', 'text/x-rust'] - - keyword_types = (words(( - 'u8', 'u16', 'u32', 'u64', 'u128', 'i8', 'i16', 'i32', 'i64', 'i128', - 'usize', 'isize', 'f32', 'f64', 'char', 'str', 'bool', - ), suffix=r'\b'), Keyword.Type) - - builtin_funcs_types = (words(( - 'Copy', 'Send', 'Sized', 'Sync', 'Unpin', - 'Drop', 'Fn', 'FnMut', 'FnOnce', 'drop', - 'Box', 'ToOwned', 'Clone', - 'PartialEq', 'PartialOrd', 'Eq', 'Ord', - 'AsRef', 'AsMut', 'Into', 'From', 'Default', - 'Iterator', 'Extend', 'IntoIterator', 'DoubleEndedIterator', - 'ExactSizeIterator', - 'Option', 'Some', 'None', - 'Result', 'Ok', 'Err', - 'String', 'ToString', 'Vec', - ), suffix=r'\b'), Name.Builtin) - - builtin_macros = (words(( - 'asm', 'assert', 'assert_eq', 'assert_ne', 'cfg', 'column', - 'compile_error', 'concat', 'concat_idents', 'dbg', 'debug_assert', - 'debug_assert_eq', 'debug_assert_ne', 'env', 'eprint', 'eprintln', - 'file', 'format', 'format_args', 'format_args_nl', 'global_asm', - 'include', 'include_bytes', 'include_str', - 'is_aarch64_feature_detected', - 'is_arm_feature_detected', - 'is_mips64_feature_detected', - 'is_mips_feature_detected', - 'is_powerpc64_feature_detected', - 'is_powerpc_feature_detected', - 'is_x86_feature_detected', - 'line', 'llvm_asm', 'log_syntax', 'macro_rules', 'matches', - 'module_path', 'option_env', 'panic', 'print', 'println', 'stringify', - 'thread_local', 'todo', 'trace_macros', 'unimplemented', 'unreachable', - 'vec', 'write', 'writeln', - ), suffix=r'!'), Name.Function.Magic) - + mimetypes = ['text/rust', 'text/x-rust'] + + keyword_types = (words(( + 'u8', 'u16', 'u32', 'u64', 'u128', 'i8', 'i16', 'i32', 'i64', 'i128', + 'usize', 'isize', 'f32', 'f64', 'char', 'str', 'bool', + ), suffix=r'\b'), Keyword.Type) + + builtin_funcs_types = (words(( + 'Copy', 'Send', 'Sized', 'Sync', 'Unpin', + 'Drop', 'Fn', 'FnMut', 'FnOnce', 'drop', + 'Box', 'ToOwned', 'Clone', + 'PartialEq', 'PartialOrd', 'Eq', 'Ord', + 'AsRef', 'AsMut', 'Into', 'From', 'Default', + 'Iterator', 'Extend', 'IntoIterator', 'DoubleEndedIterator', + 'ExactSizeIterator', + 'Option', 'Some', 'None', + 'Result', 'Ok', 'Err', + 'String', 'ToString', 'Vec', + ), suffix=r'\b'), Name.Builtin) + + builtin_macros = (words(( + 'asm', 'assert', 'assert_eq', 'assert_ne', 'cfg', 'column', + 'compile_error', 'concat', 'concat_idents', 'dbg', 'debug_assert', + 'debug_assert_eq', 'debug_assert_ne', 'env', 'eprint', 'eprintln', + 'file', 'format', 'format_args', 'format_args_nl', 'global_asm', + 'include', 'include_bytes', 'include_str', + 'is_aarch64_feature_detected', + 'is_arm_feature_detected', + 'is_mips64_feature_detected', + 'is_mips_feature_detected', + 'is_powerpc64_feature_detected', + 'is_powerpc_feature_detected', + 'is_x86_feature_detected', + 'line', 'llvm_asm', 'log_syntax', 'macro_rules', 'matches', + 'module_path', 'option_env', 'panic', 'print', 'println', 'stringify', + 'thread_local', 'todo', 'trace_macros', 'unimplemented', 'unreachable', + 'vec', 'write', 'writeln', + ), suffix=r'!'), Name.Function.Magic) + tokens = { 'root': [ # rust allows a file to start with a shebang, but if the first line - # starts with #![ then it's not a shebang but a crate attribute. + # starts with #![ then it's not a shebang but a crate attribute. (r'#![^[\r\n].*$', Comment.Preproc), default('base'), ], @@ -84,79 +84,79 @@ class RustLexer(RegexLexer): # Macro parameters (r"""\$([a-zA-Z_]\w*|\(,?|\),?|,?)""", Comment.Preproc), # Keywords - (words(('as', 'async', 'await', 'box', 'const', 'crate', 'dyn', - 'else', 'extern', 'for', 'if', 'impl', 'in', 'loop', - 'match', 'move', 'mut', 'pub', 'ref', 'return', 'static', - 'super', 'trait', 'unsafe', 'use', 'where', 'while'), - suffix=r'\b'), Keyword), - (words(('abstract', 'become', 'do', 'final', 'macro', 'override', - 'priv', 'typeof', 'try', 'unsized', 'virtual', 'yield'), - suffix=r'\b'), Keyword.Reserved), + (words(('as', 'async', 'await', 'box', 'const', 'crate', 'dyn', + 'else', 'extern', 'for', 'if', 'impl', 'in', 'loop', + 'match', 'move', 'mut', 'pub', 'ref', 'return', 'static', + 'super', 'trait', 'unsafe', 'use', 'where', 'while'), + suffix=r'\b'), Keyword), + (words(('abstract', 'become', 'do', 'final', 'macro', 'override', + 'priv', 'typeof', 'try', 'unsized', 'virtual', 'yield'), + suffix=r'\b'), Keyword.Reserved), (r'(true|false)\b', Keyword.Constant), - (r'self\b', Name.Builtin.Pseudo), + (r'self\b', Name.Builtin.Pseudo), (r'mod\b', Keyword, 'modname'), (r'let\b', Keyword.Declaration), (r'fn\b', Keyword, 'funcname'), (r'(struct|enum|type|union)\b', Keyword, 'typename'), (r'(default)(\s+)(type|fn)\b', bygroups(Keyword, Text, Keyword)), keyword_types, - (r'[sS]elf\b', Name.Builtin.Pseudo), - # Prelude (taken from Rust's src/libstd/prelude.rs) - builtin_funcs_types, - builtin_macros, + (r'[sS]elf\b', Name.Builtin.Pseudo), + # Prelude (taken from Rust's src/libstd/prelude.rs) + builtin_funcs_types, + builtin_macros, # Path seperators, so types don't catch them. (r'::\b', Text), # Types in positions. (r'(?::|->)', Text, 'typename'), # Labels - (r'(break|continue)(\b\s*)(\'[A-Za-z_]\w*)?', + (r'(break|continue)(\b\s*)(\'[A-Za-z_]\w*)?', bygroups(Keyword, Text.Whitespace, Name.Label)), - - # Character literals + + # Character literals (r"""'(\\['"\\nrt]|\\x[0-7][0-9a-fA-F]|\\0""" r"""|\\u\{[0-9a-fA-F]{1,6}\}|.)'""", String.Char), (r"""b'(\\['"\\nrt]|\\x[0-9a-fA-F]{2}|\\0""" r"""|\\u\{[0-9a-fA-F]{1,6}\}|.)'""", String.Char), - - # Binary literals + + # Binary literals (r'0b[01_]+', Number.Bin, 'number_lit'), - # Octal literals + # Octal literals (r'0o[0-7_]+', Number.Oct, 'number_lit'), - # Hexadecimal literals + # Hexadecimal literals (r'0[xX][0-9a-fA-F_]+', Number.Hex, 'number_lit'), - # Decimal literals + # Decimal literals (r'[0-9][0-9_]*(\.[0-9_]+[eE][+\-]?[0-9_]+|' r'\.[0-9_]*(?!\.)|[eE][+\-]?[0-9_]+)', Number.Float, 'number_lit'), (r'[0-9][0-9_]*', Number.Integer, 'number_lit'), - - # String literals + + # String literals (r'b"', String, 'bytestring'), (r'"', String, 'string'), - (r'(?s)b?r(#*)".*?"\1', String), + (r'(?s)b?r(#*)".*?"\1', String), - # Lifetime names - (r"'", Operator, 'lifetime'), + # Lifetime names + (r"'", Operator, 'lifetime'), # Operators and Punctuation - (r'\.\.=?', Operator), + (r'\.\.=?', Operator), (r'[{}()\[\],.;]', Punctuation), (r'[+\-*/%&|<>^!~@=:?]', Operator), - # Identifiers + # Identifiers (r'[a-zA-Z_]\w*', Name), - # Raw identifiers - (r'r#[a-zA-Z_]\w*', Name), + # Raw identifiers + (r'r#[a-zA-Z_]\w*', Name), # Attributes (r'#!?\[', Comment.Preproc, 'attribute['), - - # Misc - # Lone hashes: not used in Rust syntax, but allowed in macro - # arguments, most famously for quote::quote!() - (r'#', Text), + + # Misc + # Lone hashes: not used in Rust syntax, but allowed in macro + # arguments, most famously for quote::quote!() + (r'#', Text), ], 'comment': [ (r'[^*/]+', Comment.Multiline), @@ -183,17 +183,17 @@ class RustLexer(RegexLexer): 'typename': [ (r'\s+', Text), (r'&', Keyword.Pseudo), - (r"'", Operator, 'lifetime'), - builtin_funcs_types, + (r"'", Operator, 'lifetime'), + builtin_funcs_types, keyword_types, (r'[a-zA-Z_]\w*', Name.Class, '#pop'), default('#pop'), ], - 'lifetime': [ - (r"(static|_)", Name.Builtin), - (r"[a-zA-Z_]+\w*", Name.Attribute), - default('#pop'), - ], + 'lifetime': [ + (r"(static|_)", Name.Builtin), + (r"[a-zA-Z_]+\w*", Name.Attribute), + default('#pop'), + ], 'number_lit': [ (r'[ui](8|16|32|64|size)', Keyword, '#pop'), (r'f(32|64)', Keyword, '#pop'), @@ -216,7 +216,7 @@ class RustLexer(RegexLexer): ], 'attribute[': [ include('attribute_common'), - (r'\]', Comment.Preproc, '#pop'), - (r'[^"\]\[]+', Comment.Preproc), + (r'\]', Comment.Preproc, '#pop'), + (r'[^"\]\[]+', Comment.Preproc), ], } |