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

14 statements  

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

1""" 

2 pygments.lexers.x10 

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

4 

5 Lexers for the X10 programming 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 

12from pygments.token import Text, Comment, Keyword, String 

13 

14__all__ = ['X10Lexer'] 

15 

16 

17class X10Lexer(RegexLexer): 

18 """ 

19 For the X10 language. 

20 

21 .. versionadded:: 2.2 

22 """ 

23 

24 name = 'X10' 

25 url = 'http://x10-lang.org/' 

26 aliases = ['x10', 'xten'] 

27 filenames = ['*.x10'] 

28 mimetypes = ['text/x-x10'] 

29 

30 keywords = ( 

31 'as', 'assert', 'async', 'at', 'athome', 'ateach', 'atomic', 

32 'break', 'case', 'catch', 'class', 'clocked', 'continue', 

33 'def', 'default', 'do', 'else', 'final', 'finally', 'finish', 

34 'for', 'goto', 'haszero', 'here', 'if', 'import', 'in', 

35 'instanceof', 'interface', 'isref', 'new', 'offer', 

36 'operator', 'package', 'return', 'struct', 'switch', 'throw', 

37 'try', 'type', 'val', 'var', 'when', 'while' 

38 ) 

39 

40 types = ( 

41 'void' 

42 ) 

43 

44 values = ( 

45 'false', 'null', 'self', 'super', 'this', 'true' 

46 ) 

47 

48 modifiers = ( 

49 'abstract', 'extends', 'implements', 'native', 'offers', 

50 'private', 'property', 'protected', 'public', 'static', 

51 'throws', 'transient' 

52 ) 

53 

54 tokens = { 

55 'root': [ 

56 (r'[^\S\n]+', Text), 

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

58 (r'/\*(.|\n)*?\*/', Comment.Multiline), 

59 (r'\b(%s)\b' % '|'.join(keywords), Keyword), 

60 (r'\b(%s)\b' % '|'.join(types), Keyword.Type), 

61 (r'\b(%s)\b' % '|'.join(values), Keyword.Constant), 

62 (r'\b(%s)\b' % '|'.join(modifiers), Keyword.Declaration), 

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

64 (r"'\\.'|'[^\\]'|'\\u[0-9a-fA-F]{4}'", String.Char), 

65 (r'.', Text) 

66 ], 

67 }