@@ -6,8 +6,9 @@ */ module polemy.ast; import polemy._common; import polemy.failure; +import polemy.layer; /// abstract class AST { @@ -15,45 +16,46 @@ mixin SimpleConstructor; mixin SimplePatternMatch; } +/// +class IntLiteral : AST +{ + BigInt data; + mixin SimpleClass; + this(LexPosition pos, int n) {super(pos); data = n;} + this(LexPosition pos, long n) {super(pos); data = n;} + this(LexPosition pos, BigInt n) {super(pos); data = n;} + this(LexPosition pos, string n) {super(pos); data = BigInt(n);} +} + /// class StrLiteral : AST { string data; mixin SimpleClass; } -/// -class IntLiteral : AST -{ - BigInt data; - mixin SimpleClass; - this(immutable LexPosition pos, long n) {super(pos); data = n;} - this(immutable LexPosition pos, BigInt n) {super(pos); data = n;} - this(immutable LexPosition pos, string n) {super(pos); data = BigInt(n);} -} - /// class VarExpression : AST { - string var; + string name; mixin SimpleClass; } /// -class LayeredExpression : AST +class LayExpression : AST { - string lay; - AST expr; + Layer layer; + AST expr; mixin SimpleClass; } /// class LetExpression : AST { - string var; - string layer; + string name; + Layer layer; AST init; AST expr; mixin SimpleClass; } @@ -62,18 +64,18 @@ class FuncallExpression : AST { AST fun; AST[] args; - this(immutable LexPosition pos, AST fun, AST[] args...) + this(LexPosition pos, AST fun, AST[] args...) { super(pos); this.fun=fun; this.args=args.dup; } mixin SimpleClass; } /// class Parameter { - string name; - string[] layers; + string name; + Layer[] layers; mixin SimpleClass; } /// @@ -98,9 +100,9 @@ auto fun(string[] xs, AST ps) { return genEast!FunLiteral(array(map!((string x){return new Parameter(x,[]);})(xs)),ps); } auto funp(Parameter[] xs, AST ps) { return genEast!FunLiteral(xs,ps); } /// alias genEast!VarExpression var; /// - alias genEast!LayeredExpression lay; /// + alias genEast!LayExpression lay; /// alias genEast!LetExpression let; /// alias genEast!FuncallExpression call; /// auto param(string name, string[] lay...) { return new Parameter(name, lay); } /// }