1"""
2 pygments.lexers.console
3 ~~~~~~~~~~~~~~~~~~~~~~~
4
5 Lexers for misc console output.
6
7 :copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
8 :license: BSD, see LICENSE for details.
9"""
10
11from pygments.lexer import RegexLexer, include, bygroups, words
12from pygments.token import Generic, Comment, String, Text, Keyword, Name, \
13 Punctuation, Number, Whitespace
14
15__all__ = ['VCTreeStatusLexer', 'PyPyLogLexer']
16
17
18class VCTreeStatusLexer(RegexLexer):
19 """
20 For colorizing output of version control status commands, like "hg
21 status" or "svn status".
22 """
23 name = 'VCTreeStatus'
24 aliases = ['vctreestatus']
25 filenames = []
26 mimetypes = []
27 url = ""
28 version_added = '2.0'
29
30 tokens = {
31 'root': [
32 (r'^A \+ C\s+', Generic.Error),
33 (r'^A\s+\+?\s+', String),
34 (r'^M\s+', Generic.Inserted),
35 (r'^C\s+', Generic.Error),
36 (r'^D\s+', Generic.Deleted),
37 (r'^[?!]\s+', Comment.Preproc),
38 (r' >\s+.*\n', Comment.Preproc),
39 (r'\S+', Text),
40 (r'\s+', Whitespace),
41 ]
42 }
43
44
45class PyPyLogLexer(RegexLexer):
46 """
47 Lexer for PyPy log files.
48 """
49 name = "PyPy Log"
50 aliases = ["pypylog", "pypy"]
51 filenames = ["*.pypylog"]
52 mimetypes = ['application/x-pypylog']
53 url = 'pypy.org'
54 version_added = '1.5'
55
56 tokens = {
57 "root": [
58 (r"\[\w+\] \{jit-log-.*?$", Keyword, "jit-log"),
59 (r"\[\w+\] \{jit-backend-counts$", Keyword, "jit-backend-counts"),
60 include("extra-stuff"),
61 ],
62 "jit-log": [
63 (r"\[\w+\] jit-log-.*?}$", Keyword, "#pop"),
64 (r"^\+\d+: ", Comment),
65 (r"--end of the loop--", Comment),
66 (r"[ifp]\d+", Name),
67 (r"ptr\d+", Name),
68 (r"(\()(\w+(?:\.\w+)?)(\))",
69 bygroups(Punctuation, Name.Builtin, Punctuation)),
70 (r"[\[\]=,()]", Punctuation),
71 (r"(\d+\.\d+|inf|-inf)", Number.Float),
72 (r"-?\d+", Number.Integer),
73 (r"'.*'", String),
74 (r"(None|descr|ConstClass|ConstPtr|TargetToken)", Name),
75 (r"<.*?>+", Name.Builtin),
76 (r"(label|debug_merge_point|jump|finish)", Name.Class),
77 (words(('int_add_ovf', 'int_add', 'int_sub_ovf', 'int_sub',
78 'int_mul_ovf', 'int_mul', 'int_floordiv',
79 'int_mod', 'int_lshift', 'int_rshift',
80 'int_and', 'int_or', 'int_xor', 'int_eq',
81 'int_ne', 'int_ge', 'int_gt', 'int_le',
82 'int_lt', 'int_is_zero', 'int_is_true',
83 'uint_floordiv', 'uint_ge', 'uint_lt',
84 'float_add', 'float_sub', 'float_mul',
85 'float_truediv', 'float_neg', 'float_eq',
86 'float_ne', 'float_ge', 'float_gt',
87 'float_le', 'float_lt', 'float_abs',
88 'ptr_eq', 'ptr_ne', 'instance_ptr_eq',
89 'instance_ptr_ne', 'cast_int_to_float',
90 'cast_float_to_int', 'force_token',
91 'quasiimmut_field', 'same_as',
92 'virtual_ref_finish', 'virtual_ref',
93 'mark_opaque_ptr', 'call_may_force',
94 'call_assembler', 'call_loopinvariant',
95 'call_release_gil', 'call_pure', 'call',
96 'new_with_vtable', 'new_array', 'newstr',
97 'newunicode', 'new', 'arraylen_gc',
98 'getarrayitem_gc_pure', 'getarrayitem_gc',
99 'setarrayitem_gc', 'getarrayitem_raw',
100 'setarrayitem_raw', 'getfield_gc_pure',
101 'getfield_gc', 'getinteriorfield_gc',
102 'setinteriorfield_gc', 'getfield_raw',
103 'setfield_gc', 'setfield_raw', 'strgetitem',
104 'strsetitem', 'strlen', 'copystrcontent',
105 'unicodegetitem', 'unicodesetitem',
106 'unicodelen', 'guard_true', 'guard_false',
107 'guard_value', 'guard_isnull',
108 'guard_nonnull_class', 'guard_nonnull',
109 'guard_class', 'guard_no_overflow',
110 'guard_not_forced', 'guard_no_exception',
111 'guard_not_invalidated')),
112 Name.Builtin),
113 include("extra-stuff"),
114 ],
115 "jit-backend-counts": [
116 (r"\[\w+\] jit-backend-counts}$", Keyword, "#pop"),
117 (r":", Punctuation),
118 (r"\d+", Number),
119 include("extra-stuff"),
120 ],
121 "extra-stuff": [
122 (r"\s+", Whitespace),
123 (r"#.*?$", Comment),
124 ],
125 }