console.py 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. """
  2. pygments.lexers.console
  3. ~~~~~~~~~~~~~~~~~~~~~~~
  4. Lexers for misc console output.
  5. :copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
  6. :license: BSD, see LICENSE for details.
  7. """
  8. from pygments.lexer import RegexLexer, include, bygroups, words
  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. (words(('int_add_ovf', 'int_add', 'int_sub_ovf', 'int_sub',
  68. 'int_mul_ovf', 'int_mul', 'int_floordiv',
  69. 'int_mod', 'int_lshift', 'int_rshift',
  70. 'int_and', 'int_or', 'int_xor', 'int_eq',
  71. 'int_ne', 'int_ge', 'int_gt', 'int_le',
  72. 'int_lt', 'int_is_zero', 'int_is_true',
  73. 'uint_floordiv', 'uint_ge', 'uint_lt',
  74. 'float_add', 'float_sub', 'float_mul',
  75. 'float_truediv', 'float_neg', 'float_eq',
  76. 'float_ne', 'float_ge', 'float_gt',
  77. 'float_le', 'float_lt', 'float_abs',
  78. 'ptr_eq', 'ptr_ne', 'instance_ptr_eq',
  79. 'instance_ptr_ne', 'cast_int_to_float',
  80. 'cast_float_to_int', 'force_token',
  81. 'quasiimmut_field', 'same_as',
  82. 'virtual_ref_finish', 'virtual_ref',
  83. 'mark_opaque_ptr', 'call_may_force',
  84. 'call_assembler', 'call_loopinvariant',
  85. 'call_release_gil', 'call_pure', 'call',
  86. 'new_with_vtable', 'new_array', 'newstr',
  87. 'newunicode', 'new', 'arraylen_gc',
  88. 'getarrayitem_gc_pure', 'getarrayitem_gc',
  89. 'setarrayitem_gc', 'getarrayitem_raw',
  90. 'setarrayitem_raw', 'getfield_gc_pure',
  91. 'getfield_gc', 'getinteriorfield_gc',
  92. 'setinteriorfield_gc', 'getfield_raw',
  93. 'setfield_gc', 'setfield_raw', 'strgetitem',
  94. 'strsetitem', 'strlen', 'copystrcontent',
  95. 'unicodegetitem', 'unicodesetitem',
  96. 'unicodelen', 'guard_true', 'guard_false',
  97. 'guard_value', 'guard_isnull',
  98. 'guard_nonnull_class', 'guard_nonnull',
  99. 'guard_class', 'guard_no_overflow',
  100. 'guard_not_forced', 'guard_no_exception',
  101. 'guard_not_invalidated')),
  102. Name.Builtin),
  103. include("extra-stuff"),
  104. ],
  105. "jit-backend-counts": [
  106. (r"\[\w+\] jit-backend-counts}$", Keyword, "#pop"),
  107. (r":", Punctuation),
  108. (r"\d+", Number),
  109. include("extra-stuff"),
  110. ],
  111. "extra-stuff": [
  112. (r"\s+", Whitespace),
  113. (r"#.*?$", Comment),
  114. ],
  115. }