Exemple #1
0
 def get_process_fragment(self):
     return Fragment([
         self.token("result").r.eq(
             _Operator(self.op,
                       [self.token("operands").a,
                        self.token("operands").b]))
     ])
Exemple #2
0
def optree(op, operands, lb=None, ub=None, default=None):
	if lb is None:
		lb = 0
	if ub is None:
		ub = len(operands)
	l = ub - lb
	if l == 0:
		if default is None:
			raise AttributeError
		else:
			return default
	elif l == 1:
		return operands[lb]
	else:
		s = lb + l//2
		return _Operator(op,
			[optree(op, operands, lb, s, default),
			optree(op, operands, s, ub, default)])
Exemple #3
0
def optree(op, operands, lb=None, ub=None, default=None):
    if lb is None:
        lb = 0
    if ub is None:
        ub = len(operands)
    l = ub - lb
    if l == 0:
        if default is None:
            raise AttributeError
        else:
            return default
    elif l == 1:
        return operands[lb]
    else:
        s = lb + l // 2
        return _Operator(op, [
            optree(op, operands, lb, s, default),
            optree(op, operands, s, ub, default)
        ])
Exemple #4
0
	def get_process_fragment(self):
		return Fragment([
			self.token("result").r.eq(_Operator(self.op, 
				[self.token("operands").a, self.token("operands").b]))
		])
Exemple #5
0
 def visit_Operator(self, node):
     return _Operator(node.op, [self.visit(o) for o in node.operands])
Exemple #6
0
	def visit_Operator(self, node):
		return _Operator(node.op, [self.visit(o) for o in node.operands])