Differences From Artifact [02291a629f0b15b6]:
- File
polemy/ast.d
- 2010-11-21 11:11:49 - part of checkin [2bdfb8a182] on branch trunk - moved build sciprt for documents into Poseidon environment (user: kinaba) [annotate]
To Artifact [73653a45c2c5d30a]:
- File
polemy/ast.d
- 2010-11-21 14:24:33 - part of checkin [3995a5eb6a] on branch trunk - added iikagen pattern match (user: kinaba) [annotate]
3 3 * License: NYSL 0.9982 http://www.kmonos.net/nysl/
4 4 *
5 5 * Syntax tree for Polemy programming language.
6 6 */
7 7 module polemy.ast;
8 8 import polemy._common;
9 9 import polemy.failure;
10 +import polemy.layer;
10 11
11 12 ///
12 13 abstract class AST
13 14 {
14 15 LexPosition pos;
15 16 mixin SimpleConstructor;
16 17 mixin SimplePatternMatch;
17 18 }
19 +
20 +///
21 +class IntLiteral : AST
22 +{
23 + BigInt data;
24 + mixin SimpleClass;
25 + this(LexPosition pos, int 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;}
28 + this(LexPosition pos, string n) {super(pos); data = BigInt(n);}
29 +}
18 30
19 31 ///
20 32 class StrLiteral : AST
21 33 {
22 34 string data;
23 35 mixin SimpleClass;
24 36 }
25 37
26 -///
27 -class IntLiteral : AST
28 -{
29 - BigInt data;
30 - mixin SimpleClass;
31 - this(immutable LexPosition pos, long n) {super(pos); data = n;}
32 - this(immutable LexPosition pos, BigInt n) {super(pos); data = n;}
33 - this(immutable LexPosition pos, string n) {super(pos); data = BigInt(n);}
34 -}
35 -
36 38 ///
37 39 class VarExpression : AST
38 40 {
39 - string var;
41 + string name;
40 42 mixin SimpleClass;
41 43 }
42 44
43 45 ///
44 -class LayeredExpression : AST
46 +class LayExpression : AST
45 47 {
46 - string lay;
47 - AST expr;
48 + Layer layer;
49 + AST expr;
48 50 mixin SimpleClass;
49 51 }
50 52
51 53 ///
52 54 class LetExpression : AST
53 55 {
54 - string var;
55 - string layer;
56 + string name;
57 + Layer layer;
56 58 AST init;
57 59 AST expr;
58 60 mixin SimpleClass;
59 61 }
60 62
61 63 ///
62 64 class FuncallExpression : AST
63 65 {
64 66 AST fun;
65 67 AST[] args;
66 - this(immutable LexPosition pos, AST fun, AST[] args...)
68 + this(LexPosition pos, AST fun, AST[] args...)
67 69 { super(pos); this.fun=fun; this.args=args.dup; }
68 70 mixin SimpleClass;
69 71 }
70 72
71 73 ///
72 74 class Parameter
73 75 {
74 - string name;
75 - string[] layers;
76 + string name;
77 + Layer[] layers;
76 78 mixin SimpleClass;
77 79 }
78 80
79 81 ///
80 82 class FunLiteral : AST
81 83 {
82 84 Parameter[] params;
................................................................................
95 97
96 98 alias genEast!StrLiteral strl; ///
97 99 alias genEast!IntLiteral intl; ///
98 100 auto fun(string[] xs, AST ps) {
99 101 return genEast!FunLiteral(array(map!((string x){return new Parameter(x,[]);})(xs)),ps); }
100 102 auto funp(Parameter[] xs, AST ps) { return genEast!FunLiteral(xs,ps); } ///
101 103 alias genEast!VarExpression var; ///
102 - alias genEast!LayeredExpression lay; ///
104 + alias genEast!LayExpression lay; ///
103 105 alias genEast!LetExpression let; ///
104 106 alias genEast!FuncallExpression call; ///
105 107 auto param(string name, string[] lay...) { return new Parameter(name, lay); } ///
106 108 }