Index: main.d ================================================================== --- main.d +++ main.d @@ -12,10 +12,11 @@ /// Advance args[] to point the argument list fed to the script. /// Returns the name of the source file to run, or returns "" if /// no filename was given. Also, returns to libs[] the list of /// library source to load. +/// TODO: use std.getopt string parseArgv(ref string[] args, out string[] libs) { args.popFront(); @@ -35,11 +36,11 @@ } } /// Entry point. -void main( string[] args ) +void main( string[] args ) { string[] libs; string src = parseArgv(args, libs); auto r = new REPL(args); Index: polemy/ast.d ================================================================== --- polemy/ast.d +++ polemy/ast.d @@ -1,96 +1,96 @@ -/** - * 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;} 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; } /// List of AST Types