Fix bugs???

This commit is contained in:
melonhead@grimace 2009-11-12 21:11:10 -05:00
parent 653a5a6575
commit 8e8d1a583a
3 changed files with 15 additions and 13 deletions

6
bot.py
View File

@ -1,8 +1,8 @@
#!/usr/bin/python #!/usr/bin/python
network = "localhost" network = "irc.synirc.net"
nick = "skybot" nick = "skybotisgay"
channel = "#test" channel = "#cobol"
import sys import sys
import os import os

View File

@ -1,3 +1,4 @@
from util import hook
from pycparser.cdecl import explain_c_declaration from pycparser.cdecl import explain_c_declaration
@hook.command('explain') @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 to array of pointer to char
''' '''
if not inp: 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

View File

@ -34,14 +34,11 @@ def explain_c_declaration(c_decl):
""" """
parser = c_parser.CParser() parser = c_parser.CParser()
try:
node = parser.parse(c_decl, filename='<stdin>') node = parser.parse(c_decl, filename='<stdin>')
except c_parser.ParseError, e:
return None
if ( not isinstance(node, c_ast.FileAST) or if ( not isinstance(node, c_ast.FileAST) or
not isinstance(node.ext[-1], c_ast.Decl)): not isinstance(node.ext[-1], c_ast.Decl)):
return None return "Last external node is invalid type"
return _explain_decl_node(node.ext[-1]) return _explain_decl_node(node.ext[-1])