Check-in [4198578702]
Not logged in
Overview
SHA1 Hash:4198578702e678c7d240e9b1dced9b3b4b28f865
Date: 2010-11-07 19:32:59
User: kinaba
Comment:Changed several documentation comments into ddoc compatible ones.
Timelines: family | ancestors | descendants | both | trunk
Downloads: Tarball | ZIP archive
Other Links: files | file ages | manifest
Tags And Properties
Changes

Modified main.d from [a3deb465ebfdf083] to [521e3de53633ae4a].

1 -/* 2 - * Author: k.inaba 1 +/** 2 + * Authors: k.inaba 3 3 * License: NYSL 0.9982 (http://www.kmonos.net/nysl/ 4 - * Entry point for the polemy interpreter 4 + * 5 + * Entry point for Polemy interpreter. 5 6 */ 6 7 7 8 import std.stdio; 8 9 import polemy.lex; 9 10 import polemy.parse; 10 11 11 12 static ~this() { readln(); } // workaround for enabling "pause" under Poseidon 12 13 13 14 void main() 14 15 { 15 16 writeln( "test ok" ); 16 17 }

Modified polemy/_common.d from [6dd1b05b349c9906] to [0abd8de4d8be4f44].

1 -module polemy._common; 2 -/* 3 - * Author: k.inaba 4 - * License: NYSL 0.9982 (http://www.kmonos.net/nysl/ 5 - * "Always-opend" modules inside polemy 1 +/** 2 + * Authors: k.inaba 3 + * License: NYSL 0.9982 http://www.kmonos.net/nysl/ 4 + * 5 + * "Always-opend" modules inside Polemy. 6 6 */ 7 - 7 +module polemy._common; 8 8 public import std.array; 9 9 public import std.range; 10 10 public import std.algorithm; 11 11 public import std.conv : to; 12 12 public import std.bigint; 13 13 public import polemy.tricks;

Modified polemy/ast.d from [cc116d74213b45fc] to [b98c3d30e8619e71].

1 -module polemy.ast; 2 -import polemy._common; 3 -/* 4 - * Author: k.inaba 5 - * License: NYSL 0.9982 (http://www.kmonos.net/nysl/ 6 - * Syntax tree for the polemy programming language 1 +/* 2 + * Authors: k.inaba 3 + * License: NYSL 0.9982 http://www.kmonos.net/nysl/ 4 + * 5 + * Syntax tree for Polemy programming language. 7 6 */ 8 - 7 +module polemy.ast; 8 +import polemy._common; 9 9 import polemy.lex : LexPosition; 10 10 11 11 alias Statement[] Program; 12 12 13 13 abstract class Statement 14 14 { 15 15 immutable LexPosition pos;

Modified polemy/eval.d from [bedecb22284cfae9] to [c82fe33ef6c72ef2].

1 -module polemy.eval; 2 -import polemy._common; 3 -/* 4 - * Author: k.inaba 5 - * License: NYSL 0.9982 (http://www.kmonos.net/nysl/ 6 - * Evaluator for the polemy programming language 1 +/** 2 + * Authors: k.inaba 3 + * License: NYSL 0.9982 http://www.kmonos.net/nysl/ 4 + * 5 + * Evaluator for Polemy programming language. 7 6 */ 7 +module polemy.eval; 8 +import polemy._common; 8 9 import polemy.ast; 9 10 import polemy.runtime; 10 11 11 12 Context eval(Program prog) 12 13 { 13 14 return eval(prog, new Context); 14 15 }

Modified polemy/lex.d from [fb194a438f1088e9] to [fb4085e84f38ed6a].

1 +/** 2 + * Authors: k.inaba 3 + * License: NYSL 0.9982 http://www.kmonos.net/nysl/ 4 + * 5 + * Lexer for Polemy programming language. 6 + */ 1 7 module polemy.lex; 2 8 import polemy._common; 3 -/* 4 - * Author: k.inaba 5 - * License: NYSL 0.9982 (http://www.kmonos.net/nysl/ 6 - * Lexer for the polemy programming language 7 - */ 8 9 9 10 import std.file : readText; 10 11 import std.string : munch; 11 12 import std.ctype; 12 13 13 14 /// Represents a position in a source code 14 15 15 16 class LexPosition 16 17 { 17 - immutable string filename; ///< name of the source file 18 - immutable int lineno; ///< line number: 1, 2, ... 19 - immutable int column; ///< column: 1, 2, ... 18 + immutable string filename; /// name of the source file 19 + immutable int lineno; /// line number, 1, 2, ... 20 + immutable int column; /// column, 1, 2, ... 20 21 21 22 override string toString() const 22 23 { return sprintf!"%s:%d:%d"(filename, lineno, column); } 23 24 24 25 mixin SimpleConstructor; 25 26 mixin SimpleCompare; 26 27 } ................................................................................ 44 45 } 45 46 46 47 /// Represents a lexer token 47 48 48 49 class Token 49 50 { 50 51 enum Kind {identifier, stringLiteral, number}; 51 - immutable LexPosition pos; ///< position where the token occurred in the source 52 - immutable string str; ///< the token string itself 53 - immutable Kind kind; ///< which kind of token? 52 + immutable LexPosition pos; /// position where the token occurred in the source 53 + immutable string str; /// the token string itself 54 + immutable Kind kind; /// which kind of token? 54 55 55 56 mixin SimpleConstructor; 56 57 mixin SimpleCompare; 57 58 } 58 59 59 60 unittest 60 61 { ................................................................................ 85 86 return new Lexer(str, filename, lineno, column); 86 87 } 87 88 88 89 /// Lexer is a forward range of Tokens 89 90 90 91 class Lexer 91 92 { 93 + /// Range primitive 92 94 bool empty() /*@property*/ 93 95 { 94 96 return current is null; 95 97 } 96 98 99 + /// Range primitive 97 100 Token front() /*@property*/ 98 101 { 99 102 return std.exception.enforce(current, "Lexer has already reached the end"); 100 103 } 101 104 105 + /// Range primitive 102 106 void popFront() /*@property*/ 103 107 { 104 108 std.exception.enforce(current, "Lexer has already reached the end"); 105 109 current = readNext(); 106 110 } 107 111 112 + /// Range primitive 108 113 Lexer save() /*@property*/ 109 114 { 110 115 return new Lexer(buffer, filename, lineno, column, current); 111 116 } 112 117 113 118 private: // implementation 114 119 ................................................................................ 326 331 assert( lex3.front.kind == Token.Kind.number ); 327 332 } 328 333 329 334 unittest 330 335 { 331 336 //!! be sure to run the unittest on the root of the source directory 332 337 auto lexf = lexerFromFile("polemy/lex.d"); 338 + lexf = find!`a.str == "module"`(lexf); 333 339 assert( lexf.front.str == "module", lexf.front.str ); 334 340 assert( lexf.front.pos.filename == "polemy/lex.d" ); 335 - assert( lexf.front.pos.lineno == 1 ); 341 + assert( lexf.front.pos.lineno == 7 ); 336 342 assert( lexf.front.pos.column == 1 ); 337 343 lexf.popFront; 338 344 assert( lexf.front.str == "polemy" ); 339 - assert( lexf.front.pos.lineno == 1 ); 345 + assert( lexf.front.pos.lineno == 7 ); 340 346 assert( lexf.front.pos.column == 8 ); 341 347 lexf.popFront; 342 348 assert( lexf.front.str == "." ); 343 349 lexf.popFront; 344 350 assert( lexf.front.str == "lex" ); 345 351 lexf.popFront; 346 352 assert( lexf.front.str == ";" ); 347 353 lexf.popFront; 348 354 assert( lexf.front.str == "import" ); 349 - assert( lexf.front.pos.lineno == 2 ); 355 + assert( lexf.front.pos.lineno == 8 ); 350 356 assert( lexf.front.pos.column == 1 ); 351 357 } 352 358 353 359 unittest 354 360 { 355 361 auto lex = lexerFromString(`my # comment should 356 362 # hey!!

Modified polemy/parse.d from [6a76d51cc68a610b] to [fe545db0fb7a2428].

1 -module polemy.parse; 2 -import polemy._common; 3 -/* 4 - * Author: k.inaba 5 - * License: NYSL 0.9982 (http://www.kmonos.net/nysl/ 6 - * Parser for the polemy programming language 1 +/* 2 + * Authors: k.inaba 3 + * License: NYSL 0.9982 http://www.kmonos.net/nysl/ 4 + * 5 + * Parser for Polemy programming language 7 6 */ 8 - 7 +module polemy.parse; 8 +import polemy._common; 9 9 import polemy.lex; 10 10 import polemy.ast; 11 11 import std.bigint; 12 12 13 13 /// Parsing Failure 14 14 15 15 class ParserException : Exception

Modified polemy/runtime.d from [b0c768679677d7d5] to [3711e4a90323c649].

1 -module polemy.runtime; 2 -import polemy._common; 3 -/* 4 - * Author: k.inaba 5 - * License: NYSL 0.9982 (http://www.kmonos.net/nysl/ 6 - * Runtime data structures for the polemy programming language 1 +/** 2 + * Authors: k.inaba 3 + * License: NYSL 0.9982 http://www.kmonos.net/nysl/ 4 + * 5 + * Runtime data structures for Polemy programming language. 7 6 */ 7 +module polemy.runtime; 8 +import polemy._common; 8 9 9 10 class PolemyRuntimeException : Exception 10 11 { 11 12 this(string msg) { super(msg); } 12 13 } 13 14 14 15 abstract class Value

Modified polemy/tricks.d from [bd0c6e24fe1ad6ba] to [193cf29f54393c6e].

1 -module polemy.tricks; 2 -/* 3 - * Author: k.inaba 4 - * License: NYSL 0.9982 (http://www.kmonos.net/nysl/ 5 - * Tricks and utilities for D programming 1 +/** 2 + * Authors: k.inaba 3 + * License: NYSL 0.9982 http://www.kmonos.net/nysl/ 4 + * 5 + * Common tricks and utilities for programming in D. 6 6 */ 7 +module polemy.tricks; 7 8 static import std.array; 8 9 static import std.format; 9 10 10 11 /// Simple Wrapper for std.format.doFormat 11 12 12 13 string sprintf(string fmt, T...)(T params) 13 14 {