Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/pygments/lexers/nit.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

11 statements  

1""" 

2 pygments.lexers.nit 

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

4 

5 Lexer for the Nit language. 

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, words 

12from pygments.token import Text, Comment, Operator, Keyword, Name, String, \ 

13 Number, Punctuation 

14 

15__all__ = ['NitLexer'] 

16 

17 

18class NitLexer(RegexLexer): 

19 """ 

20 For nit source. 

21 """ 

22 

23 name = 'Nit' 

24 url = 'http://nitlanguage.org' 

25 aliases = ['nit'] 

26 filenames = ['*.nit'] 

27 version_added = '2.0' 

28 tokens = { 

29 'root': [ 

30 (r'#.*?$', Comment.Single), 

31 (words(( 

32 'package', 'module', 'import', 'class', 'abstract', 'interface', 

33 'universal', 'enum', 'end', 'fun', 'type', 'init', 'redef', 

34 'isa', 'do', 'readable', 'writable', 'var', 'intern', 'extern', 

35 'public', 'protected', 'private', 'intrude', 'if', 'then', 

36 'else', 'while', 'loop', 'for', 'in', 'and', 'or', 'not', 

37 'implies', 'return', 'continue', 'break', 'abort', 'assert', 

38 'new', 'is', 'once', 'super', 'self', 'true', 'false', 'nullable', 

39 'null', 'as', 'isset', 'label', '__debug__'), suffix=r'(?=[\r\n\t( ])'), 

40 Keyword), 

41 (r'[A-Z]\w*', Name.Class), 

42 (r'"""(([^\'\\]|\\.)|\\r|\\n)*((\{\{?)?(""?\{\{?)*""""*)', String), # Simple long string 

43 (r'\'\'\'(((\\.|[^\'\\])|\\r|\\n)|\'((\\.|[^\'\\])|\\r|\\n)|' 

44 r'\'\'((\\.|[^\'\\])|\\r|\\n))*\'\'\'', String), # Simple long string alt 

45 (r'"""(([^\'\\]|\\.)|\\r|\\n)*((""?)?(\{\{?""?)*\{\{\{\{*)', String), # Start long string 

46 (r'\}\}\}(((\\.|[^\'\\])|\\r|\\n))*(""?)?(\{\{?""?)*\{\{\{\{*', String), # Mid long string 

47 (r'\}\}\}(((\\.|[^\'\\])|\\r|\\n))*(\{\{?)?(""?\{\{?)*""""*', String), # End long string 

48 (r'"(\\.|([^"}{\\]))*"', String), # Simple String 

49 (r'"(\\.|([^"}{\\]))*\{', String), # Start string 

50 (r'\}(\\.|([^"}{\\]))*\{', String), # Mid String 

51 (r'\}(\\.|([^"}{\\]))*"', String), # End String 

52 (r'(\'[^\'\\]\')|(\'\\.\')', String.Char), 

53 (r'[0-9]+', Number.Integer), 

54 (r'[0-9]*.[0-9]+', Number.Float), 

55 (r'0(x|X)[0-9A-Fa-f]+', Number.Hex), 

56 (r'[a-z]\w*', Name), 

57 (r'_\w+', Name.Variable.Instance), 

58 (r'==|!=|<==>|>=|>>|>|<=|<<|<|\+|-|=|/|\*|%|\+=|-=|!|@', Operator), 

59 (r'\(|\)|\[|\]|,|\.\.\.|\.\.|\.|::|:', Punctuation), 

60 (r'`\{[^`]*`\}', Text), # Extern blocks won't be Lexed by Nit 

61 (r'[\r\n\t ]+', Text), 

62 ], 

63 }