本文整理汇总了Python中pygments.token.Token.Other方法的典型用法代码示例。如果您正苦于以下问题:Python Token.Other方法的具体用法?Python Token.Other怎么用?Python Token.Other使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pygments.token.Token
的用法示例。
在下文中一共展示了Token.Other方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_string_escaping_run
# 需要导入模块: from pygments.token import Token [as 别名]
# 或者: from pygments.token.Token import Other [as 别名]
def test_string_escaping_run(lexer):
fragment = '<?php $x="{\\""; ?>\n'
tokens = [
(Token.Comment.Preproc, '<?php'),
(Token.Text, ' '),
(Token.Name.Variable, '$x'),
(Token.Operator, '='),
(Token.Literal.String.Double, '"'),
(Token.Literal.String.Double, '{'),
(Token.Literal.String.Escape, '\\"'),
(Token.Literal.String.Double, '"'),
(Token.Punctuation, ';'),
(Token.Text, ' '),
(Token.Comment.Preproc, '?>'),
(Token.Other, '\n'),
]
assert list(lexer.get_tokens(fragment)) == tokens
示例2: test_nested_curly
# 需要导入模块: from pygments.token import Token [as 别名]
# 或者: from pygments.token.Token import Other [as 别名]
def test_nested_curly(lexer):
fragment = u'{templateFunction param={anotherFunction} param2=$something}\n'
tokens = [
(Token.Comment.Preproc, u'{'),
(Token.Name.Function, u'templateFunction'),
(Token.Text, u' '),
(Token.Name.Attribute, u'param'),
(Token.Operator, u'='),
(Token.Comment.Preproc, u'{'),
(Token.Name.Attribute, u'anotherFunction'),
(Token.Comment.Preproc, u'}'),
(Token.Text, u' '),
(Token.Name.Attribute, u'param2'),
(Token.Operator, u'='),
(Token.Name.Variable, u'$something'),
(Token.Comment.Preproc, u'}'),
(Token.Other, u'\n'),
]
assert list(lexer.get_tokens(fragment)) == tokens
示例3: color_line
# 需要导入模块: from pygments.token import Token [as 别名]
# 或者: from pygments.token.Token import Other [as 别名]
def color_line(self, line):
"""
"""
lexer = CLexer()
tokens = list(lexer.get_tokens(line))
new_line = ""
for t in tokens:
ttype = t[0]
ttext = str(t[1])
if ttype == Token.Text:
new_line += idaapi.COLSTR(ttext, idaapi.SCOLOR_INSN)
elif ttype == Token.Text.Whitespace:
new_line += idaapi.COLSTR(ttext, idaapi.SCOLOR_INSN)
elif ttype == Token.Error:
new_line += idaapi.COLSTR(ttext, idaapi.SCOLOR_ERROR)
elif ttype == Token.Other:
new_line += idaapi.COLSTR(ttext, idaapi.SCOLOR_DSTR)
elif ttype == Token.Keyword:
new_line += idaapi.COLSTR(ttext, idaapi.SCOLOR_KEYWORD)
elif ttype == Token.Name:
new_line += idaapi.COLSTR(ttext, idaapi.SCOLOR_LIBNAME)
elif ttype == Token.Literal:
new_line += idaapi.COLSTR(ttext, idaapi.SCOLOR_LOCNAME)
elif ttype == Token.Literal.String:
new_line += idaapi.COLSTR(ttext, idaapi.SCOLOR_STRING)
elif ttype == Token.Literal.Number:
new_line += idaapi.COLSTR(ttext, idaapi.SCOLOR_DNUM)
elif ttype == Token.Operator:
new_line += idaapi.COLSTR(ttext, idaapi.SCOLOR_ALTOP)
elif ttype == Token.Punctuation:
new_line += idaapi.COLSTR(ttext, idaapi.SCOLOR_SYMBOL)
elif ttype == Token.Comment:
new_line += idaapi.COLSTR(ttext, idaapi.SCOLOR_REGCMT)
elif ttype == Token.Comment.Single:
new_line += idaapi.COLSTR(ttext, idaapi.SCOLOR_REGCMT)
elif ttype == Token.Generic:
new_line += idaapi.COLSTR(ttext, idaapi.SCOLOR_CREFTAIL)
else:
new_line += idaapi.COLSTR(ttext, idaapi.SCOLOR_CREFTAIL)
return new_line