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
network = "localhost"
nick = "skybot"
channel = "#test"
network = "irc.synirc.net"
nick = "skybotisgay"
channel = "#cobol"
import sys
import os

View File

@ -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
result = explain_c_declaration(inp)
if result: return result
else: return None
return ""
try:
result = explain_c_declaration(inp.rstrip())
except e:
result = str(e)
return result

View File

@ -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])