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