Fix bugs???
This commit is contained in:
parent
653a5a6575
commit
8e8d1a583a
6
bot.py
6
bot.py
|
@ -1,8 +1,8 @@
|
|||
#!/usr/bin/python
|
||||
|
||||
network = "localhost"
|
||||
nick = "skybot"
|
||||
channel = "#test"
|
||||
network = "irc.synirc.net"
|
||||
nick = "skybotisgay"
|
||||
channel = "#cobol"
|
||||
|
||||
import sys
|
||||
import os
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
from util import hook
|
||||
from pycparser.cdecl import explain_c_declaration
|
||||
|
||||
@hook.command('explain')
|
||||
|
@ -7,8 +8,12 @@ foo is a array of array[8] of pointer to pointer to function() returning pointer
|
|||
to array of pointer to char
|
||||
'''
|
||||
if not inp:
|
||||
return None
|
||||
return ""
|
||||
|
||||
try:
|
||||
result = explain_c_declaration(inp.rstrip())
|
||||
except e:
|
||||
result = str(e)
|
||||
|
||||
return result
|
||||
|
||||
result = explain_c_declaration(inp)
|
||||
if result: return result
|
||||
else: return None
|
|
@ -34,14 +34,11 @@ def explain_c_declaration(c_decl):
|
|||
"""
|
||||
parser = c_parser.CParser()
|
||||
|
||||
try:
|
||||
node = parser.parse(c_decl, filename='<stdin>')
|
||||
except c_parser.ParseError, e:
|
||||
return None
|
||||
node = parser.parse(c_decl, filename='<stdin>')
|
||||
|
||||
if ( not isinstance(node, c_ast.FileAST) or
|
||||
not isinstance(node.ext[-1], c_ast.Decl)):
|
||||
return None
|
||||
return "Last external node is invalid type"
|
||||
|
||||
return _explain_decl_node(node.ext[-1])
|
||||
|
||||
|
|
Loading…
Reference in New Issue