console.py 4.0 KB

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