Index: polemy/ast.d ================================================================== --- polemy/ast.d +++ polemy/ast.d @@ -64,16 +64,24 @@ AST[] args; this(immutable LexPosition pos, AST fun, AST[] args...) { super(pos); this.fun=fun; this.args=args.dup; } mixin SimpleClass; } + +/// +class Parameter +{ + string name; + string[] layers; + mixin SimpleClass; +} /// class FunLiteral : AST { - string[] params; - AST funbody; + Parameter[] params; + AST funbody; mixin SimpleClass; } /// Handy Generator for AST nodes. To use this, mixin EasyAst; @@ -84,11 +92,13 @@ template genEast(T) { T genEast(P...)(P ps) { return new T(LexPosition.dummy, ps); } } alias genEast!StrLiteral strl; /// alias genEast!IntLiteral intl; /// - auto fun(string[] xs, AST ps) { return genEast!FunLiteral(xs,ps); } /// + auto fun(string[] xs, AST ps) { + return genEast!FunLiteral(array(map!((string x){return new Parameter(x,[]);})(xs)),ps); } + auto funp(Parameter[] xs, AST ps) { return genEast!FunLiteral(xs,ps); } /// alias genEast!VarExpression var; /// alias genEast!LayeredExpression lay; /// alias genEast!LetExpression let; /// alias genEast!FuncallExpression call; /// } Index: polemy/eval.d ================================================================== --- polemy/eval.d +++ polemy/eval.d @@ -161,11 +161,11 @@ if( e.params.length != args.length ) throw genex!RuntimeException(e.pos, sprintf!"Argument Number Mismatch (%d required but %d given)" (e.params.length, args.length)); Table ctxNeo = new Table(ctx, Table.Kind.NotPropagateSet); foreach(i,p; e.params) - ctxNeo.set(p, lay, args[i]); + ctxNeo.set(p.name, lay, args[i]); return eval(e.funbody, ctxNeo, true, lay); }); } throw genex!RuntimeException(_e.pos, sprintf!"Unknown Kind of Expression %s"(typeid(_e))); } Index: polemy/parse.d ================================================================== --- polemy/parse.d +++ polemy/parse.d @@ -221,14 +221,14 @@ return new VarExpression(pos, lex.front.str); } AST parseLambdaAfterOpenParen(immutable LexPosition pos) { - string[] params; + Parameter[] params; while( !tryEat(")") ) { - params ~= eatId("for function parameter"); + params ~= new Parameter(eatId("for function parameter"), []); if( !tryEat(",") ) { eat(")", "after function parameters"); break; } }