def construct_func_expr(n):
    """
    construct the function expression 
    """
    op = n[0]
    if op.startswith('_') and op.endswith('_'):
        op = op.strip('_')
        if op == 'var':
            return Var(str(n[1]))
        elif op == 'literal':
            if isinstance(n[1], basestring):
                raise "not implemented"
            return Constant(n[1])
        elif op == 'cast':
            raise "not implemented"
    elif op in '+-/*':
        return ArithErrFunc(op, *map(construct_func_expr,n[1:]))
    else:
        klass = __agg2f__.get(op, None)
        if klass:
            return klass(map(construct_func_expr, n[1:]))
        raise "no klass"
def construct_func_expr ( n ) : op = n [ 0 ] if op . startswith ( '_' ) and op . endswith ( '_' ) : op = op . strip ( '_' ) if op == 'var' : return Var ( str ( n [ 1 ] ) ) elif op == 'literal' : if isinstance ( n [ 1 ] , basestring ) : raise "not implemented" return Constant ( n [ 1 ] ) elif op == 'cast' : raise "not implemented" elif op in '+-/*' : return ArithErrFunc ( op , * map ( construct_func_expr , n [ 1 : ] ) ) else : klass = __agg2f__ . get ( op , None ) if klass : return klass ( map ( construct_func_expr , n [ 1 : ] ) ) raise "no klass"
construct the function expression