diff options
author | orivej <orivej@yandex-team.ru> | 2022-02-10 16:44:49 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:44:49 +0300 |
commit | 718c552901d703c502ccbefdfc3c9028d608b947 (patch) | |
tree | 46534a98bbefcd7b1f3faa5b52c138ab27db75b7 /contrib/python/Pygments/py2/pygments/lexers/c_cpp.py | |
parent | e9656aae26e0358d5378e5b63dcac5c8dbe0e4d0 (diff) | |
download | ydb-718c552901d703c502ccbefdfc3c9028d608b947.tar.gz |
Restoring authorship annotation for <orivej@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'contrib/python/Pygments/py2/pygments/lexers/c_cpp.py')
-rw-r--r-- | contrib/python/Pygments/py2/pygments/lexers/c_cpp.py | 54 |
1 files changed, 27 insertions, 27 deletions
diff --git a/contrib/python/Pygments/py2/pygments/lexers/c_cpp.py b/contrib/python/Pygments/py2/pygments/lexers/c_cpp.py index 5d84a37758..5f04dee16c 100644 --- a/contrib/python/Pygments/py2/pygments/lexers/c_cpp.py +++ b/contrib/python/Pygments/py2/pygments/lexers/c_cpp.py @@ -5,7 +5,7 @@ Lexers for C/C++ languages. - :copyright: Copyright 2006-2019 by the Pygments team, see AUTHORS. + :copyright: Copyright 2006-2019 by the Pygments team, see AUTHORS. :license: BSD, see LICENSE for details. """ @@ -36,7 +36,7 @@ class CFamilyLexer(RegexLexer): tokens = { 'whitespace': [ # preprocessor directives: without whitespace - (r'^#if\s+0', Comment.Preproc, 'if0'), + (r'^#if\s+0', Comment.Preproc, 'if0'), ('^#', Comment.Preproc, 'macro'), # or with whitespace ('^(' + _ws1 + r')(#if\s+0)', @@ -46,15 +46,15 @@ class CFamilyLexer(RegexLexer): (r'\n', Text), (r'\s+', Text), (r'\\\n', Text), # line continuation - (r'//(\n|[\w\W]*?[^\\]\n)', Comment.Single), - (r'/(\\\n)?[*][\w\W]*?[*](\\\n)?/', Comment.Multiline), - # Open until EOF, so no ending delimeter - (r'/(\\\n)?[*][\w\W]*', Comment.Multiline), + (r'//(\n|[\w\W]*?[^\\]\n)', Comment.Single), + (r'/(\\\n)?[*][\w\W]*?[*](\\\n)?/', Comment.Multiline), + # Open until EOF, so no ending delimeter + (r'/(\\\n)?[*][\w\W]*', Comment.Multiline), ], 'statements': [ - (r'(L?)(")', bygroups(String.Affix, String), 'string'), - (r"(L?)(')(\\.|\\[0-7]{1,3}|\\x[a-fA-F0-9]{1,2}|[^\\\'\n])(')", - bygroups(String.Affix, String.Char, String.Char, String.Char)), + (r'(L?)(")', bygroups(String.Affix, String), 'string'), + (r"(L?)(')(\\.|\\[0-7]{1,3}|\\x[a-fA-F0-9]{1,2}|[^\\\'\n])(')", + bygroups(String.Affix, String.Char, String.Char, String.Char)), (r'(\d+\.\d*|\.\d+|\d+)[eE][+-]?\d+[LlUu]*', Number.Float), (r'(\d+\.\d*|\.\d+|\d+[fF])[fF]?', Number.Float), (r'0x[0-9a-fA-F]+[LlUu]*', Number.Hex), @@ -63,11 +63,11 @@ class CFamilyLexer(RegexLexer): (r'\*/', Error), (r'[~!%^&*+=|?:<>/-]', Operator), (r'[()\[\],.]', Punctuation), - (words(('asm', 'auto', 'break', 'case', 'const', 'continue', - 'default', 'do', 'else', 'enum', 'extern', 'for', 'goto', - 'if', 'register', 'restricted', 'return', 'sizeof', - 'static', 'struct', 'switch', 'typedef', 'union', - 'volatile', 'while'), + (words(('asm', 'auto', 'break', 'case', 'const', 'continue', + 'default', 'do', 'else', 'enum', 'extern', 'for', 'goto', + 'if', 'register', 'restricted', 'return', 'sizeof', + 'static', 'struct', 'switch', 'typedef', 'union', + 'volatile', 'while'), suffix=r'\b'), Keyword), (r'(bool|int|long|float|short|double|char|unsigned|signed|void)\b', Keyword.Type), @@ -84,7 +84,7 @@ class CFamilyLexer(RegexLexer): prefix=r'__', suffix=r'\b'), Keyword.Reserved), (r'(true|false|NULL)\b', Name.Builtin), (r'([a-zA-Z_]\w*)(\s*)(:)(?!:)', bygroups(Name.Label, Text, Punctuation)), - (r'[a-zA-Z_]\w*', Name), + (r'[a-zA-Z_]\w*', Name), ], 'root': [ include('whitespace'), @@ -127,8 +127,8 @@ class CFamilyLexer(RegexLexer): (r'\\', String), # stray backslash ], 'macro': [ - (r'(include)(' + _ws1 + r')([^\n]+)', - bygroups(Comment.Preproc, Text, Comment.PreprocFile)), + (r'(include)(' + _ws1 + r')([^\n]+)', + bygroups(Comment.Preproc, Text, Comment.PreprocFile)), (r'[^/\n]+', Comment.Preproc), (r'/[*](.|\n)*?[*]/', Comment.Multiline), (r'//.*?\n', Comment.Single, '#pop'), @@ -190,9 +190,9 @@ class CLexer(CFamilyLexer): priority = 0.1 def analyse_text(text): - if re.search(r'^\s*#include [<"]', text, re.MULTILINE): + if re.search(r'^\s*#include [<"]', text, re.MULTILINE): return 0.1 - if re.search(r'^\s*#ifn?def ', text, re.MULTILINE): + if re.search(r'^\s*#ifn?def ', text, re.MULTILINE): return 0.1 @@ -211,7 +211,7 @@ class CppLexer(CFamilyLexer): tokens = { 'statements': [ (words(( - 'catch', 'const_cast', 'delete', 'dynamic_cast', 'explicit', + 'catch', 'const_cast', 'delete', 'dynamic_cast', 'explicit', 'export', 'friend', 'mutable', 'namespace', 'new', 'operator', 'private', 'protected', 'public', 'reinterpret_cast', 'restrict', 'static_cast', 'template', 'this', 'throw', 'throws', @@ -221,12 +221,12 @@ class CppLexer(CFamilyLexer): 'final'), suffix=r'\b'), Keyword), (r'char(16_t|32_t)\b', Keyword.Type), (r'(class)(\s+)', bygroups(Keyword, Text), 'classname'), - # C++11 raw strings - (r'(R)(")([^\\()\s]{,16})(\()((?:.|\n)*?)(\)\3)(")', - bygroups(String.Affix, String, String.Delimiter, String.Delimiter, - String, String.Delimiter, String)), - # C++11 UTF-8/16/32 strings - (r'(u8|u|U)(")', bygroups(String.Affix, String), 'string'), + # C++11 raw strings + (r'(R)(")([^\\()\s]{,16})(\()((?:.|\n)*?)(\)\3)(")', + bygroups(String.Affix, String, String.Delimiter, String.Delimiter, + String, String.Delimiter, String)), + # C++11 UTF-8/16/32 strings + (r'(u8|u|U)(")', bygroups(String.Affix, String), 'string'), inherit, ], 'root': [ @@ -246,7 +246,7 @@ class CppLexer(CFamilyLexer): } def analyse_text(text): - if re.search('#include <[a-z_]+>', text): + if re.search('#include <[a-z_]+>', text): return 0.2 if re.search('using namespace ', text): return 0.4 |