示例#1
0
def build_pattern(builder, node):
    old = builder.__class__
    builder.__class__ = SyntaxBuilder
    try:
        return build(builder, node)
    finally:
        builder.__class__ = old
示例#2
0
 def IfElse(self, tval, cond, fval):
     return IfElse(build(self, tval), build(self, cond), build(self, fval))
示例#3
0
 def method(self, items):
     result = build(self, items[0])
     for item in items[1:]:
         result = nt(result, build(self, item))
     return result
示例#4
0
 def method(self, left, right):
     return nt(build(self, left), build(self, right))
示例#5
0
 def method(self, expr):
     return nt(build(self, expr))
示例#6
0
 def Compare(self, expr, ops):
     return Compare(build(self, expr),
                    [(op == '<>' and '!=' or op, build(self, arg))
                     for op, arg in ops])
示例#7
0
 def Getattr(self, expr, attr):
     return Getattr(build(self, expr), attr)
示例#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)
示例#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)
示例#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)