ThirdParty/Pygments/pygments/lexers/c_cpp.py

changeset 6651
e8f3b5568b21
parent 5713
6762afd9f963
equal deleted inserted replaced
6650:1dd52aa8897c 6651:e8f3b5568b21
34 _ws1 = r'\s*(?:/[*].*?[*]/\s*)?' 34 _ws1 = r'\s*(?:/[*].*?[*]/\s*)?'
35 35
36 tokens = { 36 tokens = {
37 'whitespace': [ 37 'whitespace': [
38 # preprocessor directives: without whitespace 38 # preprocessor directives: without whitespace
39 ('^#if\s+0', Comment.Preproc, 'if0'), 39 (r'^#if\s+0', Comment.Preproc, 'if0'),
40 ('^#', Comment.Preproc, 'macro'), 40 ('^#', Comment.Preproc, 'macro'),
41 # or with whitespace 41 # or with whitespace
42 ('^(' + _ws1 + r')(#if\s+0)', 42 ('^(' + _ws1 + r')(#if\s+0)',
43 bygroups(using(this), Comment.Preproc), 'if0'), 43 bygroups(using(this), Comment.Preproc), 'if0'),
44 ('^(' + _ws1 + ')(#)', 44 ('^(' + _ws1 + ')(#)',
82 'leave', 'wchar_t', 'w64', 'unaligned', 'raise', 'noop', 82 'leave', 'wchar_t', 'w64', 'unaligned', 'raise', 'noop',
83 'identifier', 'forceinline', 'assume'), 83 'identifier', 'forceinline', 'assume'),
84 prefix=r'__', suffix=r'\b'), Keyword.Reserved), 84 prefix=r'__', suffix=r'\b'), Keyword.Reserved),
85 (r'(true|false|NULL)\b', Name.Builtin), 85 (r'(true|false|NULL)\b', Name.Builtin),
86 (r'([a-zA-Z_]\w*)(\s*)(:)(?!:)', bygroups(Name.Label, Text, Punctuation)), 86 (r'([a-zA-Z_]\w*)(\s*)(:)(?!:)', bygroups(Name.Label, Text, Punctuation)),
87 ('[a-zA-Z_]\w*', Name), 87 (r'[a-zA-Z_]\w*', Name),
88 ], 88 ],
89 'root': [ 89 'root': [
90 include('whitespace'), 90 include('whitespace'),
91 # functions 91 # functions
92 (r'((?:[\w*\s])+?(?:\s|[*]))' # return arguments 92 (r'((?:[\w*\s])+?(?:\s|[*]))' # return arguments
188 filenames = ['*.c', '*.h', '*.idc'] 188 filenames = ['*.c', '*.h', '*.idc']
189 mimetypes = ['text/x-chdr', 'text/x-csrc'] 189 mimetypes = ['text/x-chdr', 'text/x-csrc']
190 priority = 0.1 190 priority = 0.1
191 191
192 def analyse_text(text): 192 def analyse_text(text):
193 if re.search('^\s*#include [<"]', text, re.MULTILINE): 193 if re.search(r'^\s*#include [<"]', text, re.MULTILINE):
194 return 0.1 194 return 0.1
195 if re.search('^\s*#ifn?def ', text, re.MULTILINE): 195 if re.search(r'^\s*#ifn?def ', text, re.MULTILINE):
196 return 0.1 196 return 0.1
197 197
198 198
199 class CppLexer(CFamilyLexer): 199 class CppLexer(CFamilyLexer):
200 """ 200 """

eric ide

mercurial