console.py 4.1 KB

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