Diff
Not logged in

Differences From Artifact [73653a45c2c5d30a]:

To Artifact [cf8f245149fce4dc]:


14 { 14 { 15 LexPosition pos; 15 LexPosition pos; 16 mixin SimpleConstructor; 16 mixin SimpleConstructor; 17 mixin SimplePatternMatch; 17 mixin SimplePatternMatch; 18 } 18 } 19 19 20 /// 20 /// 21 class IntLiteral : AST | 21 class Int : AST 22 { 22 { 23 BigInt data; 23 BigInt data; 24 mixin SimpleClass; 24 mixin SimpleClass; 25 this(LexPosition pos, int n) {super(pos); data = n;} 25 this(LexPosition pos, int n) {super(pos); data = n;} 26 this(LexPosition pos, long n) {super(pos); data = n;} 26 this(LexPosition pos, long n) {super(pos); data = n;} 27 this(LexPosition pos, BigInt n) {super(pos); data = n;} 27 this(LexPosition pos, BigInt n) {super(pos); data = n;} 28 this(LexPosition pos, string n) {super(pos); data = BigInt(n);} 28 this(LexPosition pos, string n) {super(pos); data = BigInt(n);} 29 } 29 } 30 30 31 /// 31 /// 32 class StrLiteral : AST | 32 class Str : AST 33 { 33 { 34 string data; 34 string data; 35 mixin SimpleClass; 35 mixin SimpleClass; 36 } 36 } 37 37 38 /// 38 /// 39 class VarExpression : AST | 39 class Var : AST 40 { 40 { 41 string name; 41 string name; 42 mixin SimpleClass; 42 mixin SimpleClass; 43 } 43 } 44 44 45 /// 45 /// 46 class LayExpression : AST | 46 class Lay : AST 47 { 47 { 48 Layer layer; 48 Layer layer; 49 AST expr; 49 AST expr; 50 mixin SimpleClass; 50 mixin SimpleClass; 51 } 51 } 52 52 53 /// 53 /// 54 class LetExpression : AST | 54 class Let : AST 55 { 55 { 56 string name; 56 string name; 57 Layer layer; 57 Layer layer; 58 AST init; 58 AST init; 59 AST expr; 59 AST expr; 60 mixin SimpleClass; 60 mixin SimpleClass; 61 } 61 } 62 62 63 /// 63 /// 64 class FuncallExpression : AST | 64 class App : AST 65 { 65 { 66 AST fun; 66 AST fun; 67 AST[] args; 67 AST[] args; 68 this(LexPosition pos, AST fun, AST[] args...) 68 this(LexPosition pos, AST fun, AST[] args...) 69 { super(pos); this.fun=fun; this.args=args.dup; } 69 { super(pos); this.fun=fun; this.args=args.dup; } 70 mixin SimpleClass; 70 mixin SimpleClass; 71 } 71 } ................................................................................................................................................................................ 75 { 75 { 76 string name; 76 string name; 77 Layer[] layers; 77 Layer[] layers; 78 mixin SimpleClass; 78 mixin SimpleClass; 79 } 79 } 80 80 81 /// 81 /// 82 class FunLiteral : AST | 82 class Fun : AST 83 { 83 { 84 Parameter[] params; 84 Parameter[] params; 85 AST funbody; 85 AST funbody; 86 mixin SimpleClass; 86 mixin SimpleClass; 87 } 87 } 88 88 89 /// Handy Generator for AST nodes. To use this, mixin EasyAst; 89 /// Handy Generator for AST nodes. To use this, mixin EasyAst; ................................................................................................................................................................................ 91 /*mixin*/ 91 /*mixin*/ 92 template EasyAST() 92 template EasyAST() 93 { 93 { 94 /// 94 /// 95 template genEast(T) 95 template genEast(T) 96 { T genEast(P...)(P ps) { return new T(LexPosition.dummy, ps); } 96 { T genEast(P...)(P ps) { return new T(LexPosition.dummy, ps); } 97 97 98 alias genEast!StrLiteral strl; /// | 98 alias genEast!Str strl; /// 99 alias genEast!IntLiteral intl; /// | 99 alias genEast!Int intl; /// 100 auto fun(string[] xs, AST ps) { 100 auto fun(string[] xs, AST ps) { 101 return genEast!FunLiteral(array(map!((string x){return new Param | 101 return genEast!Fun(array(map!((string x){return new Parameter(x, 102 auto funp(Parameter[] xs, AST ps) { return genEast!FunLiteral(xs,ps); } | 102 auto funp(Parameter[] xs, AST ps) { return genEast!Fun(xs,ps); } /// 103 alias genEast!VarExpression var; /// | 103 alias genEast!Var var; /// 104 alias genEast!LayExpression lay; /// | 104 alias genEast!Lay lay; /// 105 alias genEast!LetExpression let; /// | 105 alias genEast!Let let; /// 106 alias genEast!FuncallExpression call; /// | 106 alias genEast!App call; /// 107 auto param(string name, string[] lay...) { return new Parameter(name, la 107 auto param(string name, string[] lay...) { return new Parameter(name, la 108 } 108 }