Check-in [2bdfb8a182]
Not logged in
Overview
SHA1 Hash:2bdfb8a182d6e12c1e30fe82c474b3159ab2541a
Date: 2010-11-21 20:11:49
User: kinaba
Comment:moved build sciprt for documents into Poseidon environment
Timelines: family | ancestors | descendants | both | trunk
Downloads: Tarball | ZIP archive
Other Links: files | file ages | manifest
Tags And Properties
Changes

Modified .poseidon from [689f2a54d91081ce] to [07d04070d657a1fa].

7 7 <filter>*.d</filter> 8 8 <showemptyfolder>0</showemptyfolder> 9 9 <buildSpec> 10 10 <buildType>0</buildType> 11 11 <mainFile>main.d</mainFile> 12 12 <Args /> 13 13 <options> 14 - <dmd> -g -unittest </dmd> 14 + <dmd> -cov -D -Dddoc -g -unittest </dmd> 15 15 <tool /> 16 16 <lib /> 17 17 <implib /> 18 18 <extra /> 19 19 <toolextra /> 20 20 <merge>0</merge> 21 21 <nonfiles>0</nonfiles> ................................................................................ 26 26 <dmdpath /> 27 27 <dmcpath /> 28 28 <buildtoolexe /> 29 29 <projectFiles> 30 30 <source> 31 31 <name>d2stacktrace\dbghelp.d</name> 32 32 <name>d2stacktrace\stacktrace.d</name> 33 + <name>doc\candydoc\candy.ddoc</name> 34 + <name>doc\candydoc\modules.ddoc</name> 33 35 <name>main.d</name> 34 36 <name>polemy\_common.d</name> 35 37 <name>polemy\ast.d</name> 36 38 <name>polemy\eval.d</name> 37 39 <name>polemy\failure.d</name> 38 40 <name>polemy\layer.d</name> 39 41 <name>polemy\lex.d</name> ................................................................................ 44 46 </source> 45 47 <interface /> 46 48 <resource /> 47 49 <othersDMD /> 48 50 <others> 49 51 <name>build.bat</name> 50 52 <name>build.sh</name> 51 - <name>builddoc.bat</name> 52 53 <name>readme.txt</name> 53 54 </others> 54 55 </projectFiles> 55 56 <includePaths /> 56 57 <linkLibrarys /> 57 58 <importExpressions /> 58 59 </buildSpec> 59 60 </projectDescription>

Deleted builddoc.bat version [7f7c5c8755679d44]

1 -@setlocal ENABLEDELAYEDEXPANSION 2 -@set ARGS= 3 -@for %%I in (main.d polemy\*.d tricks\*.d) do @set ARGS=!ARGS! %%I 4 -@if not exist bin mkdir bin 5 -@echo dmd -o- -Dddoc doc\candydoc\candy.ddoc doc\candydoc\modules.ddoc %ARGS% 6 -@dmd -o- -Dddoc doc\candydoc\candy.ddoc doc\candydoc\modules.ddoc %ARGS%

Modified polemy/ast.d from [351d6a36d1e1b0e0] to [02291a629f0b15b6].

7 7 module polemy.ast; 8 8 import polemy._common; 9 9 import polemy.failure; 10 10 11 11 /// 12 12 abstract class AST 13 13 { 14 - immutable LexPosition pos; 14 + LexPosition pos; 15 15 mixin SimpleConstructor; 16 16 mixin SimplePatternMatch; 17 17 } 18 18 19 19 /// 20 20 class StrLiteral : AST 21 21 {

Modified polemy/failure.d from [ceae1b272549ae1a] to [594acaf3ac60594c].

5 5 * Error Information for Polemy Programming Language 6 6 */ 7 7 module polemy.failure; 8 8 import polemy._common; 9 9 10 10 /// Represents a position in source codes 11 11 12 -class LexPosition 12 +class LexPosition_t 13 13 { 14 14 immutable string filename; /// name of the source file 15 15 immutable int lineno; /// 1-origin 16 16 immutable int column; /// 1-origin 17 17 18 18 mixin SimpleClass; 19 19 override string toString() const 20 20 { 21 21 return sprintf!("%s:%d:%d")(filename, lineno, column); 22 22 } 23 23 24 - static immutable LexPosition dummy; 25 - static this(){ dummy = new immutable(LexPosition)("<unnamed>",0,0); } 24 + static LexPosition dummy; 25 + static this(){ dummy = new LexPosition("<unnamed>",0,0); } 26 26 } 27 27 28 +/// Represents a position in source codes 29 + 30 +alias immutable(LexPosition_t) LexPosition; 31 + 28 32 unittest 29 33 { 30 34 auto p = new LexPosition("hello.cpp", 123, 45); 31 35 32 36 assert_eq( p.filename, "hello.cpp" ); 33 37 assert_eq( p.lineno, 123 ); 34 38 assert_eq( p.column, 45 ); ................................................................................ 43 47 assert_lt( p, q ); 44 48 assert_ne( p, q ); 45 49 } 46 50 47 51 /*mixin*/ 48 52 template ExceptionWithPosition() 49 53 { 50 - const LexPosition pos; 51 - this( const LexPosition pos, string msg, string file=null, size_t line=0, Throwable next=null ) 54 + LexPosition pos; 55 + this( LexPosition pos, string msg, string file=null, size_t line=0, Throwable next=null ) 52 56 { 53 57 if(pos is null) 54 - super(sprintf!("[???????] %s")(msg), file, line, next); 58 + super(sprintf!("[??] %s")(msg), file, line, next); 55 59 else 56 60 super(sprintf!("[%s] %s")(pos, msg), file, line, next); 57 61 this.pos = pos; 58 62 } 59 63 } 60 64 61 65 class UnexpectedEOF : Exception { mixin ExceptionWithPosition; } /// EOF during lexing/parsing 62 66 class LexException : Exception { mixin ExceptionWithPosition; } /// Lexer errors 63 67 class ParseException : Exception { mixin ExceptionWithPosition; } /// Parser errors 64 68 class RuntimeException : Exception { mixin ExceptionWithPosition; } /// Evaluator errors

Modified polemy/lex.d from [480bb741b8b1612b] to [165f2920b68bc5f6].

19 19 immutable bool quoted; /// Was it a "quoted" token or unquoted? 20 20 21 21 mixin SimpleClass; 22 22 } 23 23 24 24 unittest 25 25 { 26 - auto p = new immutable(LexPosition)("hello.cpp", 123, 45); 26 + auto p = new LexPosition("hello.cpp", 123, 45); 27 27 auto t = new Token(p, "class", false); 28 28 auto u = new Token(p, "class", true); 29 29 30 30 assert_eq( t.pos, p ); 31 31 assert_eq( t.str, "class" ); 32 32 assert( !t.quoted ); 33 33 assert_eq( t, new Token(p, "class", false) ); ................................................................................ 369 369 /// Range primitive 370 370 typeof(this) save() /*@property*/ 371 371 { 372 372 return this; 373 373 } 374 374 375 375 /// Get the current position 376 - immutable(LexPosition) currentPosition() const 376 + LexPosition currentPosition() const 377 377 { 378 - return new immutable(LexPosition)(filename, lineno, column); 378 + return new LexPosition(filename, lineno, column); 379 379 } 380 380 } 381 381 382 382 unittest 383 383 { 384 384 assert( isForwardRange!(PositionedReader!string) ); 385 385 assert( is(ElementType!(PositionedReader!string) == dchar) ); 386 386 }

Modified polemy/parse.d from [71d187282fb3ce05] to [2e1caca9f119fc4c].

8 8 import polemy._common; 9 9 import polemy.failure; 10 10 import polemy.lex; 11 11 import polemy.ast; 12 12 import polemy.layer; 13 13 14 14 /// Parse a string and return its AST 15 -/// Throws: ParseException, LexException, UnexpectedEOF 16 15 17 16 AST parseString(S, T...)(S str, T fn_ln_cn) 18 17 { 19 18 return parserFromString(str, fn_ln_cn).parse(); 20 19 } 21 20 22 21 /// Parse the content of a file and return its AST 23 -/// Throws: ParseException, LexException, UnexpectedEOF 24 22 25 23 AST parseFile(S, T...)(S filename, T ln_cn) 26 24 { 27 25 return parserFromFile(filename, ln_cn).parse(); 28 26 } 29 27 30 28 // Named Constructors of Parser ................................................................................ 71 69 /// Declaration ::= 72 70 /// ["@" Layer|"let"|"var"|"def"] Var "=" Expression ([";"|"in"] Body?)? 73 71 /// | ["@" Layer|"let"|"var"|"def"] Var "(" Param%"," ")" "{" Body "}" ([";"|"in"] Body?)? 74 72 /// | ["@" "@" Layer "=" Expression ([";"|"in"] Body?)? 75 73 /// | ["@" "@" Layer "(" Param%"," ")" "{" Body "}" ([";"|"in"] Body?)? 76 74 77 75 auto pos = currentPosition(); 78 - string layer = ""; 79 - bool layerRiseDecl = false; 76 + Layer layer = ""; 77 + bool layerLiftDecl = false; 80 78 81 79 if( tryEat("@") ) 82 80 { 83 81 layer = "@" ~ eatId("after @", AllowQuoted); 84 82 if( layer == "@@" ) 85 83 { 86 84 layer = "@" ~ eatId("after @@", AllowQuoted); 87 - layerRiseDecl = true; 85 + layerLiftDecl = true; 88 86 } 89 87 else 90 88 { 91 89 if( tryEat("(") ) 92 90 return null; // @lay(...) expression, not a declaration 93 91 } 94 92 } 95 93 96 94 // [TODO] Refactor 97 - if( layerRiseDecl ) 95 + if( layerLiftDecl ) 98 96 { 99 97 string kwd = "@" ~ layer; 100 98 string var = layer; 101 99 102 100 auto e = tryEat("(") 103 101 ? parseLambdaAfterOpenParen(pos) // let var ( ... 104 102 : (eat("=", "after "~kwd), E(0)); // let var = ... 105 103 if( moreDeclarationExists() ) 106 104 return new LetExpression(pos, var, SystemLayer, e, Body()); 107 105 else 108 - return new LetExpression(pos, var, SystemLayer, e, new VarExpression(pos, var)); 106 + return new LetExpression(pos, var, SystemLayer, e, 107 + new LayeredExpression(pos, SystemLayer, new VarExpression(pos, var)) 108 + ); 109 109 } 110 110 else 111 111 { 112 112 string kwd = layer; 113 113 if( layer.empty && !tryEat(kwd="let") && !tryEat(kwd="var") && !tryEat(kwd="def") ) 114 114 return null; // none of {@lay, let, var, def} occurred, it's not a declaration 115 115 ................................................................................ 389 389 throw genex!ParseException(currentPosition(), "identifier is expected but not found "~msg); 390 390 scope(exit) lex.popFront; 391 391 return lex.front.str; 392 392 } 393 393 394 394 AST doNothingExpression() 395 395 { 396 - return new IntLiteral(currentPosition(), BigInt(178)); 396 + return new StrLiteral(currentPosition(), "(empty function body)"); 397 397 } 398 398 399 399 immutable(LexPosition) currentPosition() 400 400 { 401 401 return lex.empty ? null : lex.front.pos; 402 402 } 403 403 } ................................................................................ 416 416 assert_eq(parseString(`1;2;`), let("_","",intl(1),intl(2))); 417 417 assert_eq(parseString(`let x=1 in 2`), let("x","",intl(1),intl(2))); 418 418 assert_eq(parseString(`var x=1;2;`), let("x","",intl(1),intl(2))); 419 419 assert_eq(parseString(`def x=1`), let("x","",intl(1),var("x"))); 420 420 assert_eq(parseString(`@val x=1;`), let("x","@val",intl(1),var("x"))); 421 421 assert_eq(parseString(`@typ x="#int";`), let("x","@typ",strl("#int"),var("x"))); 422 422 assert_eq(parseString(`f(1,2)`), call(var("f"),intl(1),intl(2))); 423 - assert_eq(parseString(`if(1){2}`), call(var("if"),intl(1),fun([],intl(2)),fun([],intl(178)))); 423 + assert_eq(parseString(`if(1){2}`), call(var("if"),intl(1),fun([],intl(2)),fun([],strl("(empty function body)")))); 424 424 assert_eq(parseString(`if(1){2}else{3}`), call(var("if"),intl(1),fun([],intl(2)),fun([],intl(3)))); 425 425 assert_eq(parseString(`if(1){}else{3}()()`), 426 - call(call(call(var("if"),intl(1),fun([],intl(178)),fun([],intl(3)))))); 426 + call(call(call(var("if"),intl(1),fun([],strl("(empty function body)")),fun([],intl(3)))))); 427 427 assert_eq(parseString(`1+2*3`), call(var("+"),intl(1),call(var("*"),intl(2),intl(3)))); 428 428 assert_eq(parseString(`(1+2)*3`), call(var("*"),call(var("+"),intl(1),intl(2)),intl(3))); 429 429 assert_eq(parseString(`1*(2+3)`), call(var("*"),intl(1),call(var("+"),intl(2),intl(3)))); 430 430 assert_eq(parseString(`1*2+3`), call(var("+"),call(var("*"),intl(1),intl(2)),intl(3))); 431 431 assert_eq(parseString(`@x(1)`), lay("@x", intl(1))); 432 432 assert_eq(parseString(`fun(x @v @t, y, z @t){}`), 433 - funp([param("x",["@v","@t"]), param("y",[]), param("z",["@t"])], intl(178))); 433 + funp([param("x",["@v","@t"]), param("y",[]), param("z",["@t"])], strl("(empty function body)"))); 434 434 435 435 assert_eq(parseString(` 436 436 let x = 100; #comment 437 437 let y = 200; #comment!!!!! 438 438 x+y 439 439 `), 440 440 let("x", "", intl(100), let("y", "", intl(200), call(var("+"), var("x"), var("y")))) ................................................................................ 472 472 assert_eq(parseString(`def foo(x) { x+1 }; foo`), 473 473 let("foo", "", 474 474 fun(["x"], call(var("+"), var("x"), intl(1))), 475 475 var("foo")) 476 476 ); 477 477 478 478 assert_eq(parseString(`@@type ( x ) { x }`), 479 - let("@type", SystemLayer, fun(["x"], var("x")), var("@type")) ); 479 + let("@type", SystemLayer, fun(["x"], var("x")), lay(SystemLayer, var("@type"))) ); 480 480 481 481 assert_eq(parseString(`{}`), call(var("{}"))); 482 482 assert_eq(parseString(`{foo:1,"bar":2}`), 483 483 call(var(".="), call(var(".="), call(var("{}")), strl("foo"), intl(1)), strl("bar"), intl(2))); 484 484 assert_eq(parseString(`{}.foo`), call(var("."),call(var("{}")),strl("foo"))); 485 485 assert_eq(parseString(`{}.?foo`), call(var(".?"),call(var("{}")),strl("foo"))); 486 486 assert_eq(parseString(`x{y:1}`), call(var(".="),var("x"),strl("y"),intl(1))); 487 487 }