class funcall(node, recordtype("funcall", "func_expr args", default=None)): """Funcall instances represent (a) Array references, both lhs and rhs (b) Function call expressions """ def __str__(self): return "%s(%s)" % (str(self.func_expr), str(self.args))
class let(stmt,recordtype("let", "ret args lineno lexpos nargout", default=None)): """Assignment statement, except [x,y]=foo(x,y,z), which is handled by call_stmt.""" def __str__(self): return "%s=%s" % (str(self.ret), str(self.args))
class func_stmt(stmt, recordtype("func_stmt", """ ident ret args stmt_list use_nargin """, default=None)): pass
class expr(node, recordtype("expr", "op args")): def __str__(self): if self.op == ".": return "%s%s" % (str(self.args[0]), self.args[1]) if self.op == "parens": return "(%s)" % str(self.args[0]) if not self.args: return str(self.op) if len(self.args) == 1: return "%s%s" % (self.op, self.args[0]) if len(self.args) == 2: return "%s%s%s" % (self.args[0]._backend(), self.op, self.args[1]._backend()) ret = "%s=" % str(self.ret) if self.ret else "" return ret + "%s(%s)" % (self.op, ",".join([str(t) for t in self.args]))
class for_stmt(stmt, recordtype("for_stmt", "ident expr stmt_list")): pass
class try_catch(stmt, recordtype("try_catch", "try_stmt catch_stmt finally_stmt")): pass
class allocate_stmt(stmt, recordtype("allocate_stmt", "ident args")): pass
class expr_stmt(stmt, node, recordtype("expr_stmt", "expr")): def __str__(self): return str(self.expr)
class while_stmt(stmt, node, recordtype("while_stmt", "cond_expr stmt_list")): pass
class if_stmt(stmt, recordtype("if_stmt", "cond_expr then_stmt else_stmt")): pass
class persistent_stmt(stmt, recordtype("persistent_stmt", "global_list")): def __str__(self): return "global %s" % str(self.global_list)
class DO_STMT(stmt, recordtype("DO_STMT", "ident start stop stmt_list")): pass
class where_stmt(stmt, recordtype("where_stmt", "cond_expr stmt_list")): pass
class function(stmt, recordtype("function", "head body")): pass
class comment(stmt, recordtype("string", "comment_stmt")): def __str__(self): return str(self.comment_stmt)
class func_decl(stmt, recordtype("func_decl", "ident ret args decl_list use_nargin docstring", default=None)): pass
class ident(atom, recordtype("ident", "name lineno column lexpos defs props init", default=None)): def __str__(self): return self.name
class number(atom, recordtype("number", "value lineno lexpos", default=None)): def __str__(self): return str(self.value)
class logical(atom, recordtype("logical", "value lineno lexpos", default=None)): pass
class string(atom, recordtype("string", "value lineno lexpos", default=None)): def __str__(self): return "'%s'" % self.value