本文整理汇总了Python中pygments.lexers.CppLexer方法的典型用法代码示例。如果您正苦于以下问题:Python lexers.CppLexer方法的具体用法?Python lexers.CppLexer怎么用?Python lexers.CppLexer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pygments.lexers
的用法示例。
在下文中一共展示了lexers.CppLexer方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: show_pseudo
# 需要导入模块: from pygments import lexers [as 别名]
# 或者: from pygments.lexers import CppLexer [as 别名]
def show_pseudo(self, item, primary):
cur = self.db_cursor()
if primary:
db = "main"
else:
db = "diff"
ea = str(int(item[1], 16))
sql = "select prototype, pseudocode, name from %s.functions where address = ?"
sql = sql % db
cur.execute(sql, (str(ea), ))
row = cur.fetchone()
if row is None or row["prototype"] is None or row["pseudocode"] is None:
Warning("Sorry, there is no pseudo-code available for the selected function.")
else:
fmt = HtmlFormatter()
fmt.noclasses = True
fmt.linenos = True
func = "%s\n%s" % (row["prototype"], row["pseudocode"])
src = highlight(func, CppLexer(), fmt)
title = "Pseudo-code for %s" % row["name"]
cdiffer = CHtmlViewer()
cdiffer.Show(src, title)
cur.close()
示例2: show_pseudo
# 需要导入模块: from pygments import lexers [as 别名]
# 或者: from pygments.lexers import CppLexer [as 别名]
def show_pseudo(self, item, primary):
cur = self.db_cursor()
if primary:
db = "main"
else:
db = "diff"
ea = str(int(item[1], 16))
sql = "select prototype, pseudocode, name from %s.functions where address = ?"
sql = sql % db
cur.execute(sql, (str(ea), ))
row = cur.fetchone()
if row is None or row["prototype"] is None or row["pseudocode"] is None:
warning("Sorry, there is no pseudo-code available for the selected function.")
else:
fmt = HtmlFormatter()
fmt.noclasses = True
fmt.linenos = True
func = "%s\n%s" % (row["prototype"], row["pseudocode"])
src = highlight(func, CppLexer(), fmt)
title = "Pseudo-code for %s" % row["name"]
cdiffer = CHtmlViewer()
cdiffer.Show(src, title)
cur.close()
示例3: testC
# 需要导入模块: from pygments import lexers [as 别名]
# 或者: from pygments.lexers import CppLexer [as 别名]
def testC(self):
""" Does the CompletionLexer work for C/C++?
"""
lexer = CompletionLexer(CLexer())
self.assertEqual(lexer.get_context("foo.bar"), [ "foo", "bar" ])
self.assertEqual(lexer.get_context("foo->bar"), [ "foo", "bar" ])
lexer = CompletionLexer(CppLexer())
self.assertEqual(lexer.get_context("Foo::Bar"), [ "Foo", "Bar" ])
示例4: lexer
# 需要导入模块: from pygments import lexers [as 别名]
# 或者: from pygments.lexers import CppLexer [as 别名]
def lexer():
yield CppLexer()
示例5: show_pseudo_diff
# 需要导入模块: from pygments import lexers [as 别名]
# 或者: from pygments.lexers import CppLexer [as 别名]
def show_pseudo_diff(self, item, html = True):
cur = self.db_cursor()
sql = """select *
from (
select prototype, pseudocode, name, 1
from functions
where address = ?
and pseudocode is not null
union select prototype, pseudocode, name, 2
from diff.functions
where address = ?
and pseudocode is not null)
order by 4 asc"""
ea1 = str(int(item[1], 16))
ea2 = str(int(item[3], 16))
cur.execute(sql, (ea1, ea2))
rows = cur.fetchall()
if len(rows) != 2:
warning("Sorry, there is no pseudo-code available for either the first or the second database.")
else:
row1 = rows[0]
row2 = rows[1]
html_diff = CHtmlDiff()
proto1 = self.decompile_and_get(int(ea1))
if proto1:
buf1 = proto1 + "\n" + "\n".join(self.pseudo[int(ea1)])
else:
log("warning: cannot retrieve the current pseudo-code for the function, using the previously saved one...")
buf1 = row1["prototype"] + "\n" + row1["pseudocode"]
buf2 = row2["prototype"] + "\n" + row2["pseudocode"]
if buf1 == buf2:
warning("Both pseudo-codes are equal.")
return
fmt = HtmlFormatter()
fmt.noclasses = True
fmt.linenos = False
fmt.nobackground = True
if not html:
uni_diff = difflib.unified_diff(buf1.split("\n"), buf2.split("\n"))
tmp = []
for line in uni_diff:
tmp.append(line.strip("\n"))
tmp = tmp[2:]
buf = "\n".join(tmp)
src = highlight(buf, DiffLexer(), fmt)
else:
src = html_diff.make_file(buf1.split("\n"), buf2.split("\n"), fmt, CppLexer())
title = "Diff pseudo-code %s - %s" % (row1["name"], row2["name"])
cdiffer = CHtmlViewer()
cdiffer.Show(src, title)
cur.close()