Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/pygments/lexers/ooc.py: 100%
10 statements
« prev ^ index » next coverage.py v7.2.7, created at 2023-06-07 06:16 +0000
« prev ^ index » next coverage.py v7.2.7, created at 2023-06-07 06:16 +0000
1"""
2 pygments.lexers.ooc
3 ~~~~~~~~~~~~~~~~~~~
5 Lexers for the Ooc language.
7 :copyright: Copyright 2006-2023 by the Pygments team, see AUTHORS.
8 :license: BSD, see LICENSE for details.
9"""
11from pygments.lexer import RegexLexer, bygroups, words
12from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
13 Number, Punctuation
15__all__ = ['OocLexer']
18class OocLexer(RegexLexer):
19 """
20 For Ooc source code
22 .. versionadded:: 1.2
23 """
24 name = 'Ooc'
25 url = 'http://ooc-lang.org/'
26 aliases = ['ooc']
27 filenames = ['*.ooc']
28 mimetypes = ['text/x-ooc']
30 tokens = {
31 'root': [
32 (words((
33 'class', 'interface', 'implement', 'abstract', 'extends', 'from',
34 'this', 'super', 'new', 'const', 'final', 'static', 'import',
35 'use', 'extern', 'inline', 'proto', 'break', 'continue',
36 'fallthrough', 'operator', 'if', 'else', 'for', 'while', 'do',
37 'switch', 'case', 'as', 'in', 'version', 'return', 'true',
38 'false', 'null'), prefix=r'\b', suffix=r'\b'),
39 Keyword),
40 (r'include\b', Keyword, 'include'),
41 (r'(cover)([ \t]+)(from)([ \t]+)(\w+[*@]?)',
42 bygroups(Keyword, Text, Keyword, Text, Name.Class)),
43 (r'(func)((?:[ \t]|\\\n)+)(~[a-z_]\w*)',
44 bygroups(Keyword, Text, Name.Function)),
45 (r'\bfunc\b', Keyword),
46 # Note: %= and ^= not listed on http://ooc-lang.org/syntax
47 (r'//.*', Comment),
48 (r'(?s)/\*.*?\*/', Comment.Multiline),
49 (r'(==?|\+=?|-[=>]?|\*=?|/=?|:=|!=?|%=?|\?|>{1,3}=?|<{1,3}=?|\.\.|'
50 r'&&?|\|\|?|\^=?)', Operator),
51 (r'(\.)([ \t]*)([a-z]\w*)', bygroups(Operator, Text,
52 Name.Function)),
53 (r'[A-Z][A-Z0-9_]+', Name.Constant),
54 (r'[A-Z]\w*([@*]|\[[ \t]*\])?', Name.Class),
56 (r'([a-z]\w*(?:~[a-z]\w*)?)((?:[ \t]|\\\n)*)(?=\()',
57 bygroups(Name.Function, Text)),
58 (r'[a-z]\w*', Name.Variable),
60 # : introduces types
61 (r'[:(){}\[\];,]', Punctuation),
63 (r'0x[0-9a-fA-F]+', Number.Hex),
64 (r'0c[0-9]+', Number.Oct),
65 (r'0b[01]+', Number.Bin),
66 (r'[0-9_]\.[0-9_]*(?!\.)', Number.Float),
67 (r'[0-9_]+', Number.Decimal),
69 (r'"(?:\\.|\\[0-7]{1,3}|\\x[a-fA-F0-9]{1,2}|[^\\"])*"',
70 String.Double),
71 (r"'(?:\\.|\\[0-9]{1,3}|\\x[a-fA-F0-9]{1,2}|[^\\\'\n])'",
72 String.Char),
73 (r'@', Punctuation), # pointer dereference
74 (r'\.', Punctuation), # imports or chain operator
76 (r'\\[ \t\n]', Text),
77 (r'[ \t]+', Text),
78 ],
79 'include': [
80 (r'[\w/]+', Name),
81 (r',', Punctuation),
82 (r'[ \t]', Text),
83 (r'[;\n]', Text, '#pop'),
84 ],
85 }