예제 #1
0
    def testFieldDefaults(self):
        s = arith_ast.Slice()
        s.a = ArithVar('foo')
        self.assertEqual(None, s.begin)
        self.assertEqual(None, s.end)
        self.assertEqual(None, s.stride)
        print(s)

        func = arith_ast.FuncCall()
        func.name = 'f'
        self.assertEqual([], func.args)
        print(func)
예제 #2
0
def LeftFuncCall(p, token, left, unused_bp):
    """ Function call f(a, b). """
    args = []
    # f(x) or f[i](x)
    if not isinstance(left, arith_ast.ArithVar):
        raise tdop.ParseError("%s can't be called" % left)
    func_name = left.name  # get a string

    while not p.AtToken(')'):
        # We don't want to grab the comma, e.g. it is NOT a sequence operator.  So
        # set the precedence to 5.
        args.append(p.ParseUntil(COMMA_PREC))
        if p.AtToken(','):
            p.Next()
    p.Eat(")")
    return arith_ast.FuncCall(func_name, args)
예제 #3
0
    def testFieldDefaults(self):
        s = arith_ast.Slice()
        s.a = ArithVar('foo')
        self.assertEqual(None, s.begin)
        self.assertEqual(None, s.end)
        self.assertEqual(None, s.stride)
        print(s)

        func = arith_ast.FuncCall()
        func.name = 'f'
        self.assertEqual([], func.args)
        print(func)

        t = arith_ast.token(5, 'x')
        self.assertEqual(5, t.id)
        self.assertEqual('x', t.value)
        self.assertEqual(const.NO_INTEGER, t.span_id)