Diff
Not logged in

Differences From Artifact [02291a629f0b15b6]:

To Artifact [73653a45c2c5d30a]:


3 * License: NYSL 0.9982 http://www.kmonos.net/nysl/ 3 * License: NYSL 0.9982 http://www.kmonos.net/nysl/ 4 * 4 * 5 * Syntax tree for Polemy programming language. 5 * Syntax tree for Polemy programming language. 6 */ 6 */ 7 module polemy.ast; 7 module polemy.ast; 8 import polemy._common; 8 import polemy._common; 9 import polemy.failure; 9 import polemy.failure; > 10 import polemy.layer; 10 11 11 /// 12 /// 12 abstract class AST 13 abstract class AST 13 { 14 { 14 LexPosition pos; 15 LexPosition pos; 15 mixin SimpleConstructor; 16 mixin SimpleConstructor; 16 mixin SimplePatternMatch; 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 class StrLiteral : AST 32 class StrLiteral : AST 21 { 33 { 22 string data; 34 string data; 23 mixin SimpleClass; 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 class VarExpression : AST 39 class VarExpression : AST 38 { 40 { 39 string var; | 41 string name; 40 mixin SimpleClass; 42 mixin SimpleClass; 41 } 43 } 42 44 43 /// 45 /// 44 class LayeredExpression : AST | 46 class LayExpression : AST 45 { 47 { 46 string lay; | 48 Layer layer; 47 AST expr; | 49 AST expr; 48 mixin SimpleClass; 50 mixin SimpleClass; 49 } 51 } 50 52 51 /// 53 /// 52 class LetExpression : AST 54 class LetExpression : AST 53 { 55 { 54 string var; | 56 string name; 55 string layer; | 57 Layer layer; 56 AST init; 58 AST init; 57 AST expr; 59 AST expr; 58 mixin SimpleClass; 60 mixin SimpleClass; 59 } 61 } 60 62 61 /// 63 /// 62 class FuncallExpression : AST 64 class FuncallExpression : AST 63 { 65 { 64 AST fun; 66 AST fun; 65 AST[] args; 67 AST[] args; 66 this(immutable LexPosition pos, AST fun, AST[] args...) | 68 this(LexPosition pos, AST fun, AST[] args...) 67 { super(pos); this.fun=fun; this.args=args.dup; } 69 { super(pos); this.fun=fun; this.args=args.dup; } 68 mixin SimpleClass; 70 mixin SimpleClass; 69 } 71 } 70 72 71 /// 73 /// 72 class Parameter 74 class Parameter 73 { 75 { 74 string name; | 76 string name; 75 string[] layers; | 77 Layer[] layers; 76 mixin SimpleClass; 78 mixin SimpleClass; 77 } 79 } 78 80 79 /// 81 /// 80 class FunLiteral : AST 82 class FunLiteral : AST 81 { 83 { 82 Parameter[] params; 84 Parameter[] params; ................................................................................................................................................................................ 95 97 96 alias genEast!StrLiteral strl; /// 98 alias genEast!StrLiteral strl; /// 97 alias genEast!IntLiteral intl; /// 99 alias genEast!IntLiteral intl; /// 98 auto fun(string[] xs, AST ps) { 100 auto fun(string[] xs, AST ps) { 99 return genEast!FunLiteral(array(map!((string x){return new Param 101 return genEast!FunLiteral(array(map!((string x){return new Param 100 auto funp(Parameter[] xs, AST ps) { return genEast!FunLiteral(xs,ps); } 102 auto funp(Parameter[] xs, AST ps) { return genEast!FunLiteral(xs,ps); } 101 alias genEast!VarExpression var; /// 103 alias genEast!VarExpression var; /// 102 alias genEast!LayeredExpression lay; /// | 104 alias genEast!LayExpression lay; /// 103 alias genEast!LetExpression let; /// 105 alias genEast!LetExpression let; /// 104 alias genEast!FuncallExpression call; /// 106 alias genEast!FuncallExpression call; /// 105 auto param(string name, string[] lay...) { return new Parameter(name, la 107 auto param(string name, string[] lay...) { return new Parameter(name, la 106 } 108 }