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

9 statements  

« prev     ^ index     » next       coverage.py v7.2.7, created at 2023-06-07 06:16 +0000

1""" 

2 pygments.lexers.nit 

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

4 

5 Lexer for the Nit language. 

6 

7 :copyright: Copyright 2006-2023 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 .. versionadded:: 2.0 

23 """ 

24 

25 name = 'Nit' 

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

27 aliases = ['nit'] 

28 filenames = ['*.nit'] 

29 tokens = { 

30 'root': [ 

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

32 (words(( 

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

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

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

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

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

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

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

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

41 Keyword), 

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

63 ], 

64 }