Exemplo n.º 1
0
 /// <summary>
 /// return value;
 /// </summary>
 /// <returns></returns>
 public override Expr Parse()
 {
     var token = _tokenIt.NextToken;
     var exp = new FunctionExpr();
     _parser.SetupContext(exp, token);
     var name = "anon_" + token.Line + "_" + token.LineCharPos;
     _tokenIt.Advance();
     _tokenIt.Expect(Tokens.LeftParenthesis);
     var argnames = _parser.ParseNames();
     exp.Meta.Init(name, argnames);
     _tokenIt.Expect(Tokens.RightParenthesis);
     ParseBlock(exp);
     var lambdaExp = new LambdaExpr();
     lambdaExp.Expr = exp;
     return lambdaExp;
 }
Exemplo n.º 2
0
 public object VisitLambda(LambdaExpr expr)
 {
     return null;
 }
Exemplo n.º 3
0
 public object VisitLambda(LambdaExpr expr)
 {
     var funcType = new LFunctionType();
     funcType.Name = expr.Expr.Meta.Name;
     funcType.FullName = funcType.Name;
     var func = new LFunction(expr.Expr);
     func.Type = funcType;
     return func;
 }
Exemplo n.º 4
0
        public Expr OnParseLambda()
        {
            var tokenIt = this._parser.TokenIt;
            var initiatorToken = tokenIt.NextToken;
            // <codeLambda>

            // Check for lambda or function declare.
            var next = tokenIt.Peek();
            if (next.Token != Tokens.LeftParenthesis)
            {
                return OnParseFunctionDeclare();
            }

            // This a lambda.
            var expr = new LambdaExpr();
            var funcExp = new FunctionExpr();
            expr.Expr = funcExp;
            expr.Expr.Meta = new FunctionMetaData();
            this._parser.SetupContext(funcExp, initiatorToken);
            var name = "anon_" + initiatorToken.Line + "_" + initiatorToken.LineCharPos;
            tokenIt.Advance();
            tokenIt.Expect(Tokens.LeftParenthesis);
            var argnames = _parser.ParseNames();
            funcExp.Meta.Init(name, argnames);
            tokenIt.Expect(Tokens.RightParenthesis);
            this.OnParseLambdaBlock(funcExp);

            // </codeLambda>
            this._parser.SetupContext(expr, initiatorToken);
            return expr;
        }