예제 #1
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;
		}
예제 #2
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;
 }
예제 #3
0
 public object VisitLambda(LambdaExpr expr)
 {
     return null;
 }