Differences From Artifact [b8324439b8512940]:
- File
polemy/ast.d
- 2010-11-10 12:38:54 - part of checkin [38fcc662be] on branch trunk - cleaned up documentation comments (user: kinaba) [annotate]
To Artifact [e950d5b14cc365fe]:
- File
polemy/ast.d
- 2010-11-11 02:40:08 - part of checkin [8e6fa743ee] on branch trunk - added layered parameter AST (only AST. no parser and no evaluator). (user: kinaba) [annotate]
62 62 {
63 63 AST fun;
64 64 AST[] args;
65 65 this(immutable LexPosition pos, AST fun, AST[] args...)
66 66 { super(pos); this.fun=fun; this.args=args.dup; }
67 67 mixin SimpleClass;
68 68 }
69 +
70 +///
71 +class Parameter
72 +{
73 + string name;
74 + string[] layers;
75 + mixin SimpleClass;
76 +}
69 77
70 78 ///
71 79 class FunLiteral : AST
72 80 {
73 - string[] params;
74 - AST funbody;
81 + Parameter[] params;
82 + AST funbody;
75 83 mixin SimpleClass;
76 84 }
77 85
78 86 /// Handy Generator for AST nodes. To use this, mixin EasyAst;
79 87
80 88 /*mixin*/
81 89 template EasyAST()
................................................................................
82 90 {
83 91 ///
84 92 template genEast(T)
85 93 { T genEast(P...)(P ps) { return new T(LexPosition.dummy, ps); } }
86 94
87 95 alias genEast!StrLiteral strl; ///
88 96 alias genEast!IntLiteral intl; ///
89 - auto fun(string[] xs, AST ps) { return genEast!FunLiteral(xs,ps); } ///
97 + auto fun(string[] xs, AST ps) {
98 + return genEast!FunLiteral(array(map!((string x){return new Parameter(x,[]);})(xs)),ps); }
99 + auto funp(Parameter[] xs, AST ps) { return genEast!FunLiteral(xs,ps); } ///
90 100 alias genEast!VarExpression var; ///
91 101 alias genEast!LayeredExpression lay; ///
92 102 alias genEast!LetExpression let; ///
93 103 alias genEast!FuncallExpression call; ///
94 104 }