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 AST fun; 63 AST fun;
64 AST[] args; 64 AST[] args;
65 this(immutable LexPosition pos, AST fun, AST[] args...) 65 this(immutable LexPosition pos, AST fun, AST[] args...)
66 { super(pos); this.fun=fun; this.args=args.dup; } 66 { super(pos); this.fun=fun; this.args=args.dup; }
67 mixin SimpleClass; 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 class FunLiteral : AST 79 class FunLiteral : AST
72 { 80 {
73 string[] params; | 81 Parameter[] params;
74 AST funbody; | 82 AST funbody;
75 mixin SimpleClass; 83 mixin SimpleClass;
76 } 84 }
77 85
78 /// Handy Generator for AST nodes. To use this, mixin EasyAst; 86 /// Handy Generator for AST nodes. To use this, mixin EasyAst;
79 87
80 /*mixin*/ 88 /*mixin*/
81 template EasyAST() 89 template EasyAST()
................................................................................................................................................................................
82 { 90 {
83 /// 91 ///
84 template genEast(T) 92 template genEast(T)
85 { T genEast(P...)(P ps) { return new T(LexPosition.dummy, ps); } 93 { T genEast(P...)(P ps) { return new T(LexPosition.dummy, ps); }
86 94
87 alias genEast!StrLiteral strl; /// 95 alias genEast!StrLiteral strl; ///
88 alias genEast!IntLiteral intl; /// 96 alias genEast!IntLiteral intl; ///
> 97 auto fun(string[] xs, AST ps) {
> 98 return genEast!FunLiteral(array(map!((string x){return new Param
89 auto fun(string[] xs, AST ps) { return genEast!FunLiteral(xs,ps); } /// | 99 auto funp(Parameter[] xs, AST ps) { return genEast!FunLiteral(xs,ps); }
90 alias genEast!VarExpression var; /// 100 alias genEast!VarExpression var; ///
91 alias genEast!LayeredExpression lay; /// 101 alias genEast!LayeredExpression lay; ///
92 alias genEast!LetExpression let; /// 102 alias genEast!LetExpression let; ///
93 alias genEast!FuncallExpression call; /// 103 alias genEast!FuncallExpression call; ///
94 } 104 }