@@ -1,27 +1,27 @@ -/** - * Authors: k.inaba - * License: NYSL 0.9982 http://www.kmonos.net/nysl/ - * - * Syntax tree for Polemy programming language. - */ -module polemy.ast; -import polemy._common; +/** + * Authors: k.inaba + * License: NYSL 0.9982 http://www.kmonos.net/nysl/ + * + * Syntax tree for Polemy programming language. + */ +module polemy.ast; +import polemy._common; import polemy.failure; import polemy.layer; /// -abstract class AST -{ - LexPosition pos; +abstract class AST +{ + LexPosition pos; /// mixin SimpleConstructor; -} - -/// +} + +/// AST node for integer literal class Int : AST { - BigInt data; + BigInt data; /// mixin SimpleClass; this(LexPosition pos, int n) {super(pos); data = n;} this(LexPosition pos, long n) {super(pos); data = n;} @@ -28,68 +28,68 @@ this(LexPosition pos, BigInt n) {super(pos); data = n;} this(LexPosition pos, string n) {super(pos); data = BigInt(n);} } -/// -class Str : AST -{ - string data; +/// AST node for string literal +class Str : AST +{ + string data; /// mixin SimpleClass; -} - -/// +} + +/// AST node for variable reference class Var : AST { - string name; + string name; /// + + mixin SimpleClass; +} + +/// AST node for @layered(expression) +class Lay : AST +{ + Layer layer; /// + AST expr; /// mixin SimpleClass; } -/// -class Lay : AST +/// AST node for variable declaration +class Let : AST { - Layer layer; - AST expr; + string name; /// + Layer layer; /// + AST init; /// + AST expr; /// mixin SimpleClass; } -/// -class Let : AST +/// AST node for function application +class App : AST { - string name; - Layer layer; - AST init; - AST expr; + AST fun; /// + AST[] args; /// mixin SimpleClass; + this(LexPosition pos, AST fun, AST[] args...) { super(pos); this.fun=fun; this.args=args.dup; } } - -/// -class App : AST -{ - AST fun; - AST[] args; - - mixin SimpleClass; - this(LexPosition pos, AST fun, AST[] args...) { super(pos); this.fun=fun; this.args=args.dup; } -} /// class Parameter { - string name; - Layer[] layers; + string name; /// + Layer[] layers; /// mixin SimpleClass; } -/// +/// AST node for function literal class Fun : AST { - Parameter[] params; - AST funbody; + Parameter[] params; /// + AST funbody; /// mixin SimpleClass; }