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
- branch=trunk inherited from [f65680e1d2]
- sym-trunk inherited from [f65680e1d2]
Changes
Modified main.d from [a3deb465ebfdf083] to [521e3de53633ae4a].
1 /* | 1 /** 2 * Author: k.inaba | 2 * Authors: k.inaba 3 * License: NYSL 0.9982 (http://www.kmonos.net/nysl/ 3 * License: NYSL 0.9982 (http://www.kmonos.net/nysl/ > 4 * 4 * Entry point for the polemy interpreter | 5 * Entry point for Polemy interpreter. 5 */ 6 */ 6 7 7 import std.stdio; 8 import std.stdio; 8 import polemy.lex; 9 import polemy.lex; 9 import polemy.parse; 10 import polemy.parse; 10 11 11 static ~this() { readln(); } // workaround for enabling "pause" under Poseidon 12 static ~this() { readln(); } // workaround for enabling "pause" under Poseidon 12 13 13 void main() 14 void main() 14 { 15 { 15 writeln( "test ok" ); 16 writeln( "test ok" ); 16 } 17 }
Modified polemy/_common.d from [6dd1b05b349c9906] to [0abd8de4d8be4f44].
1 module polemy._common; < 2 /* | 1 /** 3 * Author: k.inaba | 2 * Authors: k.inaba 4 * License: NYSL 0.9982 (http://www.kmonos.net/nysl/ | 3 * License: NYSL 0.9982 http://www.kmonos.net/nysl/ > 4 * 5 * "Always-opend" modules inside polemy | 5 * "Always-opend" modules inside Polemy. 6 */ 6 */ 7 < > 7 module polemy._common; 8 public import std.array; 8 public import std.array; 9 public import std.range; 9 public import std.range; 10 public import std.algorithm; 10 public import std.algorithm; 11 public import std.conv : to; 11 public import std.conv : to; 12 public import std.bigint; 12 public import std.bigint; 13 public import polemy.tricks; 13 public import polemy.tricks;
Modified polemy/ast.d from [cc116d74213b45fc] to [b98c3d30e8619e71].
1 module polemy.ast; < 2 import polemy._common; < 3 /* | 1 /* 4 * Author: k.inaba | 2 * Authors: k.inaba 5 * License: NYSL 0.9982 (http://www.kmonos.net/nysl/ | 3 * License: NYSL 0.9982 http://www.kmonos.net/nysl/ > 4 * 6 * Syntax tree for the polemy programming language | 5 * Syntax tree for Polemy programming language. 7 */ 6 */ 8 < > 7 module polemy.ast; > 8 import polemy._common; 9 import polemy.lex : LexPosition; 9 import polemy.lex : LexPosition; 10 10 11 alias Statement[] Program; 11 alias Statement[] Program; 12 12 13 abstract class Statement 13 abstract class Statement 14 { 14 { 15 immutable LexPosition pos; 15 immutable LexPosition pos;
Modified polemy/eval.d from [bedecb22284cfae9] to [c82fe33ef6c72ef2].
1 module polemy.eval; < 2 import polemy._common; < 3 /* | 1 /** 4 * Author: k.inaba | 2 * Authors: k.inaba 5 * License: NYSL 0.9982 (http://www.kmonos.net/nysl/ | 3 * License: NYSL 0.9982 http://www.kmonos.net/nysl/ > 4 * 6 * Evaluator for the polemy programming language | 5 * Evaluator for Polemy programming language. 7 */ 6 */ > 7 module polemy.eval; > 8 import polemy._common; 8 import polemy.ast; 9 import polemy.ast; 9 import polemy.runtime; 10 import polemy.runtime; 10 11 11 Context eval(Program prog) 12 Context eval(Program prog) 12 { 13 { 13 return eval(prog, new Context); 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 module polemy.lex; 7 module polemy.lex; 2 import polemy._common; 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 import std.file : readText; 10 import std.file : readText; 10 import std.string : munch; 11 import std.string : munch; 11 import std.ctype; 12 import std.ctype; 12 13 13 /// Represents a position in a source code 14 /// Represents a position in a source code 14 15 15 class LexPosition 16 class LexPosition 16 { 17 { 17 immutable string filename; ///< name of the source file | 18 immutable string filename; /// name of the source file 18 immutable int lineno; ///< line number: 1, 2, ... | 19 immutable int lineno; /// line number, 1, 2, ... 19 immutable int column; ///< column: 1, 2, ... | 20 immutable int column; /// column, 1, 2, ... 20 21 21 override string toString() const 22 override string toString() const 22 { return sprintf!"%s:%d:%d"(filename, lineno, column); } 23 { return sprintf!"%s:%d:%d"(filename, lineno, column); } 23 24 24 mixin SimpleConstructor; 25 mixin SimpleConstructor; 25 mixin SimpleCompare; 26 mixin SimpleCompare; 26 } 27 } ................................................................................................................................................................................ 44 } 45 } 45 46 46 /// Represents a lexer token 47 /// Represents a lexer token 47 48 48 class Token 49 class Token 49 { 50 { 50 enum Kind {identifier, stringLiteral, number}; 51 enum Kind {identifier, stringLiteral, number}; 51 immutable LexPosition pos; ///< position where the token occurred in th | 52 immutable LexPosition pos; /// position where the token occurred in the 52 immutable string str; ///< the token string itself | 53 immutable string str; /// the token string itself 53 immutable Kind kind; ///< which kind of token? | 54 immutable Kind kind; /// which kind of token? 54 55 55 mixin SimpleConstructor; 56 mixin SimpleConstructor; 56 mixin SimpleCompare; 57 mixin SimpleCompare; 57 } 58 } 58 59 59 unittest 60 unittest 60 { 61 { ................................................................................................................................................................................ 85 return new Lexer(str, filename, lineno, column); 86 return new Lexer(str, filename, lineno, column); 86 } 87 } 87 88 88 /// Lexer is a forward range of Tokens 89 /// Lexer is a forward range of Tokens 89 90 90 class Lexer 91 class Lexer 91 { 92 { > 93 /// Range primitive 92 bool empty() /*@property*/ 94 bool empty() /*@property*/ 93 { 95 { 94 return current is null; 96 return current is null; 95 } 97 } 96 98 > 99 /// Range primitive 97 Token front() /*@property*/ 100 Token front() /*@property*/ 98 { 101 { 99 return std.exception.enforce(current, "Lexer has already reached 102 return std.exception.enforce(current, "Lexer has already reached 100 } 103 } 101 104 > 105 /// Range primitive 102 void popFront() /*@property*/ 106 void popFront() /*@property*/ 103 { 107 { 104 std.exception.enforce(current, "Lexer has already reached the en 108 std.exception.enforce(current, "Lexer has already reached the en 105 current = readNext(); 109 current = readNext(); 106 } 110 } 107 111 > 112 /// Range primitive 108 Lexer save() /*@property*/ 113 Lexer save() /*@property*/ 109 { 114 { 110 return new Lexer(buffer, filename, lineno, column, current); 115 return new Lexer(buffer, filename, lineno, column, current); 111 } 116 } 112 117 113 private: // implementation 118 private: // implementation 114 119 ................................................................................................................................................................................ 326 assert( lex3.front.kind == Token.Kind.number ); 331 assert( lex3.front.kind == Token.Kind.number ); 327 } 332 } 328 333 329 unittest 334 unittest 330 { 335 { 331 //!! be sure to run the unittest on the root of the source directory 336 //!! be sure to run the unittest on the root of the source directory 332 auto lexf = lexerFromFile("polemy/lex.d"); 337 auto lexf = lexerFromFile("polemy/lex.d"); > 338 lexf = find!`a.str == "module"`(lexf); 333 assert( lexf.front.str == "module", lexf.front.str ); 339 assert( lexf.front.str == "module", lexf.front.str ); 334 assert( lexf.front.pos.filename == "polemy/lex.d" ); 340 assert( lexf.front.pos.filename == "polemy/lex.d" ); 335 assert( lexf.front.pos.lineno == 1 ); | 341 assert( lexf.front.pos.lineno == 7 ); 336 assert( lexf.front.pos.column == 1 ); 342 assert( lexf.front.pos.column == 1 ); 337 lexf.popFront; 343 lexf.popFront; 338 assert( lexf.front.str == "polemy" ); 344 assert( lexf.front.str == "polemy" ); 339 assert( lexf.front.pos.lineno == 1 ); | 345 assert( lexf.front.pos.lineno == 7 ); 340 assert( lexf.front.pos.column == 8 ); 346 assert( lexf.front.pos.column == 8 ); 341 lexf.popFront; 347 lexf.popFront; 342 assert( lexf.front.str == "." ); 348 assert( lexf.front.str == "." ); 343 lexf.popFront; 349 lexf.popFront; 344 assert( lexf.front.str == "lex" ); 350 assert( lexf.front.str == "lex" ); 345 lexf.popFront; 351 lexf.popFront; 346 assert( lexf.front.str == ";" ); 352 assert( lexf.front.str == ";" ); 347 lexf.popFront; 353 lexf.popFront; 348 assert( lexf.front.str == "import" ); 354 assert( lexf.front.str == "import" ); 349 assert( lexf.front.pos.lineno == 2 ); | 355 assert( lexf.front.pos.lineno == 8 ); 350 assert( lexf.front.pos.column == 1 ); 356 assert( lexf.front.pos.column == 1 ); 351 } 357 } 352 358 353 unittest 359 unittest 354 { 360 { 355 auto lex = lexerFromString(`my # comment should 361 auto lex = lexerFromString(`my # comment should 356 # hey!! 362 # hey!!
Modified polemy/parse.d from [6a76d51cc68a610b] to [fe545db0fb7a2428].
1 module polemy.parse; < 2 import polemy._common; < 3 /* | 1 /* 4 * Author: k.inaba | 2 * Authors: k.inaba 5 * License: NYSL 0.9982 (http://www.kmonos.net/nysl/ | 3 * License: NYSL 0.9982 http://www.kmonos.net/nysl/ > 4 * 6 * Parser for the polemy programming language | 5 * Parser for Polemy programming language 7 */ 6 */ 8 < > 7 module polemy.parse; > 8 import polemy._common; 9 import polemy.lex; 9 import polemy.lex; 10 import polemy.ast; 10 import polemy.ast; 11 import std.bigint; 11 import std.bigint; 12 12 13 /// Parsing Failure 13 /// Parsing Failure 14 14 15 class ParserException : Exception 15 class ParserException : Exception
Modified polemy/runtime.d from [b0c768679677d7d5] to [3711e4a90323c649].
1 module polemy.runtime; < 2 import polemy._common; < 3 /* | 1 /** 4 * Author: k.inaba | 2 * Authors: k.inaba 5 * License: NYSL 0.9982 (http://www.kmonos.net/nysl/ | 3 * License: NYSL 0.9982 http://www.kmonos.net/nysl/ > 4 * 6 * Runtime data structures for the polemy programming language | 5 * Runtime data structures for Polemy programming language. 7 */ 6 */ > 7 module polemy.runtime; > 8 import polemy._common; 8 9 9 class PolemyRuntimeException : Exception 10 class PolemyRuntimeException : Exception 10 { 11 { 11 this(string msg) { super(msg); } 12 this(string msg) { super(msg); } 12 } 13 } 13 14 14 abstract class Value 15 abstract class Value
Modified polemy/tricks.d from [bd0c6e24fe1ad6ba] to [193cf29f54393c6e].
1 module polemy.tricks; < 2 /* | 1 /** 3 * Author: k.inaba | 2 * Authors: k.inaba 4 * License: NYSL 0.9982 (http://www.kmonos.net/nysl/ | 3 * License: NYSL 0.9982 http://www.kmonos.net/nysl/ > 4 * 5 * Tricks and utilities for D programming | 5 * Common tricks and utilities for programming in D. 6 */ 6 */ > 7 module polemy.tricks; 7 static import std.array; 8 static import std.array; 8 static import std.format; 9 static import std.format; 9 10 10 /// Simple Wrapper for std.format.doFormat 11 /// Simple Wrapper for std.format.doFormat 11 12 12 string sprintf(string fmt, T...)(T params) 13 string sprintf(string fmt, T...)(T params) 13 { 14 {