h/plugins/explain.py

18 lines
397 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 <c expression> -- gives an explanation of C expression"
2009-11-12 23:05:07 +00:00
if not inp:
return explain.__doc__
2009-11-13 02:11:10 +00:00
2009-11-21 00:27:07 +00:00
inp = inp.encode('utf8', 'ignore')
2009-11-13 02:11:10 +00:00
try:
result = explain_c_declaration(inp.rstrip())
except e:
result = str(e)
return result