Esempio n. 1
0
File: Parser.cs Progetto: azbyn/oop
        // funCall: [funCall] assign
        AstNode FunCall()
        {
            var a = Assign();

            for (;;)
            {
                if (IsEof() || Is(TT.RightParen) ||
                    Is(TT.Question) || Is(TT.Colon))
                {
                    return(a);
                }
                Pos p = pos;
                a = new AstNode.FunCall(p, a, Assign());
            }
        }
Esempio n. 2
0
        public EvalObject Visit(AstNode.FunCall v)
        {
            var fun = Eval(v.fun);

            switch (fun)
            {
            case EvalObject.Int:
                throw new EvalException(v.pos, "Int is not callable");

            case EvalObject.Builtin b:
                return(b.Call(Eval(v.arg)));

            case EvalObject.Lambda l:
                return(l.Call(Eval(v.arg), env));

            default:
                throw new InvalidOperationException();
            }
        }