def _backend(self,level=0): if (self.args[0].__class__ is node.number and self.args[1].__class__ is node.number): return node.number(self.args[0].value + self.args[1].value)._backend() else: return "(%s+%s)" % (self.args[0]._backend(), self.args[1]._backend())
def p_expr_end(p): "end : END_EXPR" p[0] = node.expr(op="end",args=node.expr_list([node.number(0), node.number(0)]))
def p_expr_number(p): "number : NUMBER" p[0] = node.number(p[1],lineno=p.lineno(1),lexpos=p.lexpos(1))
""" SMOP compiler -- Simple Matlab/Octave to Python compiler Copyright 2011-2013 Victor Leikehman """ from __future__ import absolute_import import inspect import sys import smop.node as node extend = node.extend from . import options,parse ZERO = node.number(0) def rewrite(t): global modified; modified = [] while do_rewrite(t) or modified: modified = [] def do_rewrite(t): for u in node.postorder(t): try: u._rewrite() except: assert 0 def lineno(): """Returns the current line number in our program.""" return inspect.currentframe().f_back.f_lineno
def p_expr_end(p): "end : END_EXPR" p[0] = node.expr(op="end", args=node.expr_list([node.number(0), node.number(0)]))
def p_expr_number(p): "number : NUMBER" p[0] = node.number(p[1], lineno=p.lineno(1), lexpos=p.lexpos(1))
""" SMOP compiler -- Simple Matlab/Octave to Python compiler Copyright 2011-2013 Victor Leikehman """ from __future__ import absolute_import import inspect import sys import smop.node as node extend = node.extend from . import options, parse ZERO = node.number(0) def rewrite(t): global modified modified = [] while do_rewrite(t) or modified: modified = [] def do_rewrite(t): for u in node.postorder(t): try: u._rewrite() except: assert 0