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

11 statements  

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

1""" 

2 pygments.lexers.pointless 

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

4 

5 Lexers for Pointless. 

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 Comment, Error, Keyword, Name, Number, Operator, \ 

13 Punctuation, String, Text 

14 

15__all__ = ['PointlessLexer'] 

16 

17 

18class PointlessLexer(RegexLexer): 

19 """ 

20 For Pointless source code. 

21 

22 .. versionadded:: 2.7 

23 """ 

24 

25 name = 'Pointless' 

26 url = 'https://ptls.dev' 

27 aliases = ['pointless'] 

28 filenames = ['*.ptls'] 

29 

30 ops = words([ 

31 "+", "-", "*", "/", "**", "%", "+=", "-=", "*=", 

32 "/=", "**=", "%=", "|>", "=", "==", "!=", "<", ">", 

33 "<=", ">=", "=>", "$", "++", 

34 ]) 

35 

36 keywords = words([ 

37 "if", "then", "else", "where", "with", "cond", 

38 "case", "and", "or", "not", "in", "as", "for", 

39 "requires", "throw", "try", "catch", "when", 

40 "yield", "upval", 

41 ], suffix=r'\b') 

42 

43 tokens = { 

44 'root': [ 

45 (r'[ \n\r]+', Text), 

46 (r'--.*$', Comment.Single), 

47 (r'"""', String, 'multiString'), 

48 (r'"', String, 'string'), 

49 (r'[\[\](){}:;,.]', Punctuation), 

50 (ops, Operator), 

51 (keywords, Keyword), 

52 (r'\d+|\d*\.\d+', Number), 

53 (r'(true|false)\b', Name.Builtin), 

54 (r'[A-Z][a-zA-Z0-9]*\b', String.Symbol), 

55 (r'output\b', Name.Variable.Magic), 

56 (r'(export|import)\b', Keyword.Namespace), 

57 (r'[a-z][a-zA-Z0-9]*\b', Name.Variable) 

58 ], 

59 'multiString': [ 

60 (r'\\.', String.Escape), 

61 (r'"""', String, '#pop'), 

62 (r'"', String), 

63 (r'[^\\"]+', String), 

64 ], 

65 'string': [ 

66 (r'\\.', String.Escape), 

67 (r'"', String, '#pop'), 

68 (r'\n', Error), 

69 (r'[^\\"]+', String), 

70 ], 

71 }