console.py 4.0 KB

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