Diff
Not logged in

Differences From Artifact [2e3f1e0044f7841f]:

To Artifact [55043f61f436485a]:


8 8 import polemy._common; 9 9 import polemy.failure; 10 10 import polemy.layer; 11 11 12 12 /// 13 13 abstract class AST 14 14 { 15 - LexPosition pos; 15 + LexPosition pos; /// 16 16 17 17 mixin SimpleConstructor; 18 18 } 19 19 20 -/// 20 +/// AST node for integer literal 21 21 class Int : AST 22 22 { 23 - BigInt data; 23 + BigInt data; /// 24 24 25 25 mixin SimpleClass; 26 26 this(LexPosition pos, int n) {super(pos); data = n;} 27 27 this(LexPosition pos, long n) {super(pos); data = n;} 28 28 this(LexPosition pos, BigInt n) {super(pos); data = n;} 29 29 this(LexPosition pos, string n) {super(pos); data = BigInt(n);} 30 30 } 31 31 32 -/// 32 +/// AST node for string literal 33 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 45 mixin SimpleClass; 38 46 } 39 47 40 -/// 41 -class Var : AST 48 +/// AST node for @layered(expression) 49 +class Lay : AST 42 50 { 43 - string name; 51 + Layer layer; /// 52 + AST expr; /// 44 53 45 54 mixin SimpleClass; 46 55 } 47 56 48 -/// 49 -class Lay : AST 57 +/// AST node for variable declaration 58 +class Let : AST 50 59 { 51 - Layer layer; 52 - AST expr; 60 + string name; /// 61 + Layer layer; /// 62 + AST init; /// 63 + AST expr; /// 53 64 54 65 mixin SimpleClass; 55 66 } 56 67 57 -/// 58 -class Let : AST 59 -{ 60 - string name; 61 - Layer layer; 62 - AST init; 63 - AST expr; 64 - 65 - mixin SimpleClass; 66 -} 67 - 68 -/// 68 +/// AST node for function application 69 69 class App : AST 70 70 { 71 - AST fun; 72 - AST[] args; 71 + AST fun; /// 72 + AST[] args; /// 73 73 74 74 mixin SimpleClass; 75 75 this(LexPosition pos, AST fun, AST[] args...) { super(pos); this.fun=fun; this.args=args.dup; } 76 76 } 77 77 78 78 /// 79 79 class Parameter 80 80 { 81 - string name; 82 - Layer[] layers; 81 + string name; /// 82 + Layer[] layers; /// 83 83 84 84 mixin SimpleClass; 85 85 } 86 86 87 -/// 87 +/// AST node for function literal 88 88 class Fun : AST 89 89 { 90 - Parameter[] params; 91 - AST funbody; 90 + Parameter[] params; /// 91 + AST funbody; /// 92 92 93 93 mixin SimpleClass; 94 94 } 95 95 96 96 /// List of AST Types 97 97 98 98 alias TypeTuple!(Int,Str,Var,Lay,Let,App,Fun) ListOfASTTypes;