122 'ArithmeticError', 'AssertionError', 'AttributeError', |
122 'ArithmeticError', 'AssertionError', 'AttributeError', |
123 'BaseException', 'DeprecationWarning', 'EOFError', 'EnvironmentError', |
123 'BaseException', 'DeprecationWarning', 'EOFError', 'EnvironmentError', |
124 'Exception', 'FloatingPointError', 'FutureWarning', 'GeneratorExit', |
124 'Exception', 'FloatingPointError', 'FutureWarning', 'GeneratorExit', |
125 'IOError', 'ImportError', 'ImportWarning', 'IndentationError', |
125 'IOError', 'ImportError', 'ImportWarning', 'IndentationError', |
126 'IndexError', 'KeyError', 'KeyboardInterrupt', 'LookupError', |
126 'IndexError', 'KeyError', 'KeyboardInterrupt', 'LookupError', |
127 'MemoryError', 'NameError', 'NotImplemented', 'NotImplementedError', |
127 'MemoryError', 'ModuleNotFoundError', 'NameError', 'NotImplemented', 'NotImplementedError', |
128 'OSError', 'OverflowError', 'OverflowWarning', 'PendingDeprecationWarning', |
128 'OSError', 'OverflowError', 'OverflowWarning', 'PendingDeprecationWarning', |
129 'ReferenceError', 'RuntimeError', 'RuntimeWarning', 'StandardError', |
129 'RecursionError', 'ReferenceError', 'RuntimeError', 'RuntimeWarning', 'StandardError', |
130 'StopIteration', 'SyntaxError', 'SyntaxWarning', 'SystemError', |
130 'StopIteration', 'StopAsyncIteration', 'SyntaxError', 'SyntaxWarning', 'SystemError', |
131 'SystemExit', 'TabError', 'TypeError', 'UnboundLocalError', |
131 'SystemExit', 'TabError', 'TypeError', 'UnboundLocalError', |
132 'UnicodeDecodeError', 'UnicodeEncodeError', 'UnicodeError', |
132 'UnicodeDecodeError', 'UnicodeEncodeError', 'UnicodeError', |
133 'UnicodeTranslateError', 'UnicodeWarning', 'UserWarning', |
133 'UnicodeTranslateError', 'UnicodeWarning', 'UserWarning', |
134 'ValueError', 'VMSError', 'Warning', 'WindowsError', |
134 'ValueError', 'VMSError', 'Warning', 'WindowsError', |
135 'ZeroDivisionError'), prefix=r'(?<!\.)', suffix=r'\b'), |
135 'ZeroDivisionError'), prefix=r'(?<!\.)', suffix=r'\b'), |
178 'backtick': [ |
178 'backtick': [ |
179 ('`.*?`', String.Backtick), |
179 ('`.*?`', String.Backtick), |
180 ], |
180 ], |
181 'name': [ |
181 'name': [ |
182 (r'@[\w.]+', Name.Decorator), |
182 (r'@[\w.]+', Name.Decorator), |
183 ('[a-zA-Z_]\w*', Name), |
183 (r'[a-zA-Z_]\w*', Name), |
184 ], |
184 ], |
185 'funcname': [ |
185 'funcname': [ |
186 include('magicfuncs'), |
186 include('magicfuncs'), |
187 ('[a-zA-Z_]\w*', Name.Function, '#pop'), |
187 (r'[a-zA-Z_]\w*', Name.Function, '#pop'), |
188 default('#pop'), |
188 default('#pop'), |
189 ], |
189 ], |
190 'classname': [ |
190 'classname': [ |
191 ('[a-zA-Z_]\w*', Name.Class, '#pop') |
191 (r'[a-zA-Z_]\w*', Name.Class, '#pop') |
192 ], |
192 ], |
193 'import': [ |
193 'import': [ |
194 (r'(?:[ \t]|\\\n)+', Text), |
194 (r'(?:[ \t]|\\\n)+', Text), |
195 (r'as\b', Keyword.Namespace), |
195 (r'as\b', Keyword.Namespace), |
196 (r',', Operator), |
196 (r',', Operator), |
260 |
260 |
261 def innerstring_rules(ttype): |
261 def innerstring_rules(ttype): |
262 return [ |
262 return [ |
263 # the old style '%s' % (...) string formatting (still valid in Py3) |
263 # the old style '%s' % (...) string formatting (still valid in Py3) |
264 (r'%(\(\w+\))?[-#0 +]*([0-9]+|[*])?(\.([0-9]+|[*]))?' |
264 (r'%(\(\w+\))?[-#0 +]*([0-9]+|[*])?(\.([0-9]+|[*]))?' |
265 '[hlL]?[E-GXc-giorsux%]', String.Interpol), |
265 '[hlL]?[E-GXc-giorsaux%]', String.Interpol), |
266 # the new style '{}'.format(...) string formatting |
266 # the new style '{}'.format(...) string formatting |
267 (r'\{' |
267 (r'\{' |
268 '((\w+)((\.\w+)|(\[[^\]]+\]))*)?' # field name |
268 r'((\w+)((\.\w+)|(\[[^\]]+\]))*)?' # field name |
269 '(\![sra])?' # conversion |
269 r'(\![sra])?' # conversion |
270 '(\:(.?[<>=\^])?[-+ ]?#?0?(\d+)?,?(\.\d+)?[E-GXb-gnosx%]?)?' |
270 r'(\:(.?[<>=\^])?[-+ ]?#?0?(\d+)?,?(\.\d+)?[E-GXb-gnosx%]?)?' |
271 '\}', String.Interpol), |
271 r'\}', String.Interpol), |
272 |
272 |
273 # backslashes, quotes and formatting signs must be parsed one at a time |
273 # backslashes, quotes and formatting signs must be parsed one at a time |
274 (r'[^\\\'"%{\n]+', ttype), |
274 (r'[^\\\'"%{\n]+', ttype), |
275 (r'[\'"\\]', ttype), |
275 (r'[\'"\\]', ttype), |
276 # unhandled string formatting sign |
276 # unhandled string formatting sign |
359 '__objclass__', '__qualname__', '__self__', '__slots__', '__weakref__'), |
359 '__objclass__', '__qualname__', '__self__', '__slots__', '__weakref__'), |
360 suffix=r'\b'), |
360 suffix=r'\b'), |
361 Name.Variable.Magic), |
361 Name.Variable.Magic), |
362 ] |
362 ] |
363 tokens['numbers'] = [ |
363 tokens['numbers'] = [ |
364 (r'(\d+\.\d*|\d*\.\d+)([eE][+-]?[0-9]+)?', Number.Float), |
364 (r'(\d(?:_?\d)*\.(?:\d(?:_?\d)*)?|(?:\d(?:_?\d)*)?\.\d(?:_?\d)*)([eE][+-]?\d(?:_?\d)*)?', Number.Float), |
365 (r'\d+[eE][+-]?[0-9]+j?', Number.Float), |
365 (r'\d(?:_?\d)*[eE][+-]?\d(?:_?\d)*j?', Number.Float), |
366 (r'0[oO][0-7]+', Number.Oct), |
366 (r'0[oO](?:_?[0-7])+', Number.Oct), |
367 (r'0[bB][01]+', Number.Bin), |
367 (r'0[bB](?:_?[01])+', Number.Bin), |
368 (r'0[xX][a-fA-F0-9]+', Number.Hex), |
368 (r'0[xX](?:_?[a-fA-F0-9])+', Number.Hex), |
369 (r'\d+', Number.Integer) |
369 (r'\d(?:_?\d)*', Number.Integer) |
370 ] |
370 ] |
371 tokens['backtick'] = [] |
371 tokens['backtick'] = [] |
372 tokens['name'] = [ |
372 tokens['name'] = [ |
373 (r'@\w+', Name.Decorator), |
373 (r'@\w+', Name.Decorator), |
374 (r'@', Operator), # new matrix multiplication operator |
374 (r'@', Operator), # new matrix multiplication operator |
669 'backtick': [ |
670 'backtick': [ |
670 ('`.*?`', String.Backtick), |
671 ('`.*?`', String.Backtick), |
671 ], |
672 ], |
672 'name': [ |
673 'name': [ |
673 (r'@\w+', Name.Decorator), |
674 (r'@\w+', Name.Decorator), |
674 ('[a-zA-Z_]\w*', Name), |
675 (r'[a-zA-Z_]\w*', Name), |
675 ], |
676 ], |
676 'funcname': [ |
677 'funcname': [ |
677 ('[a-zA-Z_]\w*', Name.Function, '#pop') |
678 (r'[a-zA-Z_]\w*', Name.Function, '#pop') |
678 ], |
679 ], |
679 'cdef': [ |
680 'cdef': [ |
680 (r'(public|readonly|extern|api|inline)\b', Keyword.Reserved), |
681 (r'(public|readonly|extern|api|inline)\b', Keyword.Reserved), |
681 (r'(struct|enum|union|class)\b', Keyword), |
682 (r'(struct|enum|union|class)\b', Keyword), |
682 (r'([a-zA-Z_]\w*)(\s*)(?=[(:#=]|$)', |
683 (r'([a-zA-Z_]\w*)(\s*)(?=[(:#=]|$)', |
689 (r'(?=["\'])', Text, '#pop'), |
690 (r'(?=["\'])', Text, '#pop'), |
690 (r'[a-zA-Z_]\w*', Keyword.Type), |
691 (r'[a-zA-Z_]\w*', Keyword.Type), |
691 (r'.', Text), |
692 (r'.', Text), |
692 ], |
693 ], |
693 'classname': [ |
694 'classname': [ |
694 ('[a-zA-Z_]\w*', Name.Class, '#pop') |
695 (r'[a-zA-Z_]\w*', Name.Class, '#pop') |
695 ], |
696 ], |
696 'import': [ |
697 'import': [ |
697 (r'(\s+)(as)(\s+)', bygroups(Text, Keyword, Text)), |
698 (r'(\s+)(as)(\s+)', bygroups(Text, Keyword, Text)), |
698 (r'[a-zA-Z_][\w.]*', Name.Namespace), |
699 (r'[a-zA-Z_][\w.]*', Name.Namespace), |
699 (r'(\s*)(,)(\s*)', bygroups(Text, Operator, Text)), |
700 (r'(\s*)(,)(\s*)', bygroups(Text, Operator, Text)), |