Differences From Artifact [cf8f245149fce4dc]:
- File
polemy/ast.d
- 2010-11-23 07:42:13 - part of checkin [6ac127ddd0] on branch trunk - new evaluator (user: kinaba) [annotate]
To Artifact [f7a981003352ec6b]:
- File
polemy/ast.d
- 2010-11-23 09:36:27 - part of checkin [b97bd4f713] on branch trunk - automatic AST to table encoder (user: kinaba) [annotate]
9 import polemy.failure; 9 import polemy.failure;
10 import polemy.layer; 10 import polemy.layer;
11 11
12 /// 12 ///
13 abstract class AST 13 abstract class AST
14 { 14 {
15 LexPosition pos; 15 LexPosition pos;
> 16
16 mixin SimpleConstructor; 17 mixin SimpleConstructor;
17 mixin SimplePatternMatch; <
18 } 18 }
19 19
20 /// 20 ///
21 class Int : AST 21 class Int : AST
22 { 22 {
23 BigInt data; 23 BigInt data;
> 24
24 mixin SimpleClass; 25 mixin SimpleClass;
25 this(LexPosition pos, int n) {super(pos); data = n;} 26 this(LexPosition pos, int n) {super(pos); data = n;}
26 this(LexPosition pos, long n) {super(pos); data = n;} 27 this(LexPosition pos, long n) {super(pos); data = n;}
27 this(LexPosition pos, BigInt n) {super(pos); data = n;} 28 this(LexPosition pos, BigInt n) {super(pos); data = n;}
28 this(LexPosition pos, string n) {super(pos); data = BigInt(n);} 29 this(LexPosition pos, string n) {super(pos); data = BigInt(n);}
29 } 30 }
30 31
31 /// 32 ///
32 class Str : AST 33 class Str : AST
33 { 34 {
34 string data; 35 string data;
> 36
35 mixin SimpleClass; 37 mixin SimpleClass;
36 } 38 }
37 39
38 /// 40 ///
39 class Var : AST 41 class Var : AST
40 { 42 {
41 string name; 43 string name;
> 44
42 mixin SimpleClass; 45 mixin SimpleClass;
43 } 46 }
44 47
45 /// 48 ///
46 class Lay : AST 49 class Lay : AST
47 { 50 {
48 Layer layer; 51 Layer layer;
49 AST expr; 52 AST expr;
> 53
50 mixin SimpleClass; 54 mixin SimpleClass;
51 } 55 }
52 56
53 /// 57 ///
54 class Let : AST 58 class Let : AST
55 { 59 {
56 string name; 60 string name;
57 Layer layer; 61 Layer layer;
58 AST init; 62 AST init;
59 AST expr; 63 AST expr;
> 64
60 mixin SimpleClass; 65 mixin SimpleClass;
61 } 66 }
62 67
63 /// 68 ///
64 class App : AST 69 class App : AST
65 { 70 {
66 AST fun; 71 AST fun;
67 AST[] args; 72 AST[] args;
68 this(LexPosition pos, AST fun, AST[] args...) <
69 { super(pos); this.fun=fun; this.args=args.dup; } <
> 73
70 mixin SimpleClass; 74 mixin SimpleClass;
> 75 this(LexPosition pos, AST fun, AST[] args...) { super(pos); this.fun=fun
71 } 76 }
72 77
73 /// 78 ///
74 class Parameter 79 class Parameter
75 { 80 {
76 string name; 81 string name;
77 Layer[] layers; 82 Layer[] layers;
> 83
78 mixin SimpleClass; 84 mixin SimpleClass;
79 } 85 }
80 86
81 /// 87 ///
82 class Fun : AST 88 class Fun : AST
83 { 89 {
84 Parameter[] params; 90 Parameter[] params;
85 AST funbody; 91 AST funbody;
> 92
86 mixin SimpleClass; 93 mixin SimpleClass;
87 } 94 }
88 95
89 /// Handy Generator for AST nodes. To use this, mixin EasyAst; 96 /// Handy Generator for AST nodes. To use this, mixin EasyAst;
90 97
91 /*mixin*/ 98 /*mixin*/
92 template EasyAST() 99 template EasyAST()