Exemplo n.º 1
0
def build_pattern(builder, node):
    old = builder.__class__
    builder.__class__ = SyntaxBuilder
    try:
        return build(builder, node)
    finally:
        builder.__class__ = old
Exemplo n.º 2
0
 def IfElse(self, tval, cond, fval):
     return IfElse(build(self, tval), build(self, cond), build(self, fval))
Exemplo n.º 3
0
 def method(self, items):
     result = build(self, items[0])
     for item in items[1:]:
         result = nt(result, build(self, item))
     return result
Exemplo n.º 4
0
 def method(self, left, right):
     return nt(build(self, left), build(self, right))
Exemplo n.º 5
0
 def method(self, expr):
     return nt(build(self, expr))
Exemplo n.º 6
0
 def Compare(self, expr, ops):
     return Compare(build(self, expr),
                    [(op == '<>' and '!=' or op, build(self, arg))
                     for op, arg in ops])
Exemplo n.º 7
0
 def Getattr(self, expr, attr):
     return Getattr(build(self, expr), attr)
Exemplo n.º 8
0
 def Slice3(self, start, stop, stride):
     start = start and build(self, start) or Pass
     stop = stop and build(self, stop) or Pass
     stride = stride and build(self, stride) or Pass
     return BuildSlice(start, stop, stride)
Exemplo n.º 9
0
 def Slice2(self, start, stop):
     start = start and build(self, start) or Pass
     stop = stop and build(self, stop) or Pass
     return GetSlice(Pass, start, stop)
Exemplo n.º 10
0
 def Subscript(self, left, right):
     expr = build(self, left)
     key = build(self, right)
     if isinstance(key, GetSlice):
         return GetSlice(expr, key.start, key.stop)
     return Getitem(expr, key)