def funcCall(vals): assert(len(vals) > 0) func, args = car(vals), cdr(vals) if not hasattr(func,'__call__'): assert(len(args) == 0) return func else: return tryFuncCall(func, *args)
def getType(commd): t = _getType(commd[0:2]) if t: return t t = _getType(car(commd)) if t: return t else: prompt("error type analysis in %s"%commd) raise TypeError
def getEle(commd): etp = getType(commd) if etp in ['COMP','MAP','PIPE','IO LASSIGN', 'IO WRITE']: val, rest = None, cdr(commd) elif etp in ['LIST','BLOCK','DICT','STR']: (val,rest) = pytool.getFirstPareCont(commd, car(commd) ) elif etp in ['IO RASSIGN','IO APPEND']: val, rest = None, cdr(cdr(commd)) else: tmp = commd.split(' ', 1) # tmp = [ C arg1 arg2 ..] val, rest = tmp[0].strip(), tmp[1:] rest = ''.join(rest) return (etp,val, rest.strip())