h/plugins/explain.py

20 lines
445 B
Python
Raw Normal View History

2009-11-13 02:11:10 +00:00
from util import hook
2009-11-12 23:05:07 +00:00
from pycparser.cdecl import explain_c_declaration
@hook.command('explain')
def explain(inp):
'''.explain char *(*(**foo[][8])())[]; -- returns :
foo is a array of array[8] of pointer to pointer to function() returning pointer
to array of pointer to char
'''
if not inp:
2009-11-13 02:11:10 +00:00
return ""
try:
result = explain_c_declaration(inp.rstrip())
except e:
result = str(e)
return result