Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/pygments/lexers/numbair.py: 100%

Shortcuts on this page

r m x   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

14 statements  

1""" 

2 pygments.lexers.numbair 

3 ~~~~~~~~~~~~~~~~~~~~~~~ 

4 

5 Lexer for other Numba Intermediate Representation. 

6 

7 :copyright: Copyright 2006-2025 by the Pygments team, see AUTHORS. 

8 :license: BSD, see LICENSE for details. 

9""" 

10 

11from pygments.lexer import RegexLexer, include, bygroups, words 

12from pygments.token import Whitespace, Name, String, Punctuation, Keyword, \ 

13 Operator, Number 

14 

15__all__ = ["NumbaIRLexer"] 

16 

17class NumbaIRLexer(RegexLexer): 

18 """ 

19 Lexer for Numba IR 

20 """ 

21 name = 'Numba_IR' 

22 url = "https://numba.readthedocs.io/en/stable/developer/architecture.html#stage-2-generate-the-numba-ir" 

23 aliases = ['numba_ir', 'numbair'] 

24 filenames = ['*.numba_ir'] 

25 mimetypes = ['text/x-numba_ir', 'text/x-numbair'] 

26 version_added = '2.19' 

27 

28 identifier = r'\$[a-zA-Z0-9._]+' 

29 fun_or_var = r'([a-zA-Z_]+[a-zA-Z0-9]*)' 

30 

31 tokens = { 

32 'root' : [ 

33 (r'(label)(\ [0-9]+)(:)$', 

34 bygroups(Keyword, Name.Label, Punctuation)), 

35 

36 (r'=', Operator), 

37 include('whitespace'), 

38 include('keyword'), 

39 

40 (identifier, Name.Variable), 

41 (fun_or_var + r'(\()', 

42 bygroups(Name.Function, Punctuation)), 

43 (fun_or_var + r'(\=)', 

44 bygroups(Name.Attribute, Punctuation)), 

45 (fun_or_var, Name.Constant), 

46 (r'[0-9]+', Number), 

47 

48 # <built-in function some> 

49 (r'<[^>\n]*>', String), 

50 

51 (r'[=<>{}\[\]()*.,!\':]|x\b', Punctuation) 

52 ], 

53 

54 'keyword':[ 

55 (words(( 

56 'del', 'jump', 'call', 'branch', 

57 ), suffix=' '), Keyword), 

58 ], 

59 

60 'whitespace': [ 

61 (r'(\n|\s)+', Whitespace), 

62 ], 

63 }