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

13 statements  

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

1""" 

2 pygments.lexers.comal 

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

4 

5 Lexer for COMAL-80. 

6 

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

8 :license: BSD, see LICENSE for details. 

9""" 

10 

11import re 

12 

13from pygments.lexer import RegexLexer, words 

14from pygments.token import Comment, Whitespace, Operator, Keyword, String, \ 

15 Number, Name, Punctuation 

16 

17__all__ = ["Comal80Lexer"] 

18 

19 

20class Comal80Lexer(RegexLexer): 

21 """ 

22 For COMAL-80 source code. 

23 """ 

24 

25 name = 'COMAL-80' 

26 url = 'https://en.wikipedia.org/wiki/COMAL' 

27 aliases = ['comal', 'comal80'] 

28 filenames = ['*.cml', '*.comal'] 

29 flags = re.IGNORECASE 

30 # 

31 # COMAL allows for some strange characters in names which we list here so 

32 # keywords and word operators will not be recognized at the start of an 

33 # identifier. 

34 # 

35 _suffix = r"\b(?!['\[\]←£\\])" 

36 _identifier = r"[a-z]['\[\]←£\\\w]*" 

37 

38 tokens = { 

39 'root': [ 

40 (r'//.*\n', Comment.Single), 

41 (r'\s+', Whitespace), 

42 (r':[=+-]|\<\>|[-+*/^↑<>=]', Operator), 

43 (r'(and +then|or +else)' + _suffix, Operator.Word), 

44 (words([ 

45 'and', 'bitand', 'bitor', 'bitxor', 'div', 'in', 'mod', 'not', 

46 'or'], suffix=_suffix,), Operator.Word), 

47 (words([ 

48 'append', 'at', 'case', 'chain', 'close', 'copy', 'create', 'cursor', 

49 'data', 'delete', 'dir', 'do', 'elif', 'else', 'end', 'endcase', 'endif', 

50 'endfor', 'endloop', 'endtrap', 'endwhile', 'exec', 'exit', 'file', 

51 'for', 'goto', 'handler', 'if', 'input', 'let', 'loop', 'mount', 'null', 

52 'of', 'open', 'otherwise', 'output', 'page', 'pass', 'poke', 'print', 

53 'random', 'read', 'repeat', 'report', 'return', 'rename', 'restore', 

54 'select', 'step', 'stop', 'sys', 'then', 'to', 'trap', 'unit', 'unit$', 

55 'until', 'using', 'when', 'while', 'write', 'zone'], suffix=_suffix), 

56 Keyword.Reserved), 

57 (words([ 

58 'closed', 'dim', 'endfunc', 'endproc', 'external', 'func', 'import', 

59 'proc', 'ref', 'use'], suffix=_suffix), Keyword.Declaration), 

60 (words([ 

61 'abs', 'atn', 'chr$', 'cos', 'eod', 'eof', 'err', 'errfile', 'errtext', 

62 'esc', 'exp', 'int', 'key$', 'len', 'log', 'ord', 'peek', 'randomize', 

63 'rnd', 'sgn', 'sin', 'spc$', 'sqr', 'status$', 'str$', 'tab', 'tan', 

64 'time', 'val'], suffix=_suffix), Name.Builtin), 

65 (words(['false', 'pi', 'true'], suffix=_suffix), Keyword.Constant), 

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

67 (_identifier + r":(?=[ \n/])", Name.Label), 

68 (_identifier + r"[$#]?", Name), 

69 (r'%[01]+', Number.Bin), 

70 (r'\$[0-9a-f]+', Number.Hex), 

71 (r'\d*\.\d*(e[-+]?\d+)?', Number.Float), 

72 (r'\d+', Number.Integer), 

73 (r'[(),:;]', Punctuation), 

74 ], 

75 'string': [ 

76 (r'[^"]+', String), 

77 (r'"[0-9]*"', String.Escape), 

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

79 ], 

80 }