eric6/ThirdParty/Pygments/pygments/lexers/pony.py

changeset 7547
21b0534faebc
child 7701
25f42e208e08
equal deleted inserted replaced
7546:bf5f777260a6 7547:21b0534faebc
1 # -*- coding: utf-8 -*-
2 """
3 pygments.lexers.pony
4 ~~~~~~~~~~~~~~~~~~~~
5
6 Lexers for Pony and related languages.
7
8 :copyright: Copyright 2006-2019 by the Pygments team, see AUTHORS.
9 :license: BSD, see LICENSE for details.
10 """
11
12 from pygments.lexer import RegexLexer, bygroups, words
13 from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
14 Number, Punctuation
15
16 __all__ = ['PonyLexer']
17
18
19 class PonyLexer(RegexLexer):
20 """
21 For Pony source code.
22
23 .. versionadded:: 2.4
24 """
25
26 name = 'Pony'
27 aliases = ['pony']
28 filenames = ['*.pony']
29
30 _caps = r'(iso|trn|ref|val|box|tag)'
31
32 tokens = {
33 'root': [
34 (r'\n', Text),
35 (r'[^\S\n]+', Text),
36 (r'//.*\n', Comment.Single),
37 (r'/\*', Comment.Multiline, 'nested_comment'),
38 (r'"""(?:.|\n)*?"""', String.Doc),
39 (r'"', String, 'string'),
40 (r'\'.*\'', String.Char),
41 (r'=>|[]{}:().~;,|&!^?[]', Punctuation),
42 (words((
43 'addressof', 'and', 'as', 'consume', 'digestof', 'is', 'isnt',
44 'not', 'or'),
45 suffix=r'\b'),
46 Operator.Word),
47 (r'!=|==|<<|>>|[-+/*%=<>]', Operator),
48 (words((
49 'box', 'break', 'compile_error', 'compile_intrinsic',
50 'continue', 'do', 'else', 'elseif', 'embed', 'end', 'error',
51 'for', 'if', 'ifdef', 'in', 'iso', 'lambda', 'let', 'match',
52 'object', 'recover', 'ref', 'repeat', 'return', 'tag', 'then',
53 'this', 'trn', 'try', 'until', 'use', 'var', 'val', 'where',
54 'while', 'with', '#any', '#read', '#send', '#share'),
55 suffix=r'\b'),
56 Keyword),
57 (r'(actor|class|struct|primitive|interface|trait|type)((?:\s)+)',
58 bygroups(Keyword, Text), 'typename'),
59 (r'(new|fun|be)((?:\s)+)', bygroups(Keyword, Text), 'methodname'),
60 (words((
61 'I8', 'U8', 'I16', 'U16', 'I32', 'U32', 'I64', 'U64', 'I128',
62 'U128', 'ILong', 'ULong', 'ISize', 'USize', 'F32', 'F64',
63 'Bool', 'Pointer', 'None', 'Any', 'Array', 'String',
64 'Iterator'),
65 suffix=r'\b'),
66 Name.Builtin.Type),
67 (r'_?[A-Z]\w*', Name.Type),
68 (r'(\d+\.\d*|\.\d+|\d+)[eE][+-]?\d+', Number.Float),
69 (r'0x[0-9a-fA-F]+', Number.Hex),
70 (r'\d+', Number.Integer),
71 (r'(true|false)\b', Name.Builtin),
72 (r'_\d*', Name),
73 (r'_?[a-z][\w\'_]*', Name)
74 ],
75 'typename': [
76 (_caps + r'?((?:\s)*)(_?[A-Z]\w*)',
77 bygroups(Keyword, Text, Name.Class), '#pop')
78 ],
79 'methodname': [
80 (_caps + r'?((?:\s)*)(_?[a-z]\w*)',
81 bygroups(Keyword, Text, Name.Function), '#pop')
82 ],
83 'nested_comment': [
84 (r'[^*/]+', Comment.Multiline),
85 (r'/\*', Comment.Multiline, '#push'),
86 (r'\*/', Comment.Multiline, '#pop'),
87 (r'[*/]', Comment.Multiline)
88 ],
89 'string': [
90 (r'"', String, '#pop'),
91 (r'\\"', String),
92 (r'[^\\"]+', String)
93 ]
94 }

eric ide

mercurial