Diff
Not logged in

Differences From Artifact [73653a45c2c5d30a]:

To Artifact [cf8f245149fce4dc]:


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