@@ -7,20 +7,23 @@ module polemy.ast; import polemy._common; import polemy.lex; +/// abstract class AST { immutable LexPosition pos; mixin SimpleConstructor; } +/// class StrLiteral : AST { string data; mixin SimpleClass; } +/// class IntLiteral : AST { BigInt data; mixin SimpleClass; @@ -28,21 +31,24 @@ 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; mixin SimpleClass; } +/// class LayeredExpression : AST { string lay; AST expr; mixin SimpleClass; } +/// class LetExpression : AST { string var; string layer; @@ -50,8 +56,9 @@ AST expr; mixin SimpleClass; } +/// class FuncallExpression : AST { AST fun; AST[] args; @@ -59,8 +66,9 @@ { super(pos); this.fun=fun; this.args=args.dup; } mixin SimpleClass; } +/// class FunLiteral : AST { string[] params; AST funbody; @@ -71,15 +79,16 @@ /*mixin*/ template EasyAST() { + /// template genEast(T) { T genEast(P...)(P ps) { return new T(LexPosition.dummy, ps); } } - alias genEast!StrLiteral strl; - alias genEast!IntLiteral intl; - auto fun(string[] xs, AST ps) { return genEast!FunLiteral(xs,ps); } // to help type inference of D - alias genEast!VarExpression var; - alias genEast!LayeredExpression lay; - alias genEast!LetExpression let; - alias genEast!FuncallExpression call; + alias genEast!StrLiteral strl; /// + alias genEast!IntLiteral intl; /// + auto fun(string[] xs, AST ps) { return genEast!FunLiteral(xs,ps); } /// + alias genEast!VarExpression var; /// + alias genEast!LayeredExpression lay; /// + alias genEast!LetExpression let; /// + alias genEast!FuncallExpression call; /// }