Differences From Artifact [2e3f1e0044f7841f]:
- File
polemy/ast.d
- 2010-11-23 13:55:15 - part of checkin [2134cd44cc] on branch trunk - further clean-up for polemy2d (user: kinaba) [annotate]
To Artifact [55043f61f436485a]:
- File
polemy/ast.d
- 2010-11-24 03:50:04 - part of checkin [16abe21957] on branch trunk - added documentation comment to polemy.ast so that it also works for @macro users of Polemy. (user: kinaba) [annotate]
8 import polemy._common; 8 import polemy._common;
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
17 mixin SimpleConstructor; 17 mixin SimpleConstructor;
18 } 18 }
19 19
20 /// | 20 /// AST node for integer literal
21 class Int : AST 21 class Int : AST
22 { 22 {
23 BigInt data; | 23 BigInt data; ///
24 24
25 mixin SimpleClass; 25 mixin SimpleClass;
26 this(LexPosition pos, int n) {super(pos); data = n;} 26 this(LexPosition pos, int n) {super(pos); data = n;}
27 this(LexPosition pos, long n) {super(pos); data = n;} 27 this(LexPosition pos, long n) {super(pos); data = n;}
28 this(LexPosition pos, BigInt n) {super(pos); data = n;} 28 this(LexPosition pos, BigInt n) {super(pos); data = n;}
29 this(LexPosition pos, string n) {super(pos); data = BigInt(n);} 29 this(LexPosition pos, string n) {super(pos); data = BigInt(n);}
30 } 30 }
31 31
32 /// | 32 /// AST node for string literal
33 class Str : AST 33 class Str : AST
34 { 34 {
35 string data; | 35 string data; ///
> 36
> 37 mixin SimpleClass;
> 38 }
> 39
> 40 /// AST node for variable reference
> 41 class Var : AST
> 42 {
> 43 string name; ///
36 44
37 mixin SimpleClass; 45 mixin SimpleClass;
38 } 46 }
39 47
40 /// | 48 /// AST node for @layered(expression)
41 class Var : AST | 49 class Lay : AST
42 { 50 {
43 string name; | 51 Layer layer; ///
> 52 AST expr; ///
44 53
45 mixin SimpleClass; 54 mixin SimpleClass;
46 } 55 }
47 56
48 /// | 57 /// AST node for variable declaration
49 class Lay : AST | 58 class Let : AST
50 { 59 {
> 60 string name; ///
51 Layer layer; | 61 Layer layer; ///
> 62 AST init; ///
52 AST expr; | 63 AST expr; ///
53 64
54 mixin SimpleClass; 65 mixin SimpleClass;
55 } 66 }
56 67
57 /// | 68 /// AST node for function application
58 class Let : AST <
59 { <
60 string name; <
61 Layer layer; <
62 AST init; <
63 AST expr; <
64 <
65 mixin SimpleClass; <
66 } <
67 <
68 /// <
69 class App : AST 69 class App : AST
70 { 70 {
71 AST fun; | 71 AST fun; ///
72 AST[] args; | 72 AST[] args; ///
73 73
74 mixin SimpleClass; 74 mixin SimpleClass;
75 this(LexPosition pos, AST fun, AST[] args...) { super(pos); this.fun=fun 75 this(LexPosition pos, AST fun, AST[] args...) { super(pos); this.fun=fun
76 } 76 }
77 77
78 /// 78 ///
79 class Parameter 79 class Parameter
80 { 80 {
81 string name; | 81 string name; ///
82 Layer[] layers; | 82 Layer[] layers; ///
83 83
84 mixin SimpleClass; 84 mixin SimpleClass;
85 } 85 }
86 86
87 /// | 87 /// AST node for function literal
88 class Fun : AST 88 class Fun : AST
89 { 89 {
90 Parameter[] params; | 90 Parameter[] params; ///
91 AST funbody; | 91 AST funbody; ///
92 92
93 mixin SimpleClass; 93 mixin SimpleClass;
94 } 94 }
95 95
96 /// List of AST Types 96 /// List of AST Types
97 97
98 alias TypeTuple!(Int,Str,Var,Lay,Let,App,Fun) ListOfASTTypes; 98 alias TypeTuple!(Int,Str,Var,Lay,Let,App,Fun) ListOfASTTypes;