當前位置: 首頁>>代碼示例>>Python>>正文


Python lexers.CppLexer方法代碼示例

本文整理匯總了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() 
開發者ID:joxeankoret,項目名稱:maltindex,代碼行數:25,代碼來源:diaphora_ida.py

示例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() 
開發者ID:joxeankoret,項目名稱:diaphora,代碼行數:25,代碼來源:diaphora_ida.py

示例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" ]) 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:11,代碼來源:test_completion_lexer.py

示例4: lexer

# 需要導入模塊: from pygments import lexers [as 別名]
# 或者: from pygments.lexers import CppLexer [as 別名]
def lexer():
    yield CppLexer() 
開發者ID:pygments,項目名稱:pygments,代碼行數:4,代碼來源:test_cpp.py

示例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() 
開發者ID:joxeankoret,項目名稱:diaphora,代碼行數:59,代碼來源:diaphora_ida.py


注:本文中的pygments.lexers.CppLexer方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。