Check-in [8caee17864]
Not logged in
Overview
SHA1 Hash:8caee17864c9eda7d12622d40de1d007c56a8ba0
Date: 2010-11-24 19:31:49
User: kinaba
Comment:added documents.
Timelines: family | ancestors | descendants | both | trunk
Downloads: Tarball | ZIP archive
Other Links: files | file ages | manifest
Tags And Properties
Changes

Added doc/_common.html version [ef6db0f6f8782d46]

1 + 2 +<html><head> 3 +<meta http-equiv="content-type" content="text/html; charset=utf-8"> 4 +<meta content="text/javascript" http-equiv="content-script-type"> 5 +<title>polemy._common</title> 6 +<link rel="stylesheet" type="text/css" href="candydoc/style.css"> 7 +<!--[if lt IE 7]><link rel="stylesheet" type="text/css" href="candydoc/ie56hack.css"><![endif]--> 8 +<script language="JavaScript" src="candydoc/util.js" type="text/javascript"></script> 9 +<script language="JavaScript" src="candydoc/tree.js" type="text/javascript"></script> 10 +<script language="JavaScript" src="candydoc/explorer.js" type="text/javascript"></script> 11 +</head><body> 12 +<div id="tabarea"></div><div id="explorerclient"></div> 13 +<div id="content"><script>explorer.initialize("polemy._common");</script> 14 + <table class="content"> 15 + <tr><td id="docbody"><h1>polemy._common</h1><!-- Generated by Ddoc from polemy\_common.d --> 16 +<b>Authors:</b><br> 17 +k.inaba 18 +<br><br> 19 +<b>License:</b><br> 20 +NYSL 0.9982 http://www.kmonos.net/nysl/ 21 +<br><br> 22 + 23 + The list of modules globaly used inside Polemy.<br><br> 24 + 25 +</td></tr> 26 + <tr><td id="docfooter"> 27 + Page was generated with 28 + <img src="candydoc/img/candydoc.gif" style="vertical-align:middle; position:relative; top:-1px"> 29 + on Wed Nov 24 19:09:32 2010 30 + 31 + </td></tr> 32 + </table> 33 +</div> 34 +<script> 35 + explorer.packageExplorer.addModule("index"); 36 + explorer.packageExplorer.addModule("main"); 37 + explorer.packageExplorer.addModule("tricks.tricks"); 38 + explorer.packageExplorer.addModule("tricks.test"); 39 + explorer.packageExplorer.addModule("polemy._common"); 40 + explorer.packageExplorer.addModule("polemy.failure"); 41 + explorer.packageExplorer.addModule("polemy.layer"); 42 + explorer.packageExplorer.addModule("polemy.fresh"); 43 + explorer.packageExplorer.addModule("polemy.lex"); 44 + explorer.packageExplorer.addModule("polemy.parse"); 45 + explorer.packageExplorer.addModule("polemy.ast"); 46 + explorer.packageExplorer.addModule("polemy.value"); 47 + explorer.packageExplorer.addModule("polemy.valueconv"); 48 + explorer.packageExplorer.addModule("polemy.eval"); 49 + explorer.packageExplorer.addModule("polemy.runtime"); 50 + explorer.packageExplorer.addModule("polemy.repl");</script> 51 +</body></html> 52 + 53 +

Added doc/ast.html version [4f37b512b58aa99b]

1 + 2 +<html><head> 3 +<meta http-equiv="content-type" content="text/html; charset=utf-8"> 4 +<meta content="text/javascript" http-equiv="content-script-type"> 5 +<title>polemy.ast</title> 6 +<link rel="stylesheet" type="text/css" href="candydoc/style.css"> 7 +<!--[if lt IE 7]><link rel="stylesheet" type="text/css" href="candydoc/ie56hack.css"><![endif]--> 8 +<script language="JavaScript" src="candydoc/util.js" type="text/javascript"></script> 9 +<script language="JavaScript" src="candydoc/tree.js" type="text/javascript"></script> 10 +<script language="JavaScript" src="candydoc/explorer.js" type="text/javascript"></script> 11 +</head><body> 12 +<div id="tabarea"></div><div id="explorerclient"></div> 13 +<div id="content"><script>explorer.initialize("polemy.ast");</script> 14 + <table class="content"> 15 + <tr><td id="docbody"><h1>polemy.ast</h1><!-- Generated by Ddoc from polemy\ast.d --> 16 +<b>Authors:</b><br> 17 +k.inaba 18 +<br><br> 19 +<b>License:</b><br> 20 +NYSL 0.9982 http://www.kmonos.net/nysl/ 21 +<br><br> 22 + 23 + Syntax tree for Polemy programming language.<br><br> 24 + 25 + 26 +<script>explorer.outline.incSymbolLevel();</script> 27 +<dl> 28 +<script>explorer.outline.writeEnabled = true;</script> 29 +<dt><span class="decl">abstract class 30 +<span class="currsymbol">AST</span> 31 +<script>explorer.outline.addDecl('AST');</script> 32 + 33 +; 34 +</span></dt> 35 +<script>explorer.outline.writeEnabled = false;</script> 36 + 37 + 38 +<dd><br><br> 39 + 40 +<script>explorer.outline.incSymbolLevel();</script> 41 +<dl> 42 +<script>explorer.outline.writeEnabled = true;</script> 43 +<dt><span class="decl">immutable LexPosition 44 +<span class="currsymbol">pos</span> 45 +<script>explorer.outline.addDecl('pos');</script> 46 + 47 +; 48 +</span></dt> 49 +<script>explorer.outline.writeEnabled = false;</script> 50 + 51 + 52 +<dd><br><br> 53 +</dd> 54 +</dl> 55 +<script>explorer.outline.decSymbolLevel();</script> 56 + 57 + 58 +</dd> 59 + 60 +<script>explorer.outline.writeEnabled = true;</script> 61 +<dt><span class="decl">class 62 +<span class="currsymbol">Int</span> 63 +<script>explorer.outline.addDecl('Int');</script> 64 + 65 +: polemy.ast.AST; 66 +</span></dt> 67 +<script>explorer.outline.writeEnabled = false;</script> 68 + 69 + 70 +<dd>AST node for integer literal<br><br> 71 + 72 + 73 +<script>explorer.outline.incSymbolLevel();</script> 74 +<dl> 75 +<script>explorer.outline.writeEnabled = true;</script> 76 +<dt><span class="decl">BigInt 77 +<span class="currsymbol">data</span> 78 +<script>explorer.outline.addDecl('data');</script> 79 + 80 +; 81 +</span></dt> 82 +<script>explorer.outline.writeEnabled = false;</script> 83 + 84 + 85 +<dd><br><br> 86 +</dd> 87 +</dl> 88 +<script>explorer.outline.decSymbolLevel();</script> 89 + 90 + 91 +</dd> 92 + 93 +<script>explorer.outline.writeEnabled = true;</script> 94 +<dt><span class="decl">class 95 +<span class="currsymbol">Str</span> 96 +<script>explorer.outline.addDecl('Str');</script> 97 + 98 +: polemy.ast.AST; 99 +</span></dt> 100 +<script>explorer.outline.writeEnabled = false;</script> 101 + 102 + 103 +<dd>AST node for string literal<br><br> 104 + 105 + 106 +<script>explorer.outline.incSymbolLevel();</script> 107 +<dl> 108 +<script>explorer.outline.writeEnabled = true;</script> 109 +<dt><span class="decl">string 110 +<span class="currsymbol">data</span> 111 +<script>explorer.outline.addDecl('data');</script> 112 + 113 +; 114 +</span></dt> 115 +<script>explorer.outline.writeEnabled = false;</script> 116 + 117 + 118 +<dd><br><br> 119 +</dd> 120 +</dl> 121 +<script>explorer.outline.decSymbolLevel();</script> 122 + 123 + 124 +</dd> 125 + 126 +<script>explorer.outline.writeEnabled = true;</script> 127 +<dt><span class="decl">class 128 +<span class="currsymbol">Var</span> 129 +<script>explorer.outline.addDecl('Var');</script> 130 + 131 +: polemy.ast.AST; 132 +</span></dt> 133 +<script>explorer.outline.writeEnabled = false;</script> 134 + 135 + 136 +<dd>AST node for variable reference<br><br> 137 + 138 + 139 +<script>explorer.outline.incSymbolLevel();</script> 140 +<dl> 141 +<script>explorer.outline.writeEnabled = true;</script> 142 +<dt><span class="decl">string 143 +<span class="currsymbol">name</span> 144 +<script>explorer.outline.addDecl('name');</script> 145 + 146 +; 147 +</span></dt> 148 +<script>explorer.outline.writeEnabled = false;</script> 149 + 150 + 151 +<dd><br><br> 152 +</dd> 153 +</dl> 154 +<script>explorer.outline.decSymbolLevel();</script> 155 + 156 + 157 +</dd> 158 + 159 +<script>explorer.outline.writeEnabled = true;</script> 160 +<dt><span class="decl">class 161 +<span class="currsymbol">Lay</span> 162 +<script>explorer.outline.addDecl('Lay');</script> 163 + 164 +: polemy.ast.AST; 165 +</span></dt> 166 +<script>explorer.outline.writeEnabled = false;</script> 167 + 168 + 169 +<dd>AST node for @layered(expression)<br><br> 170 + 171 + 172 +<script>explorer.outline.incSymbolLevel();</script> 173 +<dl> 174 +<script>explorer.outline.writeEnabled = true;</script> 175 +<dt><span class="decl">Layer 176 +<span class="currsymbol">layer</span> 177 +<script>explorer.outline.addDecl('layer');</script> 178 + 179 +; 180 +</span></dt> 181 +<script>explorer.outline.writeEnabled = false;</script> 182 + 183 + 184 +<dd><br><br> 185 +</dd> 186 + 187 +<script>explorer.outline.writeEnabled = true;</script> 188 +<dt><span class="decl">AST 189 +<span class="currsymbol">expr</span> 190 +<script>explorer.outline.addDecl('expr');</script> 191 + 192 +; 193 +</span></dt> 194 +<script>explorer.outline.writeEnabled = false;</script> 195 + 196 + 197 +<dd><br><br> 198 +</dd> 199 +</dl> 200 +<script>explorer.outline.decSymbolLevel();</script> 201 + 202 + 203 +</dd> 204 + 205 +<script>explorer.outline.writeEnabled = true;</script> 206 +<dt><span class="decl">class 207 +<span class="currsymbol">Let</span> 208 +<script>explorer.outline.addDecl('Let');</script> 209 + 210 +: polemy.ast.AST; 211 +</span></dt> 212 +<script>explorer.outline.writeEnabled = false;</script> 213 + 214 + 215 +<dd>AST node for variable declaration<br><br> 216 + 217 + 218 +<script>explorer.outline.incSymbolLevel();</script> 219 +<dl> 220 +<script>explorer.outline.writeEnabled = true;</script> 221 +<dt><span class="decl">string 222 +<span class="currsymbol">name</span> 223 +<script>explorer.outline.addDecl('name');</script> 224 + 225 +; 226 +</span></dt> 227 +<script>explorer.outline.writeEnabled = false;</script> 228 + 229 + 230 +<dd><br><br> 231 +</dd> 232 + 233 +<script>explorer.outline.writeEnabled = true;</script> 234 +<dt><span class="decl">Layer 235 +<span class="currsymbol">layer</span> 236 +<script>explorer.outline.addDecl('layer');</script> 237 + 238 +; 239 +</span></dt> 240 +<script>explorer.outline.writeEnabled = false;</script> 241 + 242 + 243 +<dd><br><br> 244 +</dd> 245 + 246 +<script>explorer.outline.writeEnabled = true;</script> 247 +<dt><span class="decl">AST 248 +<span class="currsymbol">init</span> 249 +<script>explorer.outline.addDecl('init');</script> 250 + 251 +; 252 +</span></dt> 253 +<script>explorer.outline.writeEnabled = false;</script> 254 + 255 + 256 +<dd><br><br> 257 +</dd> 258 + 259 +<script>explorer.outline.writeEnabled = true;</script> 260 +<dt><span class="decl">AST 261 +<span class="currsymbol">expr</span> 262 +<script>explorer.outline.addDecl('expr');</script> 263 + 264 +; 265 +</span></dt> 266 +<script>explorer.outline.writeEnabled = false;</script> 267 + 268 + 269 +<dd><br><br> 270 +</dd> 271 +</dl> 272 +<script>explorer.outline.decSymbolLevel();</script> 273 + 274 + 275 +</dd> 276 + 277 +<script>explorer.outline.writeEnabled = true;</script> 278 +<dt><span class="decl">class 279 +<span class="currsymbol">App</span> 280 +<script>explorer.outline.addDecl('App');</script> 281 + 282 +: polemy.ast.AST; 283 +</span></dt> 284 +<script>explorer.outline.writeEnabled = false;</script> 285 + 286 + 287 +<dd>AST node for function application<br><br> 288 + 289 + 290 +<script>explorer.outline.incSymbolLevel();</script> 291 +<dl> 292 +<script>explorer.outline.writeEnabled = true;</script> 293 +<dt><span class="decl">AST 294 +<span class="currsymbol">fun</span> 295 +<script>explorer.outline.addDecl('fun');</script> 296 + 297 +; 298 +</span></dt> 299 +<script>explorer.outline.writeEnabled = false;</script> 300 + 301 + 302 +<dd><br><br> 303 +</dd> 304 + 305 +<script>explorer.outline.writeEnabled = true;</script> 306 +<dt><span class="decl">AST[] 307 +<span class="currsymbol">args</span> 308 +<script>explorer.outline.addDecl('args');</script> 309 + 310 +; 311 +</span></dt> 312 +<script>explorer.outline.writeEnabled = false;</script> 313 + 314 + 315 +<dd><br><br> 316 +</dd> 317 +</dl> 318 +<script>explorer.outline.decSymbolLevel();</script> 319 + 320 + 321 +</dd> 322 + 323 +<script>explorer.outline.writeEnabled = true;</script> 324 +<dt><span class="decl">class 325 +<span class="currsymbol">Parameter</span> 326 +<script>explorer.outline.addDecl('Parameter');</script> 327 + 328 +; 329 +</span></dt> 330 +<script>explorer.outline.writeEnabled = false;</script> 331 + 332 + 333 +<dd><br><br> 334 + 335 +<script>explorer.outline.incSymbolLevel();</script> 336 +<dl> 337 +<script>explorer.outline.writeEnabled = true;</script> 338 +<dt><span class="decl">string 339 +<span class="currsymbol">name</span> 340 +<script>explorer.outline.addDecl('name');</script> 341 + 342 +; 343 +</span></dt> 344 +<script>explorer.outline.writeEnabled = false;</script> 345 + 346 + 347 +<dd><br><br> 348 +</dd> 349 + 350 +<script>explorer.outline.writeEnabled = true;</script> 351 +<dt><span class="decl">string[] 352 +<span class="currsymbol">layers</span> 353 +<script>explorer.outline.addDecl('layers');</script> 354 + 355 +; 356 +</span></dt> 357 +<script>explorer.outline.writeEnabled = false;</script> 358 + 359 + 360 +<dd><br><br> 361 +</dd> 362 +</dl> 363 +<script>explorer.outline.decSymbolLevel();</script> 364 + 365 + 366 +</dd> 367 + 368 +<script>explorer.outline.writeEnabled = true;</script> 369 +<dt><span class="decl">class 370 +<span class="currsymbol">Fun</span> 371 +<script>explorer.outline.addDecl('Fun');</script> 372 + 373 +: polemy.ast.AST; 374 +</span></dt> 375 +<script>explorer.outline.writeEnabled = false;</script> 376 + 377 + 378 +<dd>AST node for function literal<br><br> 379 + 380 + 381 +<script>explorer.outline.incSymbolLevel();</script> 382 +<dl> 383 +<script>explorer.outline.writeEnabled = true;</script> 384 +<dt><span class="decl">Parameter[] 385 +<span class="currsymbol">params</span> 386 +<script>explorer.outline.addDecl('params');</script> 387 + 388 +; 389 +</span></dt> 390 +<script>explorer.outline.writeEnabled = false;</script> 391 + 392 + 393 +<dd><br><br> 394 +</dd> 395 + 396 +<script>explorer.outline.writeEnabled = true;</script> 397 +<dt><span class="decl">AST 398 +<span class="currsymbol">funbody</span> 399 +<script>explorer.outline.addDecl('funbody');</script> 400 + 401 +; 402 +</span></dt> 403 +<script>explorer.outline.writeEnabled = false;</script> 404 + 405 + 406 +<dd><br><br> 407 +</dd> 408 +</dl> 409 +<script>explorer.outline.decSymbolLevel();</script> 410 + 411 + 412 +</dd> 413 + 414 +<script>explorer.outline.writeEnabled = true;</script> 415 +<dt><span class="decl">alias 416 +<span class="currsymbol">ListOfASTTypes</span> 417 +<script>explorer.outline.addDecl('ListOfASTTypes');</script> 418 + 419 +; 420 +</span></dt> 421 +<script>explorer.outline.writeEnabled = false;</script> 422 + 423 + 424 +<dd>List of AST Types<br><br> 425 + 426 +</dd> 427 + 428 +<script>explorer.outline.writeEnabled = true;</script> 429 +<dt><span class="decl">template 430 +<span class="currsymbol">EasyAST</span> 431 +<script>explorer.outline.addDecl('EasyAST');</script> 432 + 433 +()</span></dt> 434 +<script>explorer.outline.writeEnabled = false;</script> 435 + 436 + 437 +<dd>Handy Generator for AST nodes. To use this, mixin EasyAst;<br><br> 438 + 439 + 440 +<script>explorer.outline.incSymbolLevel();</script> 441 +<dl> 442 +<script>explorer.outline.writeEnabled = true;</script> 443 +<dt><span class="decl">template 444 +<span class="currsymbol">genEast</span> 445 +<script>explorer.outline.addDecl('genEast');</script> 446 + 447 +(T)</span></dt> 448 +<script>explorer.outline.writeEnabled = false;</script> 449 + 450 + 451 +<dd><br><br> 452 +</dd> 453 + 454 +<script>explorer.outline.writeEnabled = true;</script> 455 +<dt><span class="decl">alias 456 +<span class="currsymbol">strl</span> 457 +<script>explorer.outline.addDecl('strl');</script> 458 + 459 +; 460 +</span></dt> 461 +<script>explorer.outline.writeEnabled = false;</script> 462 + 463 + 464 +<dd><br><br> 465 +</dd> 466 + 467 +<script>explorer.outline.writeEnabled = true;</script> 468 +<dt><span class="decl">alias 469 +<span class="currsymbol">intl</span> 470 +<script>explorer.outline.addDecl('intl');</script> 471 + 472 +; 473 +</span></dt> 474 +<script>explorer.outline.writeEnabled = false;</script> 475 + 476 + 477 +<dd><br><br> 478 +</dd> 479 + 480 +<script>explorer.outline.writeEnabled = true;</script> 481 +<dt><span class="decl"> 482 +<span class="currsymbol">funp</span> 483 +<script>explorer.outline.addDecl('funp');</script> 484 + 485 +(Parameter[] <span class="funcparam">xs</span>, AST <span class="funcparam">ps</span>); 486 +</span></dt> 487 +<script>explorer.outline.writeEnabled = false;</script> 488 + 489 + 490 +<dd><br><br> 491 +</dd> 492 + 493 +<script>explorer.outline.writeEnabled = true;</script> 494 +<dt><span class="decl">alias 495 +<span class="currsymbol">var</span> 496 +<script>explorer.outline.addDecl('var');</script> 497 + 498 +; 499 +</span></dt> 500 +<script>explorer.outline.writeEnabled = false;</script> 501 + 502 + 503 +<dd><br><br> 504 +</dd> 505 + 506 +<script>explorer.outline.writeEnabled = true;</script> 507 +<dt><span class="decl">alias 508 +<span class="currsymbol">lay</span> 509 +<script>explorer.outline.addDecl('lay');</script> 510 + 511 +; 512 +</span></dt> 513 +<script>explorer.outline.writeEnabled = false;</script> 514 + 515 + 516 +<dd><br><br> 517 +</dd> 518 + 519 +<script>explorer.outline.writeEnabled = true;</script> 520 +<dt><span class="decl">alias 521 +<span class="currsymbol">let</span> 522 +<script>explorer.outline.addDecl('let');</script> 523 + 524 +; 525 +</span></dt> 526 +<script>explorer.outline.writeEnabled = false;</script> 527 + 528 + 529 +<dd><br><br> 530 +</dd> 531 + 532 +<script>explorer.outline.writeEnabled = true;</script> 533 +<dt><span class="decl">alias 534 +<span class="currsymbol">call</span> 535 +<script>explorer.outline.addDecl('call');</script> 536 + 537 +; 538 +</span></dt> 539 +<script>explorer.outline.writeEnabled = false;</script> 540 + 541 + 542 +<dd><br><br> 543 +</dd> 544 + 545 +<script>explorer.outline.writeEnabled = true;</script> 546 +<dt><span class="decl"> 547 +<span class="currsymbol">param</span> 548 +<script>explorer.outline.addDecl('param');</script> 549 + 550 +(string <span class="funcparam">name</span>, string[] <span class="funcparam">lay</span>...); 551 +</span></dt> 552 +<script>explorer.outline.writeEnabled = false;</script> 553 + 554 + 555 +<dd><br><br> 556 +</dd> 557 +</dl> 558 +<script>explorer.outline.decSymbolLevel();</script> 559 + 560 + 561 +</dd> 562 +</dl> 563 +<script>explorer.outline.decSymbolLevel();</script> 564 + 565 + 566 +</td></tr> 567 + <tr><td id="docfooter"> 568 + Page was generated with 569 + <img src="candydoc/img/candydoc.gif" style="vertical-align:middle; position:relative; top:-1px"> 570 + on Wed Nov 24 19:09:32 2010 571 + 572 + </td></tr> 573 + </table> 574 +</div> 575 +<script> 576 + explorer.packageExplorer.addModule("index"); 577 + explorer.packageExplorer.addModule("main"); 578 + explorer.packageExplorer.addModule("tricks.tricks"); 579 + explorer.packageExplorer.addModule("tricks.test"); 580 + explorer.packageExplorer.addModule("polemy._common"); 581 + explorer.packageExplorer.addModule("polemy.failure"); 582 + explorer.packageExplorer.addModule("polemy.layer"); 583 + explorer.packageExplorer.addModule("polemy.fresh"); 584 + explorer.packageExplorer.addModule("polemy.lex"); 585 + explorer.packageExplorer.addModule("polemy.parse"); 586 + explorer.packageExplorer.addModule("polemy.ast"); 587 + explorer.packageExplorer.addModule("polemy.value"); 588 + explorer.packageExplorer.addModule("polemy.valueconv"); 589 + explorer.packageExplorer.addModule("polemy.eval"); 590 + explorer.packageExplorer.addModule("polemy.runtime"); 591 + explorer.packageExplorer.addModule("polemy.repl");</script> 592 +</body></html> 593 + 594 +

Added doc/eval.html version [6f684a1106faa774]

1 + 2 +<html><head> 3 +<meta http-equiv="content-type" content="text/html; charset=utf-8"> 4 +<meta content="text/javascript" http-equiv="content-script-type"> 5 +<title>polemy.eval</title> 6 +<link rel="stylesheet" type="text/css" href="candydoc/style.css"> 7 +<!--[if lt IE 7]><link rel="stylesheet" type="text/css" href="candydoc/ie56hack.css"><![endif]--> 8 +<script language="JavaScript" src="candydoc/util.js" type="text/javascript"></script> 9 +<script language="JavaScript" src="candydoc/tree.js" type="text/javascript"></script> 10 +<script language="JavaScript" src="candydoc/explorer.js" type="text/javascript"></script> 11 +</head><body> 12 +<div id="tabarea"></div><div id="explorerclient"></div> 13 +<div id="content"><script>explorer.initialize("polemy.eval");</script> 14 + <table class="content"> 15 + <tr><td id="docbody"><h1>polemy.eval</h1><!-- Generated by Ddoc from polemy\eval.d --> 16 +<b>Authors:</b><br> 17 +k.inaba 18 +<br><br> 19 +<b>License:</b><br> 20 +NYSL 0.9982 http://www.kmonos.net/nysl/ 21 +<br><br> 22 + 23 + Evaluator for Polemy programming language.<br><br> 24 + 25 + 26 +<script>explorer.outline.incSymbolLevel();</script> 27 +<dl> 28 +<script>explorer.outline.writeEnabled = true;</script> 29 +<dt><span class="decl">class 30 +<span class="currsymbol">Evaluator</span> 31 +<script>explorer.outline.addDecl('Evaluator');</script> 32 + 33 +; 34 +</span></dt> 35 +<script>explorer.outline.writeEnabled = false;</script> 36 + 37 + 38 +<dd>Objects for maitaining global environment and evaluation of expression on it<br><br> 39 + 40 + 41 +<script>explorer.outline.incSymbolLevel();</script> 42 +<dl> 43 +<script>explorer.outline.writeEnabled = true;</script> 44 +<dt><span class="decl">this(); 45 +</span></dt> 46 +<script>explorer.outline.writeEnabled = false;</script> 47 + 48 + 49 +<dd>Initialize evaluator with empty context<br><br> 50 + 51 +</dd> 52 + 53 +<script>explorer.outline.writeEnabled = true;</script> 54 +<dt><span class="decl">Value 55 +<span class="currsymbol">evalAST</span> 56 +<script>explorer.outline.addDecl('evalAST');</script> 57 + 58 +(AST <span class="funcparam">e</span>); 59 +</span></dt> 60 +<script>explorer.outline.writeEnabled = false;</script> 61 + 62 + 63 +<dd>Evaluate the AST<br><br> 64 + 65 +</dd> 66 + 67 +<script>explorer.outline.writeEnabled = true;</script> 68 +<dt><span class="decl">Value 69 +<span class="currsymbol">evalString</span> 70 +<script>explorer.outline.addDecl('evalString');</script> 71 + 72 +(S, T...)(S <span class="funcparam">str</span>, T <span class="funcparam">fn_ln_cn</span>); 73 +</span></dt> 74 +<script>explorer.outline.writeEnabled = false;</script> 75 + 76 + 77 +<dd>Evaluate the string<br><br> 78 + 79 +</dd> 80 + 81 +<script>explorer.outline.writeEnabled = true;</script> 82 +<dt><span class="decl">Value 83 +<span class="currsymbol">evalFile</span> 84 +<script>explorer.outline.addDecl('evalFile');</script> 85 + 86 +(S, T...)(S <span class="funcparam">filename</span>, T <span class="funcparam">ln_cn</span>); 87 +</span></dt> 88 +<script>explorer.outline.writeEnabled = false;</script> 89 + 90 + 91 +<dd>Evaluate the file<br><br> 92 + 93 +</dd> 94 + 95 +<script>explorer.outline.writeEnabled = true;</script> 96 +<dt><span class="decl">Table 97 +<span class="currsymbol">globalContext</span> 98 +<script>explorer.outline.addDecl('globalContext');</script> 99 + 100 +(); 101 +</span></dt> 102 +<script>explorer.outline.writeEnabled = false;</script> 103 + 104 + 105 +<dd>Get the global context<br><br> 106 + 107 +</dd> 108 + 109 +<script>explorer.outline.writeEnabled = true;</script> 110 +<dt><span class="decl">void 111 +<span class="currsymbol">addPrimitive</span> 112 +<script>explorer.outline.addDecl('addPrimitive');</script> 113 + 114 +(R, T...)(string <span class="funcparam">name</span>, Layer <span class="funcparam">defLay</span>, R delegate(T) <span class="funcparam">dg</span>); 115 +</span></dt> 116 +<script>explorer.outline.writeEnabled = false;</script> 117 + 118 + 119 +<dd>Add primitive function to the global context<br><br> 120 + 121 +</dd> 122 +</dl> 123 +<script>explorer.outline.decSymbolLevel();</script> 124 + 125 + 126 +</dd> 127 +</dl> 128 +<script>explorer.outline.decSymbolLevel();</script> 129 + 130 + 131 +</td></tr> 132 + <tr><td id="docfooter"> 133 + Page was generated with 134 + <img src="candydoc/img/candydoc.gif" style="vertical-align:middle; position:relative; top:-1px"> 135 + on Wed Nov 24 19:09:32 2010 136 + 137 + </td></tr> 138 + </table> 139 +</div> 140 +<script> 141 + explorer.packageExplorer.addModule("index"); 142 + explorer.packageExplorer.addModule("main"); 143 + explorer.packageExplorer.addModule("tricks.tricks"); 144 + explorer.packageExplorer.addModule("tricks.test"); 145 + explorer.packageExplorer.addModule("polemy._common"); 146 + explorer.packageExplorer.addModule("polemy.failure"); 147 + explorer.packageExplorer.addModule("polemy.layer"); 148 + explorer.packageExplorer.addModule("polemy.fresh"); 149 + explorer.packageExplorer.addModule("polemy.lex"); 150 + explorer.packageExplorer.addModule("polemy.parse"); 151 + explorer.packageExplorer.addModule("polemy.ast"); 152 + explorer.packageExplorer.addModule("polemy.value"); 153 + explorer.packageExplorer.addModule("polemy.valueconv"); 154 + explorer.packageExplorer.addModule("polemy.eval"); 155 + explorer.packageExplorer.addModule("polemy.runtime"); 156 + explorer.packageExplorer.addModule("polemy.repl");</script> 157 +</body></html> 158 + 159 +

Added doc/failure.html version [b03822e245636a24]

1 + 2 +<html><head> 3 +<meta http-equiv="content-type" content="text/html; charset=utf-8"> 4 +<meta content="text/javascript" http-equiv="content-script-type"> 5 +<title>polemy.failure</title> 6 +<link rel="stylesheet" type="text/css" href="candydoc/style.css"> 7 +<!--[if lt IE 7]><link rel="stylesheet" type="text/css" href="candydoc/ie56hack.css"><![endif]--> 8 +<script language="JavaScript" src="candydoc/util.js" type="text/javascript"></script> 9 +<script language="JavaScript" src="candydoc/tree.js" type="text/javascript"></script> 10 +<script language="JavaScript" src="candydoc/explorer.js" type="text/javascript"></script> 11 +</head><body> 12 +<div id="tabarea"></div><div id="explorerclient"></div> 13 +<div id="content"><script>explorer.initialize("polemy.failure");</script> 14 + <table class="content"> 15 + <tr><td id="docbody"><h1>polemy.failure</h1><!-- Generated by Ddoc from polemy\failure.d --> 16 +<b>Authors:</b><br> 17 +k.inaba 18 +<br><br> 19 +<b>License:</b><br> 20 +NYSL 0.9982 http://www.kmonos.net/nysl/ 21 +<br><br> 22 + 23 + Error Information for Polemy Programming Language<br><br> 24 + 25 + 26 +<script>explorer.outline.incSymbolLevel();</script> 27 +<dl> 28 +<script>explorer.outline.writeEnabled = true;</script> 29 +<dt><span class="decl">alias 30 +<span class="currsymbol">LexPosition</span> 31 +<script>explorer.outline.addDecl('LexPosition');</script> 32 + 33 +; 34 +</span></dt> 35 +<script>explorer.outline.writeEnabled = false;</script> 36 + 37 + 38 +<dd>Represents a position in source codes<br><br> 39 + 40 +</dd> 41 + 42 +<script>explorer.outline.writeEnabled = true;</script> 43 +<dt><span class="decl">class 44 +<span class="currsymbol">LexPosition_t</span> 45 +<script>explorer.outline.addDecl('LexPosition_t');</script> 46 + 47 +; 48 +</span></dt> 49 +<script>explorer.outline.writeEnabled = false;</script> 50 + 51 + 52 +<dd>Represents a position in source codes<br><br> 53 + 54 + 55 +<script>explorer.outline.incSymbolLevel();</script> 56 +<dl> 57 +<script>explorer.outline.writeEnabled = true;</script> 58 +<dt><span class="decl">immutable string 59 +<span class="currsymbol">filename</span> 60 +<script>explorer.outline.addDecl('filename');</script> 61 + 62 +; 63 +</span></dt> 64 +<script>explorer.outline.writeEnabled = false;</script> 65 + 66 + 67 +<dd>name of the source file<br><br> 68 + 69 +</dd> 70 + 71 +<script>explorer.outline.writeEnabled = true;</script> 72 +<dt><span class="decl">immutable int 73 +<span class="currsymbol">lineno</span> 74 +<script>explorer.outline.addDecl('lineno');</script> 75 + 76 +; 77 +</span></dt> 78 +<script>explorer.outline.writeEnabled = false;</script> 79 + 80 + 81 +<dd>1-origin<br><br> 82 + 83 +</dd> 84 + 85 +<script>explorer.outline.writeEnabled = true;</script> 86 +<dt><span class="decl">immutable int 87 +<span class="currsymbol">column</span> 88 +<script>explorer.outline.addDecl('column');</script> 89 + 90 +; 91 +</span></dt> 92 +<script>explorer.outline.writeEnabled = false;</script> 93 + 94 + 95 +<dd>1-origin<br><br> 96 + 97 +</dd> 98 +</dl> 99 +<script>explorer.outline.decSymbolLevel();</script> 100 + 101 + 102 +</dd> 103 + 104 +<script>explorer.outline.writeEnabled = true;</script> 105 +<dt><span class="decl">class 106 +<span class="currsymbol">UnexpectedEOF</span> 107 +<script>explorer.outline.addDecl('UnexpectedEOF');</script> 108 + 109 +: object.Exception; 110 +</span></dt> 111 +<script>explorer.outline.writeEnabled = false;</script> 112 + 113 + 114 +<dd>EOF during lexing/parsing<br><br> 115 + 116 +</dd> 117 + 118 +<script>explorer.outline.writeEnabled = true;</script> 119 +<dt><span class="decl">class 120 +<span class="currsymbol">LexException</span> 121 +<script>explorer.outline.addDecl('LexException');</script> 122 + 123 +: object.Exception; 124 +</span></dt> 125 +<script>explorer.outline.writeEnabled = false;</script> 126 + 127 + 128 +<dd>Lexer errors<br><br> 129 + 130 +</dd> 131 + 132 +<script>explorer.outline.writeEnabled = true;</script> 133 +<dt><span class="decl">class 134 +<span class="currsymbol">ParseException</span> 135 +<script>explorer.outline.addDecl('ParseException');</script> 136 + 137 +: object.Exception; 138 +</span></dt> 139 +<script>explorer.outline.writeEnabled = false;</script> 140 + 141 + 142 +<dd>Parser errors<br><br> 143 + 144 +</dd> 145 + 146 +<script>explorer.outline.writeEnabled = true;</script> 147 +<dt><span class="decl">class 148 +<span class="currsymbol">RuntimeException</span> 149 +<script>explorer.outline.addDecl('RuntimeException');</script> 150 + 151 +: object.Exception; 152 +</span></dt> 153 +<script>explorer.outline.writeEnabled = false;</script> 154 + 155 + 156 +<dd>Evaluator errors<br><br> 157 + 158 +</dd> 159 + 160 +<script>explorer.outline.writeEnabled = true;</script> 161 +<dt><span class="decl">class 162 +<span class="currsymbol">PushCallStack</span> 163 +<script>explorer.outline.addDecl('PushCallStack');</script> 164 + 165 +; 166 +</span></dt> 167 +<script>explorer.outline.writeEnabled = false;</script> 168 + 169 + 170 +<dd>Per-thread call stack management. 171 + This scoped class's ctor&dtor maintain the callstack. 172 +<br><br> 173 +<b>TODO:</b><br> 174 +make it "per-evaluator" !!!!!!!!!!!<br><br> 175 + 176 +</dd> 177 +</dl> 178 +<script>explorer.outline.decSymbolLevel();</script> 179 + 180 + 181 +</td></tr> 182 + <tr><td id="docfooter"> 183 + Page was generated with 184 + <img src="candydoc/img/candydoc.gif" style="vertical-align:middle; position:relative; top:-1px"> 185 + on Wed Nov 24 19:09:32 2010 186 + 187 + </td></tr> 188 + </table> 189 +</div> 190 +<script> 191 + explorer.packageExplorer.addModule("index"); 192 + explorer.packageExplorer.addModule("main"); 193 + explorer.packageExplorer.addModule("tricks.tricks"); 194 + explorer.packageExplorer.addModule("tricks.test"); 195 + explorer.packageExplorer.addModule("polemy._common"); 196 + explorer.packageExplorer.addModule("polemy.failure"); 197 + explorer.packageExplorer.addModule("polemy.layer"); 198 + explorer.packageExplorer.addModule("polemy.fresh"); 199 + explorer.packageExplorer.addModule("polemy.lex"); 200 + explorer.packageExplorer.addModule("polemy.parse"); 201 + explorer.packageExplorer.addModule("polemy.ast"); 202 + explorer.packageExplorer.addModule("polemy.value"); 203 + explorer.packageExplorer.addModule("polemy.valueconv"); 204 + explorer.packageExplorer.addModule("polemy.eval"); 205 + explorer.packageExplorer.addModule("polemy.runtime"); 206 + explorer.packageExplorer.addModule("polemy.repl");</script> 207 +</body></html> 208 + 209 +

Added doc/fresh.html version [f07559eb4d6cfc68]

1 + 2 +<html><head> 3 +<meta http-equiv="content-type" content="text/html; charset=utf-8"> 4 +<meta content="text/javascript" http-equiv="content-script-type"> 5 +<title>polemy.fresh</title> 6 +<link rel="stylesheet" type="text/css" href="candydoc/style.css"> 7 +<!--[if lt IE 7]><link rel="stylesheet" type="text/css" href="candydoc/ie56hack.css"><![endif]--> 8 +<script language="JavaScript" src="candydoc/util.js" type="text/javascript"></script> 9 +<script language="JavaScript" src="candydoc/tree.js" type="text/javascript"></script> 10 +<script language="JavaScript" src="candydoc/explorer.js" type="text/javascript"></script> 11 +</head><body> 12 +<div id="tabarea"></div><div id="explorerclient"></div> 13 +<div id="content"><script>explorer.initialize("polemy.fresh");</script> 14 + <table class="content"> 15 + <tr><td id="docbody"><h1>polemy.fresh</h1><!-- Generated by Ddoc from polemy\fresh.d --> 16 +<b>Authors:</b><br> 17 +k.inaba 18 +<br><br> 19 +<b>License:</b><br> 20 +NYSL 0.9982 http://www.kmonos.net/nysl/ 21 +<br><br> 22 + 23 + Interpreter-wise 24 +<span class="currsymbol">fresh</span> 25 +<script>explorer.outline.addDecl('fresh');</script> 26 + 27 + ID generator.<br><br> 28 + 29 + 30 +<script>explorer.outline.incSymbolLevel();</script> 31 +<dl> 32 +<script>explorer.outline.writeEnabled = true;</script> 33 +<dt><span class="decl">string 34 +<span class="currsymbol">freshVarName</span> 35 +<script>explorer.outline.addDecl('freshVarName');</script> 36 + 37 +(); 38 +</span></dt> 39 +<script>explorer.outline.writeEnabled = false;</script> 40 + 41 + 42 +<dd>Generate one fresh variable name<br><br> 43 + 44 +</dd> 45 +</dl> 46 +<script>explorer.outline.decSymbolLevel();</script> 47 + 48 + 49 +</td></tr> 50 + <tr><td id="docfooter"> 51 + Page was generated with 52 + <img src="candydoc/img/candydoc.gif" style="vertical-align:middle; position:relative; top:-1px"> 53 + on Wed Nov 24 19:09:32 2010 54 + 55 + </td></tr> 56 + </table> 57 +</div> 58 +<script> 59 + explorer.packageExplorer.addModule("index"); 60 + explorer.packageExplorer.addModule("main"); 61 + explorer.packageExplorer.addModule("tricks.tricks"); 62 + explorer.packageExplorer.addModule("tricks.test"); 63 + explorer.packageExplorer.addModule("polemy._common"); 64 + explorer.packageExplorer.addModule("polemy.failure"); 65 + explorer.packageExplorer.addModule("polemy.layer"); 66 + explorer.packageExplorer.addModule("polemy.fresh"); 67 + explorer.packageExplorer.addModule("polemy.lex"); 68 + explorer.packageExplorer.addModule("polemy.parse"); 69 + explorer.packageExplorer.addModule("polemy.ast"); 70 + explorer.packageExplorer.addModule("polemy.value"); 71 + explorer.packageExplorer.addModule("polemy.valueconv"); 72 + explorer.packageExplorer.addModule("polemy.eval"); 73 + explorer.packageExplorer.addModule("polemy.runtime"); 74 + explorer.packageExplorer.addModule("polemy.repl");</script> 75 +</body></html> 76 + 77 +

Added doc/index.html version [bd75516fd263e529]

1 + 2 +<html><head> 3 +<meta http-equiv="content-type" content="text/html; charset=utf-8"> 4 +<meta content="text/javascript" http-equiv="content-script-type"> 5 +<title>Polemy Reference Manual</title> 6 +<link rel="stylesheet" type="text/css" href="candydoc/style.css"> 7 +<!--[if lt IE 7]><link rel="stylesheet" type="text/css" href="candydoc/ie56hack.css"><![endif]--> 8 +<script language="JavaScript" src="candydoc/util.js" type="text/javascript"></script> 9 +<script language="JavaScript" src="candydoc/tree.js" type="text/javascript"></script> 10 +<script language="JavaScript" src="candydoc/explorer.js" type="text/javascript"></script> 11 +</head><body> 12 +<div id="tabarea"></div><div id="explorerclient"></div> 13 +<div id="content"><script>explorer.initialize("Polemy Reference Manual");</script> 14 + <table class="content"> 15 + <tr><td id="docbody"><h1>Polemy Reference Manual</h1><!-- Generated by Ddoc from index.dd --> 16 + 17 +<b>Authors:</b><br> 18 +k.inaba<br><br> 19 +<b>License:</b><br> 20 +NYSL 0.9982 (http://www.kmonos.net/nysl/)<br><br> 21 + 22 +<p> 23 +このファイルは、言語仕様などの簡単な説明です。 24 +</p> 25 +<p> 26 +あとついでに、左のサイドバーの "Package" タブをクリックすると実装のソースのドキュメントが読めます。 27 +</p> 28 + 29 + 30 +<script>explorer.outline.incSymbolLevel();</script> 31 +<dl> 32 +<script>explorer.outline.writeEnabled = true;</script> 33 +<dt><span class="decl"> 34 +<span class="currsymbol">Syntax</span> 35 +<script>explorer.outline.addDecl('Syntax');</script> 36 + 37 +</span></dt> 38 +<script>explorer.outline.writeEnabled = false;</script> 39 + 40 + <dd><p> 41 +文法について。 42 +字句解析がわりと適当なので、 43 +変数宣言の変数名のところに、数字を変数名として使えて参照できない変数が作れたり、 44 +予約語は予約語として解釈され得ないところでは普通に変数名として使えちゃったりして、 45 +偶にとんでもない見かけのソースが構文解析通りますが、気にしないで適当に使って下さい。 46 +</p> 47 + 48 + 49 +<script>explorer.outline.incSymbolLevel();</script> 50 +<dl> 51 +<script>explorer.outline.writeEnabled = true;</script> 52 +<dt><span class="decl"> 53 +<span class="currsymbol">文字コード</span> 54 +<script>explorer.outline.addDecl('文字コード');</script> 55 + 56 +</span></dt> 57 +<script>explorer.outline.writeEnabled = false;</script> 58 + 59 + <dd><p> 60 +UTF-8 のみ対応です。 61 +</p> 62 +</dd> 63 + 64 + 65 +<script>explorer.outline.writeEnabled = true;</script> 66 +<dt><span class="decl"> 67 +<span class="currsymbol">コメント</span> 68 +<script>explorer.outline.addDecl('コメント');</script> 69 + 70 +</span></dt> 71 +<script>explorer.outline.writeEnabled = false;</script> 72 + 73 + <dd><p> 74 +行コメントは <tt>#</tt> から改行までです。 75 +</p> 76 +<p> 77 +ブロックコメントはありません。 78 +</p> 79 +</dd> 80 + 81 + 82 +<script>explorer.outline.writeEnabled = true;</script> 83 +<dt><span class="decl"> 84 +<span class="currsymbol">BNF</span> 85 +<script>explorer.outline.addDecl('BNF');</script> 86 + 87 +</span></dt> 88 +<script>explorer.outline.writeEnabled = false;</script> 89 + 90 + <dd><pre> 91 + ID ::= 適当に識別子っぽい文字列 92 + LAYER ::= "@" ID 93 + 94 + E ::= 95 + <font color=green># 変数宣言</font> 96 + | ("var"|"let"|"def"|LAYER) ID "=" E (";"|"in") E 97 + | ("var"|"let"|"def"|LAYER) ID "(" PARAMS ")" "{" E "}" (";"|"in") E 98 + | ("var"|"let"|"def"|LAYER) ID "=" E 99 + | ("var"|"let"|"def"|LAYER) ID "(" PARAMS ")" "{" E "}" 100 + 101 + <font color=green># リテラル</font> 102 + | INTEGER <font color=green># 非負整数</font> 103 + | STRING <font color=green># "" でくくった文字列。\" と \\ は使える</font> 104 + | "{" ENTRYS "}" <font color=green># テーブル</font> 105 + | "fun" "(" PARAMS ")" "{" E "}" <font color=green># 無名関数</font> 106 + | "λ" "(" PARAMS ")" "{" E "}" <font color=green># 無名関数</font> 107 + 108 + <font color=green># 関数呼び出し</font> 109 + | E "(" ARGS")" 110 + 111 + where ARGS ::= E "," ... "," E 112 + PARAMS ::= (ID|LAYER)+ "," ... "," (ID|LAYER)+ 113 + ENTRYS ::= ID ":" E "," ... "," ID ":" E 114 + 115 + <font color=green># 演算子など</font> 116 + | "(" E ")" <font color=green># ただの括弧</font> 117 + | E BINOP E <font color=green># 二項演算子いろいろ</font> 118 + | E "." ID <font color=green># テーブルのフィールドアクセス</font> 119 + | E ".?" ID <font color=green># テーブルにフィールドがあるか否か</font> 120 + | E "{" ENTRYS "}" <font color=green># テーブル拡張</font> 121 + | "if" "(" E ")" "{" E "}" 122 + | "if" "(" E ")" "{" E "}" "else "{" E "}" 123 + 124 + <font color=green># パターンマッチ</font> 125 + | "case" "(" E ")" ("when" "(" PATTERN ")" "{" E "}")* 126 + 127 + where PATTERN ::= 式がだいたいなんでも書ける気がする 128 + 129 + <font color=green># レイヤ指定実行</font> 130 + | LAYER "(" E ")" 131 +</pre> 132 +</dd> 133 + 134 + 135 +<script>explorer.outline.writeEnabled = true;</script> 136 +<dt><span class="decl"> 137 +<span class="currsymbol">糖衣構文</span> 138 +<script>explorer.outline.addDecl('糖衣構文');</script> 139 + 140 +</span></dt> 141 +<script>explorer.outline.writeEnabled = false;</script> 142 + 143 + <dd><p> 144 +演算子というものはありません。内部的には全て関数呼び出し構文に書き換えられています。<tt>if</tt> もです。 145 +<br/> 146 +パターンマッチも全部 <tt>if</tt> と <tt>==</tt> と <tt>&amp;&amp;</tt> と 147 +<tt>.</tt> と <tt>.?</tt> を使った関数呼び出し式に書き換えられていますが、 148 +規則の詳細を説明するのが面倒なので適当に想像して下さい。 149 +他の書き換えはこんな感じです。 150 +</p> 151 +<pre> 152 + if (E) {E} ⇒ if( E, fun(){E}, fun(){} ) 153 + if (E) {E} else {E} ⇒ if( E, fun(){E}, fun(){E} ) 154 + E BINOP E ⇒ BINOP(E, E) 155 + { ENTRIES } ⇒ {}{ ENTRIES } 156 + {} ⇒ {}() 157 + E {ID:E, ...} ⇒ .=(E, ID, E) { ... } 158 +</pre> 159 +<p> 160 +変数宣言に色々ありますが、<tt>let</tt> と <tt>var</tt> と <tt>def</tt> は同じ扱いで、 161 +<tt>in</tt> と <tt>;</tt> は同じ扱いです。つまり 162 +</p> 163 +<pre> 164 + let x = E in E 165 + var x = E in E 166 + def x = E in E 167 + let x = E ; E 168 + var x = E ; E 169 + def x = E ; E 170 +</pre> 171 +<p> 172 +以上のどれも同じ意味なので、なんとなく関数型っぽく書きたい気分の日は <tt>let in</tt> を、 173 +手続き型っぽく書きたい気分の日は <tt>var ;</tt> を使うとよいでしょう。 174 +</p> 175 +<p> 176 +関数を宣言するときは、<tt>fun</tt> や <tt>λ</tt> を省略できます。 177 +以下の書き換えが行われます。 178 +</p> 179 +<pre> 180 + def f( ARGS ) { E }; E ⇒ def f = fun(ARGS){E}; E 181 +</pre> 182 +<p> 183 +他に、もっと手続き型っぽくための書き換え色々 184 +</p> 185 +<pre> 186 + fun () { E; E; E } ⇒ fun () { let _ = E in let _ = E in E } 187 + fun () { var x = 100 } ⇒ fun () { var x = 100; x } 188 + fun () { var x = 100; } ⇒ fun () { var x = 100; x } 189 + fun () { } ⇒ fun () { "(empty function body)" } 190 +</pre> 191 +<p> 192 +中身が空の関数に何を返させるかは適当です。今はとりあえず適当に文字列返してます。 193 +</p> 194 +</dd> 195 + 196 + 197 +<script>explorer.outline.writeEnabled = true;</script> 198 +<dt><span class="decl"> 199 +<span class="currsymbol">変数のスコープ規則</span> 200 +<script>explorer.outline.addDecl('変数のスコープ規則');</script> 201 + 202 +</span></dt> 203 +<script>explorer.outline.writeEnabled = false;</script> 204 + 205 + <dd><p> 206 +基本的には、let によって常識的な感じに変数のスコープがネストします。 207 +</p> 208 +<pre> 209 + let x=21 in let x=x+x in x <font color=green># 42</font> 210 +</pre> 211 +<p> 212 +一方で、"let rec" のような特別な構文はありませんが、 213 +</p> 214 +<pre> 215 + let f = fun(x) { if(x==0){1}else{x*f(x-1)} } in f(10) <font color=green># 3628800</font> 216 +</pre> 217 +<p> 218 +再帰的な関数定義なども、おそらく意図されたとおりに動きます。 219 +内部の詳細は、諸般の事情により、 220 +マジカルで破壊的なスコープ規則になっているのですが、 221 +同名の変数を激しく重ねて使ったりしなければ、 222 +だいたい自然な動きをすると思います、たぶん、はい。 223 +</p> 224 +<p> 225 +ひとつだけ不可思議な動きをするのは、以下のケースです。 226 +</p> 227 +<pre> 228 + let x = 1 in 229 + let f = fun() {x} in 230 + let x = 2 in 231 + f() <font color=green># 2!!</font> 232 +</pre> 233 +<p> 234 +let-in を縦にチェインしたときだけ、同名変数を破壊的に上書きします 235 +(再帰関数の定義が"うまく"いっているのはこの上書きのためです)。 236 +なんでこんなことになっているかというと、 237 +後で説明する「レイヤ」を使ったときに 238 +<tt>let foo = ... in @lay foo = ... in ...</tt> 239 +で他レイヤに重ね書きするためであります。 240 +</p> 241 +</dd> 242 +</dl> 243 +<script>explorer.outline.decSymbolLevel();</script> 244 + 245 + 246 +</dd> 247 + 248 + 249 + 250 + 251 + 252 +<script>explorer.outline.writeEnabled = true;</script> 253 +<dt><span class="decl"> 254 +<span class="currsymbol">Basic Features</span> 255 +<script>explorer.outline.addDecl('Basic Features');</script> 256 + 257 +</span></dt> 258 +<script>explorer.outline.writeEnabled = false;</script> 259 + 260 + <dd><p> 261 +特に特徴的でもない部分を簡単にまとめ。 262 +</p> 263 +<ul> 264 + <li>静的型システムはありません。</li> 265 + <li>"ほぼ" 純粋関数型言語です。変数やテーブルのフィールドの破壊的な書き換えはできません。<br/> 266 + ただし、組み込み関数(<tt>print</tt>)と、変数のスコープ規則のマジカルな片隅に副作用があります。</li> 267 +</ul> 268 +<p> 269 +静的型システムがないのは意図的ですが、破壊的代入がないのは、単に実装がめんどかっただけなので、 270 +今後何か増えるかもしれません。増えないかもしれません。 271 +</p> 272 + 273 +<script>explorer.outline.incSymbolLevel();</script> 274 +<dl> 275 +<script>explorer.outline.writeEnabled = true;</script> 276 +<dt><span class="decl"> 277 +<span class="currsymbol">データ型</span> 278 +<script>explorer.outline.addDecl('データ型');</script> 279 + 280 +</span></dt> 281 +<script>explorer.outline.writeEnabled = false;</script> 282 + 283 + <dd><p> 284 +以下のデータ型があります。 285 +</p> 286 +<ul> 287 + <li>整数: <tt>0</tt>, <tt>123</tt>, <tt>456666666666666666666666666666666666666789</tt>, ...</li> 288 + <li>文字列: <tt>"hello, world!"</tt>, ...</li> 289 + <li>関数: <tt>fun(x){x+1}</tt></li> 290 + <li>テーブル: <tt>{car: 1, cdr: {car: 2, cdr: {}}}</tt></li> 291 + <li>未定義値: (テーブルの、存在しないフィールドにアクセスしたりすると作れます)</li> 292 +</ul> 293 +<p> 294 +関数はいわゆる「クロージャ」です。静的スコープで外側の環境にアクセスできます。 295 +テーブルはいわゆるプロトタイプチェーンを持っていて、 296 +自分にないフィールドの場合は親に問い合わせが行く感じになっていますが、 297 +フィールドの書き換えがないので、これは特に意味ないかもしれない…。 298 +</p> 299 +</dd> 300 + 301 +<script>explorer.outline.writeEnabled = true;</script> 302 +<dt><span class="decl"> 303 +<span class="currsymbol">パターンマッチ</span> 304 +<script>explorer.outline.addDecl('パターンマッチ');</script> 305 + 306 +</span></dt> 307 +<script>explorer.outline.writeEnabled = false;</script> 308 + 309 + <dd><p> 310 +適当に実装されたパターンマッチがあります。 311 +リストの 2n 番目と 2n+1 番目を足して長さを半分にする関数: 312 +</p> 313 +<pre> 314 + def adjSum(lst) 315 + { 316 + case( lst ) 317 + when( {car:x, cdr:{car: y, cdr:z}} ) { {car: x+y, cdr: adjSum(z)} } 318 + when( {car:x, cdr:{}} ) { lst } 319 + when( {} ) { {} } 320 + } 321 +</pre> 322 +<p> 323 +動かすときには、処理系がそれっぽい if-then-else に展開しています。 324 +<tt>when</tt> を上から試していって、最初にマッチしたところを実行します。 325 +</p> 326 +<pre> 327 + PAT ::= "_" <font color=green># ワイルドカード</font> 328 + | ID <font color=green># 変数パターン</font> 329 + | "{" ID ":" PAT "," ... "," ID : PAT "}" <font color=green># テーブルパターン</font> 330 + | E <font color=green># 値パターン</font> 331 +</pre> 332 +<p> 333 +変数パターンは常にマッチして、値をその変数に束縛します。 334 +ワイルドカードも常にマッチしますが、変数束縛しません。 335 +値パターンは、任意の式が書けます。その式を評価した結果と <tt>==</tt> ならマッチします。 336 +外で束縛された変数を値パターンとして配置、は直接はできないので 337 +</p> 338 +<pre> 339 + var x = 123; 340 + case( foo ) 341 + when( {val: x+0} ) { ... } <font color=green># これは任意の {val:123} と同じ</font> 342 + when( {val: x} ) { ... } <font color=green># これは任意の foo.?val なら常にマッチ</font> 343 +</pre> 344 +<p> 345 +適当にちょっと複雑な式にしてやるとよいかも(裏技)。 346 +</p> 347 +<p> 348 +テーブルパターンは、書かれたキーが全てあればマッチします。 349 +<tt>{a: _}</tt> は、<tt>.a</tt> を持ってさえいればマッチするので、 350 +<tt>{a: 123, b: 456}</tt> なんかにもマッチします。 351 +なので、リストに対するパターンを書くときには、car/cdr の場合を先に書かないと 352 +<tt>when({})</tt> を上に書くと全部マッチしちゃいます。注意。 353 +</p> 354 +</dd> 355 +</dl> 356 +<script>explorer.outline.decSymbolLevel();</script> 357 + 358 + 359 +</dd> 360 + 361 + 362 + 363 + 364 + 365 + 366 +<script>explorer.outline.writeEnabled = true;</script> 367 +<dt><span class="decl"> 368 +<span class="currsymbol">Layers</span> 369 +<script>explorer.outline.addDecl('Layers');</script> 370 + 371 +</span></dt> 372 +<script>explorer.outline.writeEnabled = false;</script> 373 + 374 + <dd><pre> 375 +[Layers :: Overview] 376 + 377 + Polemy's runtime environment has many "layer"s. 378 + Usual execution run in the @value layer. 379 + 380 + &gt;&gt; 1 + 2 381 + 3 382 + &gt;&gt; @value( 1 + 2 ) 383 + 3 384 + 385 + Here you can see that @LayerName( Expression ) executes the inner Expression in 386 + the @LayerName layer. Other than @value, one other predefined layer exists: @macro. 387 + 388 + &gt;&gt; @macro( 1+2 ) 389 + {pos@value:{lineno@value:3, column@value:9, filename@value:<REPL>}, 390 + is@value:app, 391 + args@value:{car@value:{pos@value:{lineno@value:3, column@value:9, filename@value:<REPL>}, 392 + is@value:int, 393 + data@value:1}, 394 + cdr@value:{ 395 + car@value:{pos@value:{lineno@value:3, column@value:11, filename@value:<REPL>}, 396 + is@value:int, 397 + data@value:2}, 398 + cdr@value:{}}}, 399 + fun@value:{pos@value:{lineno@value:3, column@value:10, filename@value:<REPL>}, 400 + is@value:var, 401 + name@value:+}} 402 + 403 + (Sorry, this pretty printing is not available on the actual interpreter...) 404 + This evaluates the expression 1+2 in the @macro layer. In this layer, the meaning of 405 + the program is its abstract syntax tree. 406 + 407 + You can interleave layers. 408 + The root node of the abstract syntax tree is function "app"lication. 409 + 410 + &gt;&gt; @value(@macro( 1+2 ).is) 411 + app 412 + 413 + 414 + 415 +[Layers :: Defining a new layer] 416 + 417 + To define a new layer, you should first tell how to "lift" existing values two the new layer. 418 + Let us define the "@type" layer, where the meaning of programs is their static type. 419 + 420 + &gt;&gt; @@type = fun(x) { 421 + &gt;&gt; if( _isint(x) ) { "int" } else { 422 + &gt;&gt; if( _isfun(x) ) { x } else { "unknown" } } 423 + &gt;&gt; } 424 + (Note: polemy REPL may warn some exception here but please ignore) 425 + 426 + For simplicity, I here deal only with integers. 427 + _isint is a primitive function of Polemy that checks the dynamic type of a value. 428 + For function, leaving it untouched works well for almost all layers. 429 + 430 + &gt;&gt; @type( 1 ) 431 + int 432 + &gt;&gt; @type( 2 ) 433 + int 434 + &gt;&gt; @type( "foo" ) 435 + unknown 436 + 437 + Fine! Let's try to type 1+2. 438 + 439 + &gt;&gt; @type( 1 + 2 ) 440 + ...\value.d(119): [<REPL>:6:8] only @value layer can call native function 441 + 442 + Note that the behavior of this program is 443 + - run 1+2 in the @type layer 444 + and NOT 445 + - run 1+2 in @value and obtain 3 and run 3 in the @type. 446 + The problem is, the variable "+" is defined only in the @value layer. 447 + To carry out computation in the @type layer. We need to define it also 448 + in the @type layer. 449 + 450 + To define some variable in a specific layer, use @LayerName in place of 451 + (let|var|def)s. 452 + 453 + &gt;&gt; let x = 2 454 + &gt;&gt; @value x = 2 455 + &gt;&gt; @type x = "int" 456 + &gt;&gt; @hoge x = "fuga" 457 + 458 + For "+", do it like this. 459 + 460 + &gt;&gt; @type "+" = fun(x,y) {@value( 461 + &gt;&gt; if( @type(x)=="int" &amp;&amp; @type(y)=="int" ) { "int" } else { "typeerror" } 462 + &gt;&gt; )} 463 + polemy.value.native!(IntValue,IntValue,IntValue).native.__anonclass24 464 + 465 + It is just computing the return type from the input type. 466 + Not here that the intended "meaning" of if-then-else is the runtime-branching, 467 + and the meaning of "==" is the value-comparison. These are the @value layer 468 + behavior. So we have defined the function body inside @value layer. 469 + But when we refer the variables x and y, we need its @type layer meaning. 470 + Hence we use @type() there. 471 + 472 + Now we get it. 473 + 474 + &gt;&gt; @type( 1 + 2 ) 475 + int 476 + 477 + Well, but do we have to define the @type layer meaning for every variables??? 478 + No. After you defined @type "+", you'll automatically get the following: 479 + 480 + &gt;&gt; def double(x) { x + x } 481 + (function:17e4740:1789720) 482 + 483 + &gt;&gt; @type( double(123) ) 484 + int 485 + 486 + Every user-defined functions are automatically "lift"ed to the appropriate layer. 487 + Only primitive functions like "+" requires @yourNewLayer annotation. 488 + 489 + 490 + 491 +[Layers :: neutral-layer] 492 + 493 + let|var|def is to define a variable in the "current" layer. 494 + Not necessary to the @value layer. 495 + 496 + &gt;&gt; @value( let x = 1 in @value(x) ) 497 + 1 498 + 499 + &gt;&gt; @macro( let x = 1 in @value(x) ) 500 + polemy.failure.RuntimeException: [<REPL>:14:29] variable x not found 501 + 502 + &gt;&gt; @macro( let x = 1 in @macro(x) ) 503 + {pos@value:{lineno@value:15, ... 504 + 505 + 506 + 507 +[Layers :: Layered-Parameters] 508 + 509 + &gt;&gt; def foo(x @macro @value) { {fst: x, snd: @macro(x)} } 510 + (function:1730360:1789720) 511 + 512 + If you annotate function parameters by @LayerNames, when you invoke the function... 513 + 514 + &gt;&gt; foo(1+2) 515 + {snd@value: {pos@value:{lineno@value:17, column@value:5, filename@value:<REPL>}, 516 + is@value:app, arg@value:{... 517 + /fst@value:3 518 + /} 519 + 520 + its corresponding arguments are evaluated in the layer and passed to it. 521 + If you specify multiple layers, the argument expression is run multiple times. 522 + If you do not specify any layer for a parameter, it works in the neutral layer. 523 +</pre> 524 +</dd> 525 + 526 + 527 + 528 +<script>explorer.outline.writeEnabled = true;</script> 529 +<dt><span class="decl"> 530 +<span class="currsymbol">Macro Layers</span> 531 +<script>explorer.outline.addDecl('Macro Layers');</script> 532 + 533 +</span></dt> 534 +<script>explorer.outline.writeEnabled = false;</script> 535 + 536 + <dd><p> 537 +Polemy 言語組み込みのレイヤは <code>@value</code> と <code>@macro</code> の二つです。 538 +(内部的にはもういくつかありますが、ユーザから直接は使えません。) 539 +<code>@value</code> は、「普通に」普通のセマンティクスでプログラムを実行するレイヤでした。 540 +<code>@macro</code> は、実は、<code>@value</code> よりも前に実行されるレイヤで、 541 +「プログラムを実行するとその構文木を返す」というセマンティクスで動きます。 542 +</p> 543 +<pre> 544 + (ここに例) 545 +</pre> 546 +<p> 547 +動きとしてはこうです。 548 +</p> 549 +<ol> 550 +<li>関数呼び出し時(とトップレベル環境の実行開始時)に、 551 + まず、<code>@macro</code> レイヤでコードを実行。</li> 552 +<li>返ってきた構文木を、<code>@value</code> レイヤ、 553 + またはその関数を呼び出したときのレイヤで実行。</li> 554 +</ol> 555 +<p> 556 +<code>@macro</code> レイヤも所詮ただのレイヤですので、 557 +上で説明した方法で <code>@macro</code> レイヤに関数などを登録しておくことで、 558 +構文木の生成をいじることが可能です。まさにマクロ。 559 +</p> 560 + 561 + 562 +<script>explorer.outline.incSymbolLevel();</script> 563 +<dl> 564 +<script>explorer.outline.writeEnabled = true;</script> 565 +<dt><span class="decl"> 566 +<span class="currsymbol">使い方</span> 567 +<script>explorer.outline.addDecl('使い方');</script> 568 + 569 +</span></dt> 570 +<script>explorer.outline.writeEnabled = false;</script> 571 + 572 + <dd><pre> 573 + When function is invoked, it first run in the @macro layer, and after that, 574 + it run in the neutral layer. Here is an example. 575 + 576 + &gt;&gt; @macro twice(x) { x; x } 577 + &gt;&gt; def f() { twice(print("Hello")); 999 } 578 + (function:173b6a0:1789720) 579 + &gt;&gt; f() 580 + Hello 581 + Hello 582 + 999 583 + 584 + When the interpreter evaluates f(), it first executes 585 + "twice(print("Hello")); 999" 586 + in the @macro layer. Basically what it does is to just construct its syntax tree. 587 + But, since we have defined the "twice" function in the @macro layer, it is 588 + execute as a function. Resulting syntax tree is 589 + "print("Hello"); print("Hello"); 999" 590 + and this is executed on the neutral (in this example, @value) layer. 591 + This is the reason why you see two "Hello"s. 592 + 593 + [[quote and unquote]] 594 + 595 + Here is more involved example of code genration. 596 + From "x", it generates "x*x*x*x*x*x*x*x*x*x". 597 + 598 + @macro pow10(x) { 599 + @value( 600 + def pow(x, n) { 601 + if( n == 1 ) { x } 602 + else { 603 + @macro( @value(x) * @value(pow(x,n-1)) ) 604 + } 605 + } 606 + in 607 + pow(@macro(x),10) 608 + ) 609 + }; 610 + 611 + Here, x is a syntax tree but n is an actual integer. If you read carefully, 612 + you should get what is going on. Basically, @macro can be considered like 613 + quasiquoting and @value to be an escape from it. 614 +</pre> 615 +</dd> 616 + 617 +<script>explorer.outline.writeEnabled = true;</script> 618 +<dt><span class="decl"> 619 +<span class="currsymbol">微妙な挙動</span> 620 +<script>explorer.outline.addDecl('微妙な挙動');</script> 621 + 622 +</span></dt> 623 +<script>explorer.outline.writeEnabled = false;</script> 624 + 625 + <dd><pre> 626 + (rawmacro) レイヤの話 627 + 628 + [[limitations]] 629 + 630 + This @macro layer is a very primitive one, and not a perfect macro language. 631 + Two major limitations are seen in the following "it" example. 632 + 633 + &gt;&gt; @macro LetItBe(x, y) { let it = x in y }; 634 + 635 + The variable name is not hygenic, and so without any effort, the syntax tree "y" 636 + can access the outer variable "it". 637 + 638 + &gt;&gt; def foo() { LetItBe( 1+2+3, it*it ) } 639 + &gt;&gt; foo() 640 + 36 641 + 642 + Of course, this is not just a limitation; it can sometimes allow us to write 643 + many interesting macros. 644 + 645 + The other problem is that the macro expansion is only done at function startup. 646 + So 647 + 648 + &gt;&gt; LetItBe( 1+2+3, it*it ) 649 + ...\value.d(173): [<REPL>:24:1] variable LetItBe is not set in layer @value 650 + 651 + you cannot directly use the macro in the same scope as the definition. 652 + You need to wrap it up in a function (like the foo() in the above example). 653 +</pre> 654 +</dd> 655 +</dl> 656 +<script>explorer.outline.decSymbolLevel();</script> 657 + 658 + 659 +</dd> 660 + 661 + 662 + 663 +<script>explorer.outline.writeEnabled = true;</script> 664 +<dt><span class="decl"> 665 +<span class="currsymbol">Built-in Primitives</span> 666 +<script>explorer.outline.addDecl('Built-in Primitives');</script> 667 + 668 +</span></dt> 669 +<script>explorer.outline.writeEnabled = false;</script> 670 + 671 + <dd><p> 672 +組み込み関数・変数の一覧。 673 +</p> 674 + 675 +<script>explorer.outline.incSymbolLevel();</script> 676 +<dl> 677 +<script>explorer.outline.writeEnabled = true;</script> 678 +<dt><span class="decl"> 679 +<span class="currsymbol">テーブル操作</span> 680 +<script>explorer.outline.addDecl('テーブル操作');</script> 681 + 682 +</span></dt> 683 +<script>explorer.outline.writeEnabled = false;</script> 684 + 685 + <dd> <table> <tr><th>{}</th> <td>()</td> <td>空のテーブルを作る</td></tr> 686 + <tr><th>.</th> <td>(t, s)</td> <td>テーブル t の名前 s のフィールドの値を取得。なければ <tt>undefined</tt></td></tr> 687 + <tr><th>.?</th> <td>(t, s)</td> <td>テーブル t に名前 s のフィールドがあれば 1、なければ 0</td></tr> 688 + <tr><th>.=</th> <td>(t, s, v)</td> <td>テーブル t を親に持ち、名前 s のフィールドに v が入ったテーブルを作る</td></tr> 689 + </table> 690 +</dd> 691 +<br /> 692 + 693 + 694 +<script>explorer.outline.writeEnabled = true;</script> 695 +<dt><span class="decl"> 696 +<span class="currsymbol">制御フロー</span> 697 +<script>explorer.outline.addDecl('制御フロー');</script> 698 + 699 +</span></dt> 700 +<script>explorer.outline.writeEnabled = false;</script> 701 + 702 + <dd> <table> <tr><th>if</th> <td>(n, ft, fe)</td> <td>n が非 0 なら <tt>ft()</t>、0 なら <tt>fe()</tt> を実行</td></tr> 703 + </table> 704 +</dd> 705 +<br /> 706 + 707 + 708 +<script>explorer.outline.writeEnabled = true;</script> 709 +<dt><span class="decl"> 710 +<span class="currsymbol">演算</span> 711 +<script>explorer.outline.addDecl('演算');</script> 712 + 713 +</span></dt> 714 +<script>explorer.outline.writeEnabled = false;</script> 715 + 716 + <dd> <table> <tr><th>+</th> <td>(n, m)</td> <td>整数 n と整数 m を足して返す</td></tr> 717 + <tr><th>-</th> <td>(n, m)</td> <td>整数の引き算</td></tr> 718 + <tr><th>*</th> <td>(n, m)</td> <td>整数の掛け算</td></tr> 719 + <tr><th>/</th> <td>(n, m)</td> <td>整数の割り算</td></tr> 720 + <tr><th>%</th> <td>(n, m)</td> <td>整数の剰余</td></tr> 721 + <tr><th>&amp;&amp;</th> <td>(n, m)</td> <td>整数 n と m が両方非 0 なら 1、それ以外では 0</td></tr> 722 + <tr><th>||</th> <td>(n, m)</td> <td>整数 n と m がどちらか非 0 なら 1、それ以外では 0</td></tr> 723 + <tr><th>~</th> <td>(a, b)</td> <td>a と b を文字列化して結合</td></tr> 724 + <tr><th>&lt;</th> <td>(a, b)</td> <td>a と b を比較</td></tr> 725 + <tr><th>&lt;=</th> <td>(a, b)</td> <td>a と b を比較</td></tr> 726 + <tr><th>&gt;</th> <td>(a, b)</td> <td>a と b を比較</td></tr> 727 + <tr><th>&gt;=</th> <td>(a, b)</td> <td>a と b を比較</td></tr> 728 + <tr><th>==</th> <td>(a, b)</td> <td>a と b を比較</td></tr> 729 + <tr><th>!=</th> <td>(a, b)</td> <td>a と b を比較</td></tr> 730 + </table> 731 +<p> 732 +注意点として、作者の趣味の問題で、<tt>&amp;&amp;</tt> と <tt>||</tt> は short-circuit 評価をしません。 733 +整数演算の種類が少ないのは、D 言語の std.bigint がビット演算などをサポートしてないためです。 734 +文字列が結合しかできないのは、単に手抜きです。 735 +</p> 736 +</dd> 737 + 738 + 739 +<script>explorer.outline.writeEnabled = true;</script> 740 +<dt><span class="decl"> 741 +<span class="currsymbol">外部とのやりとり</span> 742 +<script>explorer.outline.addDecl('外部とのやりとり');</script> 743 + 744 +</span></dt> 745 +<script>explorer.outline.writeEnabled = false;</script> 746 + 747 + <dd> <table> <tr><th>print</th> <td>(a)</td> <td>a を文字列化標準出力に改行付きで表示</td></tr> 748 + <tr><th>argv</th> <td></td> <td>スクリプトに渡された引数文字列のconsリスト</td></tr> 749 + </table> 750 +</dd> 751 +<br /> 752 + 753 + 754 +<script>explorer.outline.writeEnabled = true;</script> 755 +<dt><span class="decl"> 756 +<span class="currsymbol">データ型判定</span> 757 +<script>explorer.outline.addDecl('データ型判定');</script> 758 + 759 +</span></dt> 760 +<script>explorer.outline.writeEnabled = false;</script> 761 + 762 + <dd> <table> <tr><th>_isint</th> <td>(a)</td> <td>a が整数なら 1、でなければ 0</td></tr> 763 + <tr><th>_isstr</th> <td>(a)</td> <td>a が文字列なら 1、でなければ 0</td></tr> 764 + <tr><th>_isfun</th> <td>(a)</td> <td>a が関数なら 1、でなければ 0</td></tr> 765 + <tr><th>_istable</th> <td>(a)</td> <td>a がテーブルなら 1、でなければ 0</td></tr> 766 + <tr><th>_isundefined</th> <td>(a)</td> <td>a が未定義値なら 1、でなければ 0</td></tr> 767 + </table> 768 +</dd> 769 +</dl> 770 +<script>explorer.outline.decSymbolLevel();</script> 771 + 772 + 773 +</dd> 774 + 775 +</dl> 776 +<script>explorer.outline.decSymbolLevel();</script> 777 + 778 + 779 +</td></tr> 780 + <tr><td id="docfooter"> 781 + Page was generated with 782 + <img src="candydoc/img/candydoc.gif" style="vertical-align:middle; position:relative; top:-1px"> 783 + on Wed Nov 24 19:09:31 2010 784 + 785 + </td></tr> 786 + </table> 787 +</div> 788 +<script> 789 + explorer.packageExplorer.addModule("index"); 790 + explorer.packageExplorer.addModule("main"); 791 + explorer.packageExplorer.addModule("tricks.tricks"); 792 + explorer.packageExplorer.addModule("tricks.test"); 793 + explorer.packageExplorer.addModule("polemy._common"); 794 + explorer.packageExplorer.addModule("polemy.failure"); 795 + explorer.packageExplorer.addModule("polemy.layer"); 796 + explorer.packageExplorer.addModule("polemy.fresh"); 797 + explorer.packageExplorer.addModule("polemy.lex"); 798 + explorer.packageExplorer.addModule("polemy.parse"); 799 + explorer.packageExplorer.addModule("polemy.ast"); 800 + explorer.packageExplorer.addModule("polemy.value"); 801 + explorer.packageExplorer.addModule("polemy.valueconv"); 802 + explorer.packageExplorer.addModule("polemy.eval"); 803 + explorer.packageExplorer.addModule("polemy.runtime"); 804 + explorer.packageExplorer.addModule("polemy.repl");</script> 805 +</body></html> 806 + 807 +

Added doc/layer.html version [6466200d7c375c71]

1 + 2 +<html><head> 3 +<meta http-equiv="content-type" content="text/html; charset=utf-8"> 4 +<meta content="text/javascript" http-equiv="content-script-type"> 5 +<title>polemy.layer</title> 6 +<link rel="stylesheet" type="text/css" href="candydoc/style.css"> 7 +<!--[if lt IE 7]><link rel="stylesheet" type="text/css" href="candydoc/ie56hack.css"><![endif]--> 8 +<script language="JavaScript" src="candydoc/util.js" type="text/javascript"></script> 9 +<script language="JavaScript" src="candydoc/tree.js" type="text/javascript"></script> 10 +<script language="JavaScript" src="candydoc/explorer.js" type="text/javascript"></script> 11 +</head><body> 12 +<div id="tabarea"></div><div id="explorerclient"></div> 13 +<div id="content"><script>explorer.initialize("polemy.layer");</script> 14 + <table class="content"> 15 + <tr><td id="docbody"><h1>polemy.layer</h1><!-- Generated by Ddoc from polemy\layer.d --> 16 +<b>Authors:</b><br> 17 +k.inaba 18 +<br><br> 19 +<b>License:</b><br> 20 +NYSL 0.9982 http://www.kmonos.net/nysl/ 21 +<br><br> 22 + 23 + Definition of constants related to the layers.<br><br> 24 + 25 + 26 +<script>explorer.outline.incSymbolLevel();</script> 27 +<dl> 28 +<script>explorer.outline.writeEnabled = true;</script> 29 +<dt><span class="decl">alias 30 +<span class="currsymbol">Layer</span> 31 +<script>explorer.outline.addDecl('Layer');</script> 32 + 33 +; 34 +</span></dt> 35 +<script>explorer.outline.writeEnabled = false;</script> 36 + 37 + 38 +<dd>Type for the layer ID<br><br> 39 + 40 +</dd> 41 + 42 +<script>explorer.outline.writeEnabled = true;</script> 43 +<dt><span class="decl"> 44 +<span class="currsymbol">SystemLayer</span> 45 +<script>explorer.outline.addDecl('SystemLayer');</script> 46 + 47 +</span></dt> 48 +<script>explorer.outline.writeEnabled = false;</script> 49 + 50 + 51 +<dd>Predefined layer for internal data<br><br> 52 + 53 +</dd> 54 + 55 +<script>explorer.outline.writeEnabled = true;</script> 56 +<dt><span class="decl"> 57 +<span class="currsymbol">ValueLayer</span> 58 +<script>explorer.outline.addDecl('ValueLayer');</script> 59 + 60 +</span></dt> 61 +<script>explorer.outline.writeEnabled = false;</script> 62 + 63 + 64 +<dd>Predefined layer for normal run<br><br> 65 + 66 +</dd> 67 + 68 +<script>explorer.outline.writeEnabled = true;</script> 69 +<dt><span class="decl"> 70 +<span class="currsymbol">MacroLayer</span> 71 +<script>explorer.outline.addDecl('MacroLayer');</script> 72 + 73 +</span></dt> 74 +<script>explorer.outline.writeEnabled = false;</script> 75 + 76 + 77 +<dd>Predefined layer for macro run (@lay() changes layer)<br><br> 78 + 79 +</dd> 80 + 81 +<script>explorer.outline.writeEnabled = true;</script> 82 +<dt><span class="decl"> 83 +<span class="currsymbol">RawMacroLayer</span> 84 +<script>explorer.outline.addDecl('RawMacroLayer');</script> 85 + 86 +</span></dt> 87 +<script>explorer.outline.writeEnabled = false;</script> 88 + 89 + 90 +<dd>Predefined layer for macro run (@lay() becomes AST)<br><br> 91 + 92 +</dd> 93 + 94 +<script>explorer.outline.writeEnabled = true;</script> 95 +<dt><span class="decl"> 96 +<span class="currsymbol">AstLayer</span> 97 +<script>explorer.outline.addDecl('AstLayer');</script> 98 + 99 +</span></dt> 100 +<script>explorer.outline.writeEnabled = false;</script> 101 + 102 + 103 +<dd>Predefined layer for macro run (never invoke macro)<br><br> 104 + 105 +</dd> 106 + 107 +<script>explorer.outline.writeEnabled = true;</script> 108 +<dt><span class="decl">bool 109 +<span class="currsymbol">isASTLayer</span> 110 +<script>explorer.outline.addDecl('isASTLayer');</script> 111 + 112 +(Layer <span class="funcparam">lay</span>); 113 +</span></dt> 114 +<script>explorer.outline.writeEnabled = false;</script> 115 + 116 + 117 +<dd>True if it is macro-like layer that basically generates syntax tree<br><br> 118 + 119 +</dd> 120 + 121 +<script>explorer.outline.writeEnabled = true;</script> 122 +<dt><span class="decl">bool 123 +<span class="currsymbol">isNoLayerChangeLayer</span> 124 +<script>explorer.outline.addDecl('isNoLayerChangeLayer');</script> 125 + 126 +(Layer <span class="funcparam">lay</span>); 127 +</span></dt> 128 +<script>explorer.outline.writeEnabled = false;</script> 129 + 130 + 131 +<dd>True if in the specified layer @<span class="funcparam">lay</span>(...) has no effect and merely produces a syntax tree<br><br> 132 + 133 +</dd> 134 + 135 +<script>explorer.outline.writeEnabled = true;</script> 136 +<dt><span class="decl">bool 137 +<span class="currsymbol">isMacroLayer</span> 138 +<script>explorer.outline.addDecl('isMacroLayer');</script> 139 + 140 +(Layer <span class="funcparam">lay</span>); 141 +</span></dt> 142 +<script>explorer.outline.writeEnabled = false;</script> 143 + 144 + 145 +<dd>True if do macro expanstion<br><br> 146 + 147 +</dd> 148 +</dl> 149 +<script>explorer.outline.decSymbolLevel();</script> 150 + 151 + 152 +</td></tr> 153 + <tr><td id="docfooter"> 154 + Page was generated with 155 + <img src="candydoc/img/candydoc.gif" style="vertical-align:middle; position:relative; top:-1px"> 156 + on Wed Nov 24 19:09:32 2010 157 + 158 + </td></tr> 159 + </table> 160 +</div> 161 +<script> 162 + explorer.packageExplorer.addModule("index"); 163 + explorer.packageExplorer.addModule("main"); 164 + explorer.packageExplorer.addModule("tricks.tricks"); 165 + explorer.packageExplorer.addModule("tricks.test"); 166 + explorer.packageExplorer.addModule("polemy._common"); 167 + explorer.packageExplorer.addModule("polemy.failure"); 168 + explorer.packageExplorer.addModule("polemy.layer"); 169 + explorer.packageExplorer.addModule("polemy.fresh"); 170 + explorer.packageExplorer.addModule("polemy.lex"); 171 + explorer.packageExplorer.addModule("polemy.parse"); 172 + explorer.packageExplorer.addModule("polemy.ast"); 173 + explorer.packageExplorer.addModule("polemy.value"); 174 + explorer.packageExplorer.addModule("polemy.valueconv"); 175 + explorer.packageExplorer.addModule("polemy.eval"); 176 + explorer.packageExplorer.addModule("polemy.runtime"); 177 + explorer.packageExplorer.addModule("polemy.repl");</script> 178 +</body></html> 179 + 180 +

Added doc/lex.html version [d95037ff9be23025]

1 + 2 +<html><head> 3 +<meta http-equiv="content-type" content="text/html; charset=utf-8"> 4 +<meta content="text/javascript" http-equiv="content-script-type"> 5 +<title>polemy.lex</title> 6 +<link rel="stylesheet" type="text/css" href="candydoc/style.css"> 7 +<!--[if lt IE 7]><link rel="stylesheet" type="text/css" href="candydoc/ie56hack.css"><![endif]--> 8 +<script language="JavaScript" src="candydoc/util.js" type="text/javascript"></script> 9 +<script language="JavaScript" src="candydoc/tree.js" type="text/javascript"></script> 10 +<script language="JavaScript" src="candydoc/explorer.js" type="text/javascript"></script> 11 +</head><body> 12 +<div id="tabarea"></div><div id="explorerclient"></div> 13 +<div id="content"><script>explorer.initialize("polemy.lex");</script> 14 + <table class="content"> 15 + <tr><td id="docbody"><h1>polemy.lex</h1><!-- Generated by Ddoc from polemy\lex.d --> 16 +<b>Authors:</b><br> 17 +k.inaba 18 +<br><br> 19 +<b>License:</b><br> 20 +NYSL 0.9982 http://www.kmonos.net/nysl/ 21 +<br><br> 22 + 23 + Lexer for Polemy programming language.<br><br> 24 + 25 + 26 +<script>explorer.outline.incSymbolLevel();</script> 27 +<dl> 28 +<script>explorer.outline.writeEnabled = true;</script> 29 +<dt><span class="decl">class 30 +<span class="currsymbol">Token</span> 31 +<script>explorer.outline.addDecl('Token');</script> 32 + 33 +; 34 +</span></dt> 35 +<script>explorer.outline.writeEnabled = false;</script> 36 + 37 + 38 +<dd>Represents a lexer token<br><br> 39 + 40 + 41 +<script>explorer.outline.incSymbolLevel();</script> 42 +<dl> 43 +<script>explorer.outline.writeEnabled = true;</script> 44 +<dt><span class="decl">immutable LexPosition 45 +<span class="currsymbol">pos</span> 46 +<script>explorer.outline.addDecl('pos');</script> 47 + 48 +; 49 +</span></dt> 50 +<script>explorer.outline.writeEnabled = false;</script> 51 + 52 + 53 +<dd>Position where the token occurred in the source<br><br> 54 + 55 +</dd> 56 + 57 +<script>explorer.outline.writeEnabled = true;</script> 58 +<dt><span class="decl">immutable string 59 +<span class="currsymbol">str</span> 60 +<script>explorer.outline.addDecl('str');</script> 61 + 62 +; 63 +</span></dt> 64 +<script>explorer.outline.writeEnabled = false;</script> 65 + 66 + 67 +<dd>The token string itself<br><br> 68 + 69 +</dd> 70 + 71 +<script>explorer.outline.writeEnabled = true;</script> 72 +<dt><span class="decl">immutable bool 73 +<span class="currsymbol">quoted</span> 74 +<script>explorer.outline.addDecl('quoted');</script> 75 + 76 +; 77 +</span></dt> 78 +<script>explorer.outline.writeEnabled = false;</script> 79 + 80 + 81 +<dd>Was it a " 82 +<span class="currsymbol">quoted</span> 83 +<script>explorer.outline.addDecl('quoted');</script> 84 + 85 +" token or unquoted?<br><br> 86 + 87 +</dd> 88 +</dl> 89 +<script>explorer.outline.decSymbolLevel();</script> 90 + 91 + 92 +</dd> 93 + 94 +<script>explorer.outline.writeEnabled = true;</script> 95 +<dt><span class="decl">Lexer 96 +<span class="currsymbol">lexerFromFile</span> 97 +<script>explorer.outline.addDecl('lexerFromFile');</script> 98 + 99 +(T...)(string <span class="funcparam">filename</span>, T <span class="funcparam">ln_cn</span>); 100 +</span></dt> 101 +<script>explorer.outline.writeEnabled = false;</script> 102 + 103 + 104 +<dd>Named Construtors for Lexer<br><br> 105 + 106 +</dd> 107 + 108 +<script>explorer.outline.writeEnabled = true;</script> 109 +<dt><span class="decl">LexerT!(PositionedReader!(CharSeq)) 110 +<span class="currsymbol">lexerFromString</span> 111 +<script>explorer.outline.addDecl('lexerFromString');</script> 112 + 113 +(CharSeq)(CharSeq <span class="funcparam">str</span>, string <span class="funcparam">filename</span> = "&lt;unnamed&gt;", int <span class="funcparam">lineno</span> = 1, int <span class="funcparam">column</span> = 1); 114 +</span></dt> 115 +<script>explorer.outline.writeEnabled = false;</script> 116 + 117 + 118 +<dd>Named Construtor for Lexer<br><br> 119 + 120 +</dd> 121 + 122 +<script>explorer.outline.writeEnabled = true;</script> 123 +<dt><span class="decl">alias 124 +<span class="currsymbol">Lexer</span> 125 +<script>explorer.outline.addDecl('Lexer');</script> 126 + 127 +; 128 +</span></dt> 129 +<script>explorer.outline.writeEnabled = false;</script> 130 + 131 + 132 +<dd>Standard 133 +<span class="currsymbol">Lexer</span> 134 +<script>explorer.outline.addDecl('Lexer');</script> 135 + 136 + Type (all you have to know is that this is a forward range of Tokens!)<br><br> 137 + 138 +</dd> 139 + 140 +<script>explorer.outline.writeEnabled = true;</script> 141 +<dt><span class="decl">class 142 +<span class="currsymbol">LexerT</span> 143 +<script>explorer.outline.addDecl('LexerT');</script> 144 + 145 +(Reader) if (isForwardRange!(Reader) &amp;&amp; is(ElementType!(Reader) == dchar)); 146 +</span></dt> 147 +<script>explorer.outline.writeEnabled = false;</script> 148 + 149 + 150 +<dd>Lexer Implementation<br><br> 151 + 152 + 153 +<script>explorer.outline.incSymbolLevel();</script> 154 +<dl> 155 +<script>explorer.outline.writeEnabled = true;</script> 156 +<dt><span class="decl">bool 157 +<span class="currsymbol">empty</span> 158 +<script>explorer.outline.addDecl('empty');</script> 159 + 160 +(); 161 +</span></dt> 162 +<script>explorer.outline.writeEnabled = false;</script> 163 + 164 + 165 +<dd>Range primitive<br><br> 166 + 167 +</dd> 168 + 169 +<script>explorer.outline.writeEnabled = true;</script> 170 +<dt><span class="decl">Token 171 +<span class="currsymbol">front</span> 172 +<script>explorer.outline.addDecl('front');</script> 173 + 174 +(); 175 +</span></dt> 176 +<script>explorer.outline.writeEnabled = false;</script> 177 + 178 + 179 +<dd>Range primitive<br><br> 180 + 181 +</dd> 182 + 183 +<script>explorer.outline.writeEnabled = true;</script> 184 +<dt><span class="decl">void 185 +<span class="currsymbol">popFront</span> 186 +<script>explorer.outline.addDecl('popFront');</script> 187 + 188 +(); 189 +</span></dt> 190 +<script>explorer.outline.writeEnabled = false;</script> 191 + 192 + 193 +<dd>Range primitive<br><br> 194 + 195 +</dd> 196 + 197 +<script>explorer.outline.writeEnabled = true;</script> 198 +<dt><span class="decl">typeof(this) 199 +<span class="currsymbol">save</span> 200 +<script>explorer.outline.addDecl('save');</script> 201 + 202 +(); 203 +</span></dt> 204 +<script>explorer.outline.writeEnabled = false;</script> 205 + 206 + 207 +<dd>Range primitive<br><br> 208 + 209 +</dd> 210 +</dl> 211 +<script>explorer.outline.decSymbolLevel();</script> 212 + 213 + 214 +</dd> 215 + 216 +<script>explorer.outline.writeEnabled = true;</script> 217 +<dt><span class="decl">struct 218 +<span class="currsymbol">PositionedReader</span> 219 +<script>explorer.outline.addDecl('PositionedReader');</script> 220 + 221 +(CharSeq) if (isForwardRange!(CharSeq) &amp;&amp; is(ElementType!(CharSeq) == dchar)); 222 +</span></dt> 223 +<script>explorer.outline.writeEnabled = false;</script> 224 + 225 + 226 +<dd>Forward range for reader character by character, 227 + keeping track of position information and caring \r\n -&gt; \n conversion.<br><br> 228 + 229 + 230 +<script>explorer.outline.incSymbolLevel();</script> 231 +<dl> 232 +<script>explorer.outline.writeEnabled = true;</script> 233 +<dt><span class="decl">bool 234 +<span class="currsymbol">empty</span> 235 +<script>explorer.outline.addDecl('empty');</script> 236 + 237 +(); 238 +</span></dt> 239 +<script>explorer.outline.writeEnabled = false;</script> 240 + 241 + 242 +<dd>Range primitive<br><br> 243 + 244 +</dd> 245 + 246 +<script>explorer.outline.writeEnabled = true;</script> 247 +<dt><span class="decl">dchar 248 +<span class="currsymbol">front</span> 249 +<script>explorer.outline.addDecl('front');</script> 250 + 251 +(); 252 +</span></dt> 253 +<script>explorer.outline.writeEnabled = false;</script> 254 + 255 + 256 +<dd>Range primitive<br><br> 257 + 258 +</dd> 259 + 260 +<script>explorer.outline.writeEnabled = true;</script> 261 +<dt><span class="decl">void 262 +<span class="currsymbol">popFront</span> 263 +<script>explorer.outline.addDecl('popFront');</script> 264 + 265 +(); 266 +</span></dt> 267 +<script>explorer.outline.writeEnabled = false;</script> 268 + 269 + 270 +<dd>Range primitive<br><br> 271 + 272 +</dd> 273 + 274 +<script>explorer.outline.writeEnabled = true;</script> 275 +<dt><span class="decl">typeof(this) 276 +<span class="currsymbol">save</span> 277 +<script>explorer.outline.addDecl('save');</script> 278 + 279 +(); 280 +</span></dt> 281 +<script>explorer.outline.writeEnabled = false;</script> 282 + 283 + 284 +<dd>Range primitive<br><br> 285 + 286 +</dd> 287 + 288 +<script>explorer.outline.writeEnabled = true;</script> 289 +<dt><span class="decl">const LexPosition 290 +<span class="currsymbol">currentPosition</span> 291 +<script>explorer.outline.addDecl('currentPosition');</script> 292 + 293 +(); 294 +</span></dt> 295 +<script>explorer.outline.writeEnabled = false;</script> 296 + 297 + 298 +<dd>Get the current position<br><br> 299 + 300 +</dd> 301 +</dl> 302 +<script>explorer.outline.decSymbolLevel();</script> 303 + 304 + 305 +</dd> 306 +</dl> 307 +<script>explorer.outline.decSymbolLevel();</script> 308 + 309 + 310 +</td></tr> 311 + <tr><td id="docfooter"> 312 + Page was generated with 313 + <img src="candydoc/img/candydoc.gif" style="vertical-align:middle; position:relative; top:-1px"> 314 + on Wed Nov 24 19:09:32 2010 315 + 316 + </td></tr> 317 + </table> 318 +</div> 319 +<script> 320 + explorer.packageExplorer.addModule("index"); 321 + explorer.packageExplorer.addModule("main"); 322 + explorer.packageExplorer.addModule("tricks.tricks"); 323 + explorer.packageExplorer.addModule("tricks.test"); 324 + explorer.packageExplorer.addModule("polemy._common"); 325 + explorer.packageExplorer.addModule("polemy.failure"); 326 + explorer.packageExplorer.addModule("polemy.layer"); 327 + explorer.packageExplorer.addModule("polemy.fresh"); 328 + explorer.packageExplorer.addModule("polemy.lex"); 329 + explorer.packageExplorer.addModule("polemy.parse"); 330 + explorer.packageExplorer.addModule("polemy.ast"); 331 + explorer.packageExplorer.addModule("polemy.value"); 332 + explorer.packageExplorer.addModule("polemy.valueconv"); 333 + explorer.packageExplorer.addModule("polemy.eval"); 334 + explorer.packageExplorer.addModule("polemy.runtime"); 335 + explorer.packageExplorer.addModule("polemy.repl");</script> 336 +</body></html> 337 + 338 +

Added doc/main.html version [d4c8f156867b63c7]

1 + 2 +<html><head> 3 +<meta http-equiv="content-type" content="text/html; charset=utf-8"> 4 +<meta content="text/javascript" http-equiv="content-script-type"> 5 +<title>main</title> 6 +<link rel="stylesheet" type="text/css" href="candydoc/style.css"> 7 +<!--[if lt IE 7]><link rel="stylesheet" type="text/css" href="candydoc/ie56hack.css"><![endif]--> 8 +<script language="JavaScript" src="candydoc/util.js" type="text/javascript"></script> 9 +<script language="JavaScript" src="candydoc/tree.js" type="text/javascript"></script> 10 +<script language="JavaScript" src="candydoc/explorer.js" type="text/javascript"></script> 11 +</head><body> 12 +<div id="tabarea"></div><div id="explorerclient"></div> 13 +<div id="content"><script>explorer.initialize("main");</script> 14 + <table class="content"> 15 + <tr><td id="docbody"><h1>main</h1><!-- Generated by Ddoc from main.d --> 16 +<b>Authors:</b><br> 17 +k.inaba 18 +<br><br> 19 +<b>License:</b><br> 20 +NYSL 0.9982 (http://www.kmonos.net/nysl/) 21 +<br><br> 22 + 23 + Entry point for Polemy interpreter.<br><br> 24 + 25 + 26 +<script>explorer.outline.incSymbolLevel();</script> 27 +<dl> 28 +<script>explorer.outline.writeEnabled = true;</script> 29 +<dt><span class="decl">string 30 +<span class="currsymbol">parseArgv</span> 31 +<script>explorer.outline.addDecl('parseArgv');</script> 32 + 33 +(ref string[] <span class="funcparam">args</span>, out string[] <span class="funcparam">libs</span>); 34 +</span></dt> 35 +<script>explorer.outline.writeEnabled = false;</script> 36 + 37 + 38 +<dd>Advance <span class="funcparam">args</span>[] to point the argument list fed to the script. 39 + Returns the name of the source file to run, or returns "" if 40 + no filename was given. Also, returns to <span class="funcparam">libs</span>[] the list of 41 + library source to load. 42 +<br><br> 43 +<b>TODO:</b><br> 44 +use std.getopt<br><br> 45 + 46 +</dd> 47 + 48 +<script>explorer.outline.writeEnabled = true;</script> 49 +<dt><span class="decl">void 50 +<span class="currsymbol">main</span> 51 +<script>explorer.outline.addDecl('main');</script> 52 + 53 +(string[] <span class="funcparam">args</span>); 54 +</span></dt> 55 +<script>explorer.outline.writeEnabled = false;</script> 56 + 57 + 58 +<dd>Entry point.<br><br> 59 + 60 +</dd> 61 +</dl> 62 +<script>explorer.outline.decSymbolLevel();</script> 63 + 64 + 65 +</td></tr> 66 + <tr><td id="docfooter"> 67 + Page was generated with 68 + <img src="candydoc/img/candydoc.gif" style="vertical-align:middle; position:relative; top:-1px"> 69 + on Wed Nov 24 19:09:32 2010 70 + 71 + </td></tr> 72 + </table> 73 +</div> 74 +<script> 75 + explorer.packageExplorer.addModule("index"); 76 + explorer.packageExplorer.addModule("main"); 77 + explorer.packageExplorer.addModule("tricks.tricks"); 78 + explorer.packageExplorer.addModule("tricks.test"); 79 + explorer.packageExplorer.addModule("polemy._common"); 80 + explorer.packageExplorer.addModule("polemy.failure"); 81 + explorer.packageExplorer.addModule("polemy.layer"); 82 + explorer.packageExplorer.addModule("polemy.fresh"); 83 + explorer.packageExplorer.addModule("polemy.lex"); 84 + explorer.packageExplorer.addModule("polemy.parse"); 85 + explorer.packageExplorer.addModule("polemy.ast"); 86 + explorer.packageExplorer.addModule("polemy.value"); 87 + explorer.packageExplorer.addModule("polemy.valueconv"); 88 + explorer.packageExplorer.addModule("polemy.eval"); 89 + explorer.packageExplorer.addModule("polemy.runtime"); 90 + explorer.packageExplorer.addModule("polemy.repl");</script> 91 +</body></html> 92 + 93 +

Added doc/parse.html version [6f4d8d046b442e49]

1 + 2 +<html><head> 3 +<meta http-equiv="content-type" content="text/html; charset=utf-8"> 4 +<meta content="text/javascript" http-equiv="content-script-type"> 5 +<title>polemy.parse</title> 6 +<link rel="stylesheet" type="text/css" href="candydoc/style.css"> 7 +<!--[if lt IE 7]><link rel="stylesheet" type="text/css" href="candydoc/ie56hack.css"><![endif]--> 8 +<script language="JavaScript" src="candydoc/util.js" type="text/javascript"></script> 9 +<script language="JavaScript" src="candydoc/tree.js" type="text/javascript"></script> 10 +<script language="JavaScript" src="candydoc/explorer.js" type="text/javascript"></script> 11 +</head><body> 12 +<div id="tabarea"></div><div id="explorerclient"></div> 13 +<div id="content"><script>explorer.initialize("polemy.parse");</script> 14 + <table class="content"> 15 + <tr><td id="docbody"><h1>polemy.parse</h1><!-- Generated by Ddoc from polemy\parse.d --> 16 +<b>Authors:</b><br> 17 +k.inaba 18 +<br><br> 19 +<b>License:</b><br> 20 +NYSL 0.9982 http://www.kmonos.net/nysl/ 21 +<br><br> 22 + 23 + Parser for Polemy programming language<br><br> 24 + 25 + 26 +<script>explorer.outline.incSymbolLevel();</script> 27 +<dl> 28 +<script>explorer.outline.writeEnabled = true;</script> 29 +<dt><span class="decl">AST 30 +<span class="currsymbol">parseString</span> 31 +<script>explorer.outline.addDecl('parseString');</script> 32 + 33 +(S, T...)(S <span class="funcparam">str</span>, T <span class="funcparam">fn_ln_cn</span>); 34 +</span></dt> 35 +<script>explorer.outline.writeEnabled = false;</script> 36 + 37 + 38 +<dd>Parse a string and return its AST<br><br> 39 + 40 +</dd> 41 + 42 +<script>explorer.outline.writeEnabled = true;</script> 43 +<dt><span class="decl">AST 44 +<span class="currsymbol">parseFile</span> 45 +<script>explorer.outline.addDecl('parseFile');</script> 46 + 47 +(S, T...)(S <span class="funcparam">filename</span>, T <span class="funcparam">ln_cn</span>); 48 +</span></dt> 49 +<script>explorer.outline.writeEnabled = false;</script> 50 + 51 + 52 +<dd>Parse the content of a file and return its AST<br><br> 53 + 54 +</dd> 55 +</dl> 56 +<script>explorer.outline.decSymbolLevel();</script> 57 + 58 + 59 +</td></tr> 60 + <tr><td id="docfooter"> 61 + Page was generated with 62 + <img src="candydoc/img/candydoc.gif" style="vertical-align:middle; position:relative; top:-1px"> 63 + on Wed Nov 24 19:09:32 2010 64 + 65 + </td></tr> 66 + </table> 67 +</div> 68 +<script> 69 + explorer.packageExplorer.addModule("index"); 70 + explorer.packageExplorer.addModule("main"); 71 + explorer.packageExplorer.addModule("tricks.tricks"); 72 + explorer.packageExplorer.addModule("tricks.test"); 73 + explorer.packageExplorer.addModule("polemy._common"); 74 + explorer.packageExplorer.addModule("polemy.failure"); 75 + explorer.packageExplorer.addModule("polemy.layer"); 76 + explorer.packageExplorer.addModule("polemy.fresh"); 77 + explorer.packageExplorer.addModule("polemy.lex"); 78 + explorer.packageExplorer.addModule("polemy.parse"); 79 + explorer.packageExplorer.addModule("polemy.ast"); 80 + explorer.packageExplorer.addModule("polemy.value"); 81 + explorer.packageExplorer.addModule("polemy.valueconv"); 82 + explorer.packageExplorer.addModule("polemy.eval"); 83 + explorer.packageExplorer.addModule("polemy.runtime"); 84 + explorer.packageExplorer.addModule("polemy.repl");</script> 85 +</body></html> 86 + 87 +

Added doc/repl.html version [a4f8734ecfa16cea]

1 + 2 +<html><head> 3 +<meta http-equiv="content-type" content="text/html; charset=utf-8"> 4 +<meta content="text/javascript" http-equiv="content-script-type"> 5 +<title>polemy.repl</title> 6 +<link rel="stylesheet" type="text/css" href="candydoc/style.css"> 7 +<!--[if lt IE 7]><link rel="stylesheet" type="text/css" href="candydoc/ie56hack.css"><![endif]--> 8 +<script language="JavaScript" src="candydoc/util.js" type="text/javascript"></script> 9 +<script language="JavaScript" src="candydoc/tree.js" type="text/javascript"></script> 10 +<script language="JavaScript" src="candydoc/explorer.js" type="text/javascript"></script> 11 +</head><body> 12 +<div id="tabarea"></div><div id="explorerclient"></div> 13 +<div id="content"><script>explorer.initialize("polemy.repl");</script> 14 + <table class="content"> 15 + <tr><td id="docbody"><h1>polemy.repl</h1><!-- Generated by Ddoc from polemy\repl.d --> 16 +<b>Authors:</b><br> 17 +k.inaba 18 +<br><br> 19 +<b>License:</b><br> 20 +NYSL 0.9982 (http://www.kmonos.net/nysl/) 21 +<br><br> 22 + 23 + Read-Eval-Print-Loop<br><br> 24 + 25 + 26 +<script>explorer.outline.incSymbolLevel();</script> 27 +<dl> 28 +<script>explorer.outline.writeEnabled = true;</script> 29 +<dt><span class="decl">int 30 +<span class="currsymbol">VersionNoMajor</span> 31 +<script>explorer.outline.addDecl('VersionNoMajor');</script> 32 + 33 +; 34 +</span></dt> 35 +<script>explorer.outline.writeEnabled = false;</script> 36 + 37 + 38 +<dd>Version Number<br><br> 39 + 40 +</dd> 41 + 42 +<script>explorer.outline.writeEnabled = true;</script> 43 +<dt><span class="decl">int 44 +<span class="currsymbol">VersionNoMinor</span> 45 +<script>explorer.outline.addDecl('VersionNoMinor');</script> 46 + 47 +; 48 +</span></dt> 49 +<script>explorer.outline.writeEnabled = false;</script> 50 + 51 + 52 +<dd>Version Number<br><br> 53 + 54 +</dd> 55 + 56 +<script>explorer.outline.writeEnabled = true;</script> 57 +<dt><span class="decl">int 58 +<span class="currsymbol">VersionNoRev</span> 59 +<script>explorer.outline.addDecl('VersionNoRev');</script> 60 + 61 +; 62 +</span></dt> 63 +<script>explorer.outline.writeEnabled = false;</script> 64 + 65 + 66 +<dd>Version Number<br><br> 67 + 68 +</dd> 69 + 70 +<script>explorer.outline.writeEnabled = true;</script> 71 +<dt><span class="decl">class 72 +<span class="currsymbol">REPL</span> 73 +<script>explorer.outline.addDecl('REPL');</script> 74 + 75 +; 76 +</span></dt> 77 +<script>explorer.outline.writeEnabled = false;</script> 78 + 79 + 80 +<dd>Read-Eval-Print-Loop<br><br> 81 + 82 + 83 +<script>explorer.outline.incSymbolLevel();</script> 84 +<dl> 85 +<script>explorer.outline.writeEnabled = true;</script> 86 +<dt><span class="decl">this(string[] <span class="funcparam">args</span>); 87 +</span></dt> 88 +<script>explorer.outline.writeEnabled = false;</script> 89 + 90 + 91 +<dd>Load the prelude environment<br><br> 92 + 93 +</dd> 94 + 95 +<script>explorer.outline.writeEnabled = true;</script> 96 +<dt><span class="decl">void 97 +<span class="currsymbol">greet</span> 98 +<script>explorer.outline.addDecl('greet');</script> 99 + 100 +(); 101 +</span></dt> 102 +<script>explorer.outline.writeEnabled = false;</script> 103 + 104 + 105 +<dd>Print the version number etc.<br><br> 106 + 107 +</dd> 108 + 109 +<script>explorer.outline.writeEnabled = true;</script> 110 +<dt><span class="decl">void 111 +<span class="currsymbol">runFile</span> 112 +<script>explorer.outline.addDecl('runFile');</script> 113 + 114 +(string <span class="funcparam">filename</span>); 115 +</span></dt> 116 +<script>explorer.outline.writeEnabled = false;</script> 117 + 118 + 119 +<dd>Run one file on the global scope<br><br> 120 + 121 +</dd> 122 + 123 +<script>explorer.outline.writeEnabled = true;</script> 124 +<dt><span class="decl">void 125 +<span class="currsymbol">replLoop</span> 126 +<script>explorer.outline.addDecl('replLoop');</script> 127 + 128 +(); 129 +</span></dt> 130 +<script>explorer.outline.writeEnabled = false;</script> 131 + 132 + 133 +<dd>Repeat the singleInteraction<br><br> 134 + 135 +</dd> 136 + 137 +<script>explorer.outline.writeEnabled = true;</script> 138 +<dt><span class="decl">bool 139 +<span class="currsymbol">singleInteraction</span> 140 +<script>explorer.outline.addDecl('singleInteraction');</script> 141 + 142 +(); 143 +</span></dt> 144 +<script>explorer.outline.writeEnabled = false;</script> 145 + 146 + 147 +<dd>Read one line from stdin, and do some reaction<br><br> 148 + 149 +</dd> 150 +</dl> 151 +<script>explorer.outline.decSymbolLevel();</script> 152 + 153 + 154 +</dd> 155 +</dl> 156 +<script>explorer.outline.decSymbolLevel();</script> 157 + 158 + 159 +</td></tr> 160 + <tr><td id="docfooter"> 161 + Page was generated with 162 + <img src="candydoc/img/candydoc.gif" style="vertical-align:middle; position:relative; top:-1px"> 163 + on Wed Nov 24 19:09:32 2010 164 + 165 + </td></tr> 166 + </table> 167 +</div> 168 +<script> 169 + explorer.packageExplorer.addModule("index"); 170 + explorer.packageExplorer.addModule("main"); 171 + explorer.packageExplorer.addModule("tricks.tricks"); 172 + explorer.packageExplorer.addModule("tricks.test"); 173 + explorer.packageExplorer.addModule("polemy._common"); 174 + explorer.packageExplorer.addModule("polemy.failure"); 175 + explorer.packageExplorer.addModule("polemy.layer"); 176 + explorer.packageExplorer.addModule("polemy.fresh"); 177 + explorer.packageExplorer.addModule("polemy.lex"); 178 + explorer.packageExplorer.addModule("polemy.parse"); 179 + explorer.packageExplorer.addModule("polemy.ast"); 180 + explorer.packageExplorer.addModule("polemy.value"); 181 + explorer.packageExplorer.addModule("polemy.valueconv"); 182 + explorer.packageExplorer.addModule("polemy.eval"); 183 + explorer.packageExplorer.addModule("polemy.runtime"); 184 + explorer.packageExplorer.addModule("polemy.repl");</script> 185 +</body></html> 186 + 187 +

Added doc/runtime.html version [c37f8cec8f6ca249]

1 + 2 +<html><head> 3 +<meta http-equiv="content-type" content="text/html; charset=utf-8"> 4 +<meta content="text/javascript" http-equiv="content-script-type"> 5 +<title>polemy.runtime</title> 6 +<link rel="stylesheet" type="text/css" href="candydoc/style.css"> 7 +<!--[if lt IE 7]><link rel="stylesheet" type="text/css" href="candydoc/ie56hack.css"><![endif]--> 8 +<script language="JavaScript" src="candydoc/util.js" type="text/javascript"></script> 9 +<script language="JavaScript" src="candydoc/tree.js" type="text/javascript"></script> 10 +<script language="JavaScript" src="candydoc/explorer.js" type="text/javascript"></script> 11 +</head><body> 12 +<div id="tabarea"></div><div id="explorerclient"></div> 13 +<div id="content"><script>explorer.initialize("polemy.runtime");</script> 14 + <table class="content"> 15 + <tr><td id="docbody"><h1>polemy.runtime</h1><!-- Generated by Ddoc from polemy\runtime.d --> 16 +<b>Authors:</b><br> 17 +k.inaba 18 +<br><br> 19 +<b>License:</b><br> 20 +NYSL 0.9982 http://www.kmonos.net/nysl/ 21 +<br><br> 22 + 23 + Runtime library for Polemy programming language.<br><br> 24 + 25 + 26 +<script>explorer.outline.incSymbolLevel();</script> 27 +<dl> 28 +<script>explorer.outline.writeEnabled = true;</script> 29 +<dt><span class="decl">void 30 +<span class="currsymbol">enrollRuntimeLibrary</span> 31 +<script>explorer.outline.addDecl('enrollRuntimeLibrary');</script> 32 + 33 +(Evaluator <span class="funcparam">e</span>); 34 +</span></dt> 35 +<script>explorer.outline.writeEnabled = false;</script> 36 + 37 + 38 +<dd>enroll the native implementations of primitive functions<br><br> 39 + 40 +</dd> 41 +</dl> 42 +<script>explorer.outline.decSymbolLevel();</script> 43 + 44 + 45 +</td></tr> 46 + <tr><td id="docfooter"> 47 + Page was generated with 48 + <img src="candydoc/img/candydoc.gif" style="vertical-align:middle; position:relative; top:-1px"> 49 + on Wed Nov 24 19:09:32 2010 50 + 51 + </td></tr> 52 + </table> 53 +</div> 54 +<script> 55 + explorer.packageExplorer.addModule("index"); 56 + explorer.packageExplorer.addModule("main"); 57 + explorer.packageExplorer.addModule("tricks.tricks"); 58 + explorer.packageExplorer.addModule("tricks.test"); 59 + explorer.packageExplorer.addModule("polemy._common"); 60 + explorer.packageExplorer.addModule("polemy.failure"); 61 + explorer.packageExplorer.addModule("polemy.layer"); 62 + explorer.packageExplorer.addModule("polemy.fresh"); 63 + explorer.packageExplorer.addModule("polemy.lex"); 64 + explorer.packageExplorer.addModule("polemy.parse"); 65 + explorer.packageExplorer.addModule("polemy.ast"); 66 + explorer.packageExplorer.addModule("polemy.value"); 67 + explorer.packageExplorer.addModule("polemy.valueconv"); 68 + explorer.packageExplorer.addModule("polemy.eval"); 69 + explorer.packageExplorer.addModule("polemy.runtime"); 70 + explorer.packageExplorer.addModule("polemy.repl");</script> 71 +</body></html> 72 + 73 +

Added doc/test.html version [adfbdf0e13d183a2]

1 + 2 +<html><head> 3 +<meta http-equiv="content-type" content="text/html; charset=utf-8"> 4 +<meta content="text/javascript" http-equiv="content-script-type"> 5 +<title>tricks.test</title> 6 +<link rel="stylesheet" type="text/css" href="candydoc/style.css"> 7 +<!--[if lt IE 7]><link rel="stylesheet" type="text/css" href="candydoc/ie56hack.css"><![endif]--> 8 +<script language="JavaScript" src="candydoc/util.js" type="text/javascript"></script> 9 +<script language="JavaScript" src="candydoc/tree.js" type="text/javascript"></script> 10 +<script language="JavaScript" src="candydoc/explorer.js" type="text/javascript"></script> 11 +</head><body> 12 +<div id="tabarea"></div><div id="explorerclient"></div> 13 +<div id="content"><script>explorer.initialize("tricks.test");</script> 14 + <table class="content"> 15 + <tr><td id="docbody"><h1>tricks.test</h1><!-- Generated by Ddoc from tricks\test.d --> 16 +<b>Authors:</b><br> 17 +k.inaba 18 +<br><br> 19 +<b>License:</b><br> 20 +NYSL 0.9982 http://www.kmonos.net/nysl/ 21 +<br><br> 22 + 23 + Hepler routines for unittesting. 24 +<br><br> 25 +<b>TODO:</b><br> 26 +Is there any clean way to implement "assert_compiles" and "assert_not_compile"?<br><br> 27 + 28 + 29 +<script>explorer.outline.incSymbolLevel();</script> 30 +<dl> 31 +<script>explorer.outline.writeEnabled = true;</script> 32 +<dt><span class="decl">void 33 +<span class="currsymbol">assert_throw</span> 34 +<script>explorer.outline.addDecl('assert_throw');</script> 35 + 36 +(ExcT = Throwable, T, string fn = __FILE__, size_t ln = __LINE__)(lazy T <span class="funcparam">t</span>, string <span class="funcparam">msg</span> = ""); 37 +</span></dt> 38 +<script>explorer.outline.writeEnabled = false;</script> 39 + 40 + 41 +<dd>Unittest helper that asserts an expression must throw something<br><br> 42 + 43 +</dd> 44 + 45 +<script>explorer.outline.writeEnabled = true;</script> 46 +<dt><span class="decl">T 47 +<span class="currsymbol">assert_nothrow</span> 48 +<script>explorer.outline.addDecl('assert_nothrow');</script> 49 + 50 +(T, string fn = __FILE__, size_t ln = __LINE__)(lazy T <span class="funcparam">t</span>, string <span class="funcparam">msg</span> = ""); 51 +</span></dt> 52 +<script>explorer.outline.writeEnabled = false;</script> 53 + 54 + 55 +<dd>Unittest helper that asserts an expression must not throw anything<br><br> 56 + 57 +</dd> 58 + 59 +<script>explorer.outline.writeEnabled = true;</script> 60 +<dt><span class="decl">alias 61 +<span class="currsymbol">assert_eq</span> 62 +<script>explorer.outline.addDecl('assert_eq');</script> 63 + 64 +; 65 +</span></dt> 66 +<script>explorer.outline.writeEnabled = false;</script> 67 + 68 + 69 +<dd>asserts two operands are ==<br><br> 70 + 71 +</dd> 72 + 73 +<script>explorer.outline.writeEnabled = true;</script> 74 +<dt><span class="decl">alias 75 +<span class="currsymbol">assert_ne</span> 76 +<script>explorer.outline.addDecl('assert_ne');</script> 77 + 78 +; 79 +</span></dt> 80 +<script>explorer.outline.writeEnabled = false;</script> 81 + 82 + 83 +<dd>asserts two operands are !=<br><br> 84 + 85 +</dd> 86 + 87 +<script>explorer.outline.writeEnabled = true;</script> 88 +<dt><span class="decl">alias 89 +<span class="currsymbol">assert_lt</span> 90 +<script>explorer.outline.addDecl('assert_lt');</script> 91 + 92 +; 93 +</span></dt> 94 +<script>explorer.outline.writeEnabled = false;</script> 95 + 96 + 97 +<dd>asserts two operands are <<br><br> 98 + 99 +</dd> 100 + 101 +<script>explorer.outline.writeEnabled = true;</script> 102 +<dt><span class="decl">alias 103 +<span class="currsymbol">assert_le</span> 104 +<script>explorer.outline.addDecl('assert_le');</script> 105 + 106 +; 107 +</span></dt> 108 +<script>explorer.outline.writeEnabled = false;</script> 109 + 110 + 111 +<dd>asserts two operands are &lt;=<br><br> 112 + 113 +</dd> 114 + 115 +<script>explorer.outline.writeEnabled = true;</script> 116 +<dt><span class="decl">alias 117 +<span class="currsymbol">assert_gt</span> 118 +<script>explorer.outline.addDecl('assert_gt');</script> 119 + 120 +; 121 +</span></dt> 122 +<script>explorer.outline.writeEnabled = false;</script> 123 + 124 + 125 +<dd>asserts two operands are &gt;<br><br> 126 + 127 +</dd> 128 + 129 +<script>explorer.outline.writeEnabled = true;</script> 130 +<dt><span class="decl">alias 131 +<span class="currsymbol">assert_ge</span> 132 +<script>explorer.outline.addDecl('assert_ge');</script> 133 + 134 +; 135 +</span></dt> 136 +<script>explorer.outline.writeEnabled = false;</script> 137 + 138 + 139 +<dd>asserts two operands are &gt;=<br><br> 140 + 141 +</dd> 142 +</dl> 143 +<script>explorer.outline.decSymbolLevel();</script> 144 + 145 + 146 +</td></tr> 147 + <tr><td id="docfooter"> 148 + Page was generated with 149 + <img src="candydoc/img/candydoc.gif" style="vertical-align:middle; position:relative; top:-1px"> 150 + on Wed Nov 24 19:09:32 2010 151 + 152 + </td></tr> 153 + </table> 154 +</div> 155 +<script> 156 + explorer.packageExplorer.addModule("index"); 157 + explorer.packageExplorer.addModule("main"); 158 + explorer.packageExplorer.addModule("tricks.tricks"); 159 + explorer.packageExplorer.addModule("tricks.test"); 160 + explorer.packageExplorer.addModule("polemy._common"); 161 + explorer.packageExplorer.addModule("polemy.failure"); 162 + explorer.packageExplorer.addModule("polemy.layer"); 163 + explorer.packageExplorer.addModule("polemy.fresh"); 164 + explorer.packageExplorer.addModule("polemy.lex"); 165 + explorer.packageExplorer.addModule("polemy.parse"); 166 + explorer.packageExplorer.addModule("polemy.ast"); 167 + explorer.packageExplorer.addModule("polemy.value"); 168 + explorer.packageExplorer.addModule("polemy.valueconv"); 169 + explorer.packageExplorer.addModule("polemy.eval"); 170 + explorer.packageExplorer.addModule("polemy.runtime"); 171 + explorer.packageExplorer.addModule("polemy.repl");</script> 172 +</body></html> 173 + 174 +

Added doc/tricks.html version [5661c0b00c83f9dd]

1 + 2 +<html><head> 3 +<meta http-equiv="content-type" content="text/html; charset=utf-8"> 4 +<meta content="text/javascript" http-equiv="content-script-type"> 5 +<title>tricks.tricks</title> 6 +<link rel="stylesheet" type="text/css" href="candydoc/style.css"> 7 +<!--[if lt IE 7]><link rel="stylesheet" type="text/css" href="candydoc/ie56hack.css"><![endif]--> 8 +<script language="JavaScript" src="candydoc/util.js" type="text/javascript"></script> 9 +<script language="JavaScript" src="candydoc/tree.js" type="text/javascript"></script> 10 +<script language="JavaScript" src="candydoc/explorer.js" type="text/javascript"></script> 11 +</head><body> 12 +<div id="tabarea"></div><div id="explorerclient"></div> 13 +<div id="content"><script>explorer.initialize("tricks.tricks");</script> 14 + <table class="content"> 15 + <tr><td id="docbody"><h1>tricks.tricks</h1><!-- Generated by Ddoc from tricks\tricks.d --> 16 +<b>Authors:</b><br> 17 +k.inaba 18 +<br><br> 19 +<b>License:</b><br> 20 +NYSL 0.9982 http://www.kmonos.net/nysl/ 21 +<br><br> 22 + 23 + Common 24 +<span class="currsymbol">tricks</span> 25 +<script>explorer.outline.addDecl('tricks');</script> 26 + 27 + and utilities for programming in D.<br><br> 28 + 29 + 30 +<script>explorer.outline.incSymbolLevel();</script> 31 +<dl> 32 +<script>explorer.outline.writeEnabled = true;</script> 33 +<dt><span class="decl">string 34 +<span class="currsymbol">sprintf</span> 35 +<script>explorer.outline.addDecl('sprintf');</script> 36 + 37 +(string fmt, T...)(T <span class="funcparam">params</span>); 38 +</span></dt> 39 +<script>explorer.outline.writeEnabled = false;</script> 40 + 41 + 42 +<dd>Simple Wrapper for std.format.doFormat<br><br> 43 + 44 +</dd> 45 + 46 +<script>explorer.outline.writeEnabled = true;</script> 47 +<dt><span class="decl">ExceptionType 48 +<span class="currsymbol">genex</span> 49 +<script>explorer.outline.addDecl('genex');</script> 50 + 51 +(ExceptionType, string fn = __FILE__, int ln = __LINE__, T...)(T <span class="funcparam">params</span>); 52 +</span></dt> 53 +<script>explorer.outline.writeEnabled = false;</script> 54 + 55 + 56 +<dd>Create an exception with automatically completed filename and lineno information<br><br> 57 + 58 +</dd> 59 + 60 +<script>explorer.outline.writeEnabled = true;</script> 61 +<dt><span class="decl">template 62 +<span class="currsymbol">SimpleConstructor</span> 63 +<script>explorer.outline.addDecl('SimpleConstructor');</script> 64 + 65 +()</span></dt> 66 +<script>explorer.outline.writeEnabled = false;</script> 67 + 68 + 69 +<dd>Mixing-in the bean constructor for a class<br><br> 70 + 71 + 72 +<script>explorer.outline.incSymbolLevel();</script> 73 +<dl> 74 +<script>explorer.outline.writeEnabled = true;</script> 75 +<dt><span class="decl">this(typeof(this.tupleof) params); 76 +</span></dt> 77 +<script>explorer.outline.writeEnabled = false;</script> 78 + 79 + 80 +<dd>member-by-member constructor<br><br> 81 + 82 +</dd> 83 +</dl> 84 +<script>explorer.outline.decSymbolLevel();</script> 85 + 86 + 87 +</dd> 88 + 89 +<script>explorer.outline.writeEnabled = true;</script> 90 +<dt><span class="decl">template 91 +<span class="currsymbol">SimpleToHash</span> 92 +<script>explorer.outline.addDecl('SimpleToHash');</script> 93 + 94 +()</span></dt> 95 +<script>explorer.outline.writeEnabled = false;</script> 96 + 97 + 98 +<dd>Mixing-in the MOST-DERIVED-member-wise comparator for a class<br><br> 99 + 100 + 101 +<script>explorer.outline.incSymbolLevel();</script> 102 +<dl> 103 +<script>explorer.outline.writeEnabled = true;</script> 104 +<dt><span class="decl">const hash_t 105 +<span class="currsymbol">toHash</span> 106 +<script>explorer.outline.addDecl('toHash');</script> 107 + 108 +(); 109 +</span></dt> 110 +<script>explorer.outline.writeEnabled = false;</script> 111 + 112 + 113 +<dd>member-by-member hash<br><br> 114 + 115 +</dd> 116 +</dl> 117 +<script>explorer.outline.decSymbolLevel();</script> 118 + 119 + 120 +</dd> 121 + 122 +<script>explorer.outline.writeEnabled = true;</script> 123 +<dt><span class="decl">template 124 +<span class="currsymbol">SimpleCompare</span> 125 +<script>explorer.outline.addDecl('SimpleCompare');</script> 126 + 127 +()</span></dt> 128 +<script>explorer.outline.writeEnabled = false;</script> 129 + 130 + 131 +<dd>Mixing-in the MOST-DERIVED-member-wise comparator for a class<br><br> 132 + 133 + 134 +<script>explorer.outline.incSymbolLevel();</script> 135 +<dl> 136 +<script>explorer.outline.writeEnabled = true;</script> 137 +<dt><span class="decl">const bool 138 +<span class="currsymbol">opEquals</span> 139 +<script>explorer.outline.addDecl('opEquals');</script> 140 + 141 +(Object <span class="funcparam">rhs_</span>); 142 +</span></dt> 143 +<script>explorer.outline.writeEnabled = false;</script> 144 + 145 + 146 +<dd>member-by-member equality<br><br> 147 + 148 +</dd> 149 + 150 +<script>explorer.outline.writeEnabled = true;</script> 151 +<dt><span class="decl">const int 152 +<span class="currsymbol">opCmp</span> 153 +<script>explorer.outline.addDecl('opCmp');</script> 154 + 155 +(Object <span class="funcparam">rhs_</span>); 156 +</span></dt> 157 +<script>explorer.outline.writeEnabled = false;</script> 158 + 159 + 160 +<dd>member-by-member compare<br><br> 161 + 162 +</dd> 163 +</dl> 164 +<script>explorer.outline.decSymbolLevel();</script> 165 + 166 + 167 +</dd> 168 + 169 +<script>explorer.outline.writeEnabled = true;</script> 170 +<dt><span class="decl">template 171 +<span class="currsymbol">SimpleToString</span> 172 +<script>explorer.outline.addDecl('SimpleToString');</script> 173 + 174 +()</span></dt> 175 +<script>explorer.outline.writeEnabled = false;</script> 176 + 177 + 178 +<dd>Mixing-in a simple toString method<br><br> 179 + 180 + 181 +<script>explorer.outline.incSymbolLevel();</script> 182 +<dl> 183 +<script>explorer.outline.writeEnabled = true;</script> 184 +<dt><span class="decl">string 185 +<span class="currsymbol">toString</span> 186 +<script>explorer.outline.addDecl('toString');</script> 187 + 188 +(); 189 +</span></dt> 190 +<script>explorer.outline.writeEnabled = false;</script> 191 + 192 + 193 +<dd>member-by-member 194 +<span class="currsymbol">toString</span> 195 +<script>explorer.outline.addDecl('toString');</script> 196 + 197 +<br><br> 198 + 199 +</dd> 200 +</dl> 201 +<script>explorer.outline.decSymbolLevel();</script> 202 + 203 + 204 +</dd> 205 + 206 +<script>explorer.outline.writeEnabled = true;</script> 207 +<dt><span class="decl">template 208 +<span class="currsymbol">SimpleClass</span> 209 +<script>explorer.outline.addDecl('SimpleClass');</script> 210 + 211 +()</span></dt> 212 +<script>explorer.outline.writeEnabled = false;</script> 213 + 214 + 215 +<dd>Everything is in<br><br> 216 + 217 +</dd> 218 + 219 +<script>explorer.outline.writeEnabled = true;</script> 220 +<dt><span class="decl">template 221 +<span class="currsymbol">firstParam</span> 222 +<script>explorer.outline.addDecl('firstParam');</script> 223 + 224 +(T)</span></dt> 225 +<script>explorer.outline.writeEnabled = false;</script> 226 + 227 + 228 +<dd>Will be used for dynamic overload resolution pattern<br><br> 229 + 230 +</dd> 231 +</dl> 232 +<script>explorer.outline.decSymbolLevel();</script> 233 + 234 + 235 +</td></tr> 236 + <tr><td id="docfooter"> 237 + Page was generated with 238 + <img src="candydoc/img/candydoc.gif" style="vertical-align:middle; position:relative; top:-1px"> 239 + on Wed Nov 24 19:09:32 2010 240 + 241 + </td></tr> 242 + </table> 243 +</div> 244 +<script> 245 + explorer.packageExplorer.addModule("index"); 246 + explorer.packageExplorer.addModule("main"); 247 + explorer.packageExplorer.addModule("tricks.tricks"); 248 + explorer.packageExplorer.addModule("tricks.test"); 249 + explorer.packageExplorer.addModule("polemy._common"); 250 + explorer.packageExplorer.addModule("polemy.failure"); 251 + explorer.packageExplorer.addModule("polemy.layer"); 252 + explorer.packageExplorer.addModule("polemy.fresh"); 253 + explorer.packageExplorer.addModule("polemy.lex"); 254 + explorer.packageExplorer.addModule("polemy.parse"); 255 + explorer.packageExplorer.addModule("polemy.ast"); 256 + explorer.packageExplorer.addModule("polemy.value"); 257 + explorer.packageExplorer.addModule("polemy.valueconv"); 258 + explorer.packageExplorer.addModule("polemy.eval"); 259 + explorer.packageExplorer.addModule("polemy.runtime"); 260 + explorer.packageExplorer.addModule("polemy.repl");</script> 261 +</body></html> 262 + 263 +

Added doc/value.html version [925e1ae13e3ace40]

1 + 2 +<html><head> 3 +<meta http-equiv="content-type" content="text/html; charset=utf-8"> 4 +<meta content="text/javascript" http-equiv="content-script-type"> 5 +<title>polemy.value</title> 6 +<link rel="stylesheet" type="text/css" href="candydoc/style.css"> 7 +<!--[if lt IE 7]><link rel="stylesheet" type="text/css" href="candydoc/ie56hack.css"><![endif]--> 8 +<script language="JavaScript" src="candydoc/util.js" type="text/javascript"></script> 9 +<script language="JavaScript" src="candydoc/tree.js" type="text/javascript"></script> 10 +<script language="JavaScript" src="candydoc/explorer.js" type="text/javascript"></script> 11 +</head><body> 12 +<div id="tabarea"></div><div id="explorerclient"></div> 13 +<div id="content"><script>explorer.initialize("polemy.value");</script> 14 + <table class="content"> 15 + <tr><td id="docbody"><h1>polemy.value</h1><!-- Generated by Ddoc from polemy\value.d --> 16 +<b>Authors:</b><br> 17 +k.inaba 18 +<br><br> 19 +<b>License:</b><br> 20 +NYSL 0.9982 http://www.kmonos.net/nysl/ 21 +<br><br> 22 + 23 + Runtime data structures for Polemy programming language.<br><br> 24 + 25 + 26 +<script>explorer.outline.incSymbolLevel();</script> 27 +<dl> 28 +<script>explorer.outline.writeEnabled = true;</script> 29 +<dt><span class="decl">abstract class 30 +<span class="currsymbol">Value</span> 31 +<script>explorer.outline.addDecl('Value');</script> 32 + 33 +; 34 +</span></dt> 35 +<script>explorer.outline.writeEnabled = false;</script> 36 + 37 + 38 +<dd>Runtime values of Polemy<br><br> 39 + 40 +</dd> 41 + 42 +<script>explorer.outline.writeEnabled = true;</script> 43 +<dt><span class="decl">class 44 +<span class="currsymbol">IntValue</span> 45 +<script>explorer.outline.addDecl('IntValue');</script> 46 + 47 +: polemy.value.Value; 48 +</span></dt> 49 +<script>explorer.outline.writeEnabled = false;</script> 50 + 51 + 52 +<dd><br><br> 53 +</dd> 54 + 55 +<script>explorer.outline.writeEnabled = true;</script> 56 +<dt><span class="decl">class 57 +<span class="currsymbol">StrValue</span> 58 +<script>explorer.outline.addDecl('StrValue');</script> 59 + 60 +: polemy.value.Value; 61 +</span></dt> 62 +<script>explorer.outline.writeEnabled = false;</script> 63 + 64 + 65 +<dd><br><br> 66 +</dd> 67 + 68 +<script>explorer.outline.writeEnabled = true;</script> 69 +<dt><span class="decl">class 70 +<span class="currsymbol">UndefinedValue</span> 71 +<script>explorer.outline.addDecl('UndefinedValue');</script> 72 + 73 +: polemy.value.Value; 74 +</span></dt> 75 +<script>explorer.outline.writeEnabled = false;</script> 76 + 77 + 78 +<dd><br><br> 79 +</dd> 80 + 81 +<script>explorer.outline.writeEnabled = true;</script> 82 +<dt><span class="decl">abstract class 83 +<span class="currsymbol">FunValue</span> 84 +<script>explorer.outline.addDecl('FunValue');</script> 85 + 86 +: polemy.value.Value; 87 +</span></dt> 88 +<script>explorer.outline.writeEnabled = false;</script> 89 + 90 + 91 +<dd><br><br> 92 +</dd> 93 + 94 +<script>explorer.outline.writeEnabled = true;</script> 95 +<dt><span class="decl">class 96 +<span class="currsymbol">Table</span> 97 +<script>explorer.outline.addDecl('Table');</script> 98 + 99 +: polemy.value.Value; 100 +</span></dt> 101 +<script>explorer.outline.writeEnabled = false;</script> 102 + 103 + 104 +<dd>Context (variable environment) 105 + Simlar to prototype chain of ECMAScript etc. 106 + But extended with the notion of "Layer"<br><br> 107 + 108 + 109 +<script>explorer.outline.incSymbolLevel();</script> 110 +<dl> 111 +<script>explorer.outline.writeEnabled = true;</script> 112 +<dt><span class="decl">bool 113 +<span class="currsymbol">empty</span> 114 +<script>explorer.outline.addDecl('empty');</script> 115 + 116 +(); 117 +</span></dt> 118 +<script>explorer.outline.writeEnabled = false;</script> 119 + 120 + 121 +<dd>Is this an 122 +<span class="currsymbol">empty</span> 123 +<script>explorer.outline.addDecl('empty');</script> 124 + 125 + table?<br><br> 126 + 127 +</dd> 128 + 129 +<script>explorer.outline.writeEnabled = true;</script> 130 +<dt><span class="decl">bool 131 +<span class="currsymbol">isList</span> 132 +<script>explorer.outline.addDecl('isList');</script> 133 + 134 +(); 135 +</span></dt> 136 +<script>explorer.outline.writeEnabled = false;</script> 137 + 138 + 139 +<dd>Can be seen as a cons-list?<br><br> 140 + 141 +</dd> 142 + 143 +<script>explorer.outline.writeEnabled = true;</script> 144 +<dt><span class="decl">Value[] 145 +<span class="currsymbol">toList</span> 146 +<script>explorer.outline.addDecl('toList');</script> 147 + 148 +(); 149 +</span></dt> 150 +<script>explorer.outline.writeEnabled = false;</script> 151 + 152 + 153 +<dd>Regard table as a cons-list and convert to an array<br><br> 154 + 155 +</dd> 156 +</dl> 157 +<script>explorer.outline.decSymbolLevel();</script> 158 + 159 + 160 +</dd> 161 +</dl> 162 +<script>explorer.outline.decSymbolLevel();</script> 163 + 164 + 165 +</td></tr> 166 + <tr><td id="docfooter"> 167 + Page was generated with 168 + <img src="candydoc/img/candydoc.gif" style="vertical-align:middle; position:relative; top:-1px"> 169 + on Wed Nov 24 19:09:32 2010 170 + 171 + </td></tr> 172 + </table> 173 +</div> 174 +<script> 175 + explorer.packageExplorer.addModule("index"); 176 + explorer.packageExplorer.addModule("main"); 177 + explorer.packageExplorer.addModule("tricks.tricks"); 178 + explorer.packageExplorer.addModule("tricks.test"); 179 + explorer.packageExplorer.addModule("polemy._common"); 180 + explorer.packageExplorer.addModule("polemy.failure"); 181 + explorer.packageExplorer.addModule("polemy.layer"); 182 + explorer.packageExplorer.addModule("polemy.fresh"); 183 + explorer.packageExplorer.addModule("polemy.lex"); 184 + explorer.packageExplorer.addModule("polemy.parse"); 185 + explorer.packageExplorer.addModule("polemy.ast"); 186 + explorer.packageExplorer.addModule("polemy.value"); 187 + explorer.packageExplorer.addModule("polemy.valueconv"); 188 + explorer.packageExplorer.addModule("polemy.eval"); 189 + explorer.packageExplorer.addModule("polemy.runtime"); 190 + explorer.packageExplorer.addModule("polemy.repl");</script> 191 +</body></html> 192 + 193 +

Added doc/valueconv.html version [2aa3eeff1e9266f3]

1 + 2 +<html><head> 3 +<meta http-equiv="content-type" content="text/html; charset=utf-8"> 4 +<meta content="text/javascript" http-equiv="content-script-type"> 5 +<title>polemy.valueconv</title> 6 +<link rel="stylesheet" type="text/css" href="candydoc/style.css"> 7 +<!--[if lt IE 7]><link rel="stylesheet" type="text/css" href="candydoc/ie56hack.css"><![endif]--> 8 +<script language="JavaScript" src="candydoc/util.js" type="text/javascript"></script> 9 +<script language="JavaScript" src="candydoc/tree.js" type="text/javascript"></script> 10 +<script language="JavaScript" src="candydoc/explorer.js" type="text/javascript"></script> 11 +</head><body> 12 +<div id="tabarea"></div><div id="explorerclient"></div> 13 +<div id="content"><script>explorer.initialize("polemy.valueconv");</script> 14 + <table class="content"> 15 + <tr><td id="docbody"><h1>polemy.valueconv</h1><!-- Generated by Ddoc from polemy\valueconv.d --> 16 +<b>Authors:</b><br> 17 +k.inaba 18 +<br><br> 19 +<b>License:</b><br> 20 +NYSL 0.9982 http://www.kmonos.net/nysl/ 21 +<br><br> 22 + 23 + Convert values between Polemy and D<br><br> 24 + 25 + 26 +<script>explorer.outline.incSymbolLevel();</script> 27 +<dl> 28 +<script>explorer.outline.writeEnabled = true;</script> 29 +<dt><span class="decl">T 30 +<span class="currsymbol">polemy2d</span> 31 +<script>explorer.outline.addDecl('polemy2d');</script> 32 + 33 +(T)(Value <span class="funcparam">_v</span>, LexPosition <span class="funcparam">callpos</span> = null); 34 +</span></dt> 35 +<script>explorer.outline.writeEnabled = false;</script> 36 + 37 + 38 +<dd>Experimental!! Convert Polemy value to D Value<br><br> 39 + 40 +</dd> 41 + 42 +<script>explorer.outline.writeEnabled = true;</script> 43 +<dt><span class="decl">Table 44 +<span class="currsymbol">makeCons</span> 45 +<script>explorer.outline.addDecl('makeCons');</script> 46 + 47 +(Value <span class="funcparam">a</span>, Value <span class="funcparam">d</span>); 48 +</span></dt> 49 +<script>explorer.outline.writeEnabled = false;</script> 50 + 51 + 52 +<dd>Cons of two pairs<br><br> 53 + 54 +</dd> 55 + 56 +<script>explorer.outline.writeEnabled = true;</script> 57 +<dt><span class="decl">Value 58 +<span class="currsymbol">d2polemy</span> 59 +<script>explorer.outline.addDecl('d2polemy');</script> 60 + 61 +(T)(T <span class="funcparam">e</span>); 62 +</span></dt> 63 +<script>explorer.outline.writeEnabled = false;</script> 64 + 65 + 66 +<dd>Experimental!! Convert D value (except AST) to Polemy Value<br><br> 67 + 68 +</dd> 69 + 70 +<script>explorer.outline.writeEnabled = true;</script> 71 +<dt><span class="decl">Value 72 +<span class="currsymbol">ast2table</span> 73 +<script>explorer.outline.addDecl('ast2table');</script> 74 + 75 +(T)(T <span class="funcparam">e</span>, Value delegate(AST) <span class="funcparam">rec</span>); 76 +</span></dt> 77 +<script>explorer.outline.writeEnabled = false;</script> 78 + 79 + 80 +<dd>Convert AST to Table so that it can be used in Polemy<br><br> 81 + 82 +</dd> 83 +</dl> 84 +<script>explorer.outline.decSymbolLevel();</script> 85 + 86 + 87 +</td></tr> 88 + <tr><td id="docfooter"> 89 + Page was generated with 90 + <img src="candydoc/img/candydoc.gif" style="vertical-align:middle; position:relative; top:-1px"> 91 + on Wed Nov 24 19:09:32 2010 92 + 93 + </td></tr> 94 + </table> 95 +</div> 96 +<script> 97 + explorer.packageExplorer.addModule("index"); 98 + explorer.packageExplorer.addModule("main"); 99 + explorer.packageExplorer.addModule("tricks.tricks"); 100 + explorer.packageExplorer.addModule("tricks.test"); 101 + explorer.packageExplorer.addModule("polemy._common"); 102 + explorer.packageExplorer.addModule("polemy.failure"); 103 + explorer.packageExplorer.addModule("polemy.layer"); 104 + explorer.packageExplorer.addModule("polemy.fresh"); 105 + explorer.packageExplorer.addModule("polemy.lex"); 106 + explorer.packageExplorer.addModule("polemy.parse"); 107 + explorer.packageExplorer.addModule("polemy.ast"); 108 + explorer.packageExplorer.addModule("polemy.value"); 109 + explorer.packageExplorer.addModule("polemy.valueconv"); 110 + explorer.packageExplorer.addModule("polemy.eval"); 111 + explorer.packageExplorer.addModule("polemy.runtime"); 112 + explorer.packageExplorer.addModule("polemy.repl");</script> 113 +</body></html> 114 + 115 +

Modified index.dd from [f78a001ef162c560] to [07bae30af3901ecf].

8 8 <p> 9 9 あとついでに、左のサイドバーの "Package" タブをクリックすると実装のソースのドキュメントが読めます。 10 10 </p> 11 11 12 12 $(DDOC_MEMBERS 13 13 14 14 $(SECTION Syntax, $(SECBODY 15 - 16 15 <p> 17 16 文法について。 18 17 字句解析がわりと適当なので、 19 18 変数宣言の変数名のところに、数字を変数名として使えて参照できない変数が作れたり、 20 19 予約語は予約語として解釈され得ないところでは普通に変数名として使えちゃったりして、 21 20 偶にとんでもない見かけのソースが構文解析通りますが、気にしないで適当に使って下さい。 22 21 </p> ................................................................................ 89 88 <br/> 90 89 パターンマッチも全部 <tt>if</tt> と <tt>==</tt> と <tt>&amp;&amp;</tt> と 91 90 <tt>.</tt> と <tt>.?</tt> を使った関数呼び出し式に書き換えられていますが、 92 91 規則の詳細を説明するのが面倒なので適当に想像して下さい。 93 92 他の書き換えはこんな感じです。 94 93 </p> 95 94 <pre> 96 - if (E) then{E} ⇒ if( E, fun(){E}, fun(){} ) 97 - if (E) then{E} else{E} ⇒ if( E, fun(){E}, fun(){E} ) 98 - E BINOP E ⇒ BINOP(E, E) 99 - { ENTRIES } ⇒ {}{ ENTRIES } 100 - {} ⇒ {}() 101 - E {ID:E, ...} ⇒ .=(E, ID, E) { ... } 95 + if (E) {E} ⇒ if( E, fun(){E}, fun(){} ) 96 + if (E) {E} else {E} ⇒ if( E, fun(){E}, fun(){E} ) 97 + E BINOP E ⇒ BINOP(E, E) 98 + { ENTRIES } ⇒ {}{ ENTRIES } 99 + {} ⇒ {}() 100 + E {ID:E, ...} ⇒ .=(E, ID, E) { ... } 102 101 </pre> 103 102 <p> 104 103 変数宣言に色々ありますが、<tt>let</tt> と <tt>var</tt> と <tt>def</tt> は同じ扱いで、 105 104 <tt>in</tt> と <tt>;</tt> は同じ扱いです。つまり 106 105 </p> 107 106 <pre> 108 107 let x = E in E ................................................................................ 135 134 <p> 136 135 中身が空の関数に何を返させるかは適当です。今はとりあえず適当に文字列返してます。 137 136 </p> 138 137 )) 139 138 140 139 $(SECTION 変数のスコープ規則, $(SECBODY 141 140 <p> 142 -NOTE: Theres no "let rec" syntax, but still recursive definition works 143 - def f(x) { if(x==0){1}else{x*f(x-1)} } in f(10) #=> 3628800 144 - yet still the code below also works 145 - def x=21 in def x=x+x in x #=> 42. 146 - The internal scoping mechanism is a little tricky (this is for coping with 147 - the "layer" feature explained below), but I hope that it works as everyone 148 - expects in most cases, as long as you don't use the same-name-variables heavily :). 141 +基本的には、let によって常識的な感じに変数のスコープがネストします。 142 +</p> 143 +<pre> 144 + let x=21 in let x=x+x in x $(D_COMMENT # 42) 145 +</pre> 146 +<p> 147 +一方で、"let rec" のような特別な構文はありませんが、 148 +</p> 149 +<pre> 150 + let f = fun(x) { if(x==0){1}else{x*f(x-1)} } in f(10) $(D_COMMENT # 3628800) 151 +</pre> 152 +<p> 153 +再帰的な関数定義なども、おそらく意図されたとおりに動きます。 154 +内部の詳細は、諸般の事情により、 155 +マジカルで破壊的なスコープ規則になっているのですが、 156 +同名の変数を激しく重ねて使ったりしなければ、 157 +だいたい自然な動きをすると思います、たぶん、はい。 158 +</p> 159 +<p> 160 +ひとつだけ不可思議な動きをするのは、以下のケースです。 161 +</p> 162 +<pre> 163 + let x = 1 in 164 + let f = fun() {x} in 165 + let x = 2 in 166 + f() $(D_COMMENT # 2!!) 167 +</pre> 168 +<p> 169 +let-in を縦にチェインしたときだけ、同名変数を破壊的に上書きします 170 +(再帰関数の定義が"うまく"いっているのはこの上書きのためです)。 171 +なんでこんなことになっているかというと、 172 +後で説明する「レイヤ」を使ったときに 173 +<tt>let foo = ... in @lay foo = ... in ...</tt> 174 +で他レイヤに重ね書きするためであります。 149 175 </p> 150 176 )) 151 - 177 +) 152 178 )) 153 179 154 180 155 181 156 182 157 183 $(SECTION Basic Features, $(SECBODY 158 184 <p> ................................................................................ 183 209 関数はいわゆる「クロージャ」です。静的スコープで外側の環境にアクセスできます。 184 210 テーブルはいわゆるプロトタイプチェーンを持っていて、 185 211 自分にないフィールドの場合は親に問い合わせが行く感じになっていますが、 186 212 フィールドの書き換えがないので、これは特に意味ないかもしれない…。 187 213 </p> 188 214 )) 189 215 $(SECTION パターンマッチ, $(SECBODY 190 -pattern matching is also available. Here is an example. 191 - 192 - def adjSum(lst) 193 - { 194 - case( lst ) 195 - when( {car:x, cdr:{car: y, cdr:z}} ) { {car: x+y, cdr: adjSum(z)} } 196 - when( {car:x, cdr:{}} ) { {car: x, cdr: {}} } 197 - when( {} ) { {} } 198 - }; 199 - 200 -It is expanded to a sequence of if-then-elses prefering the first-match. 201 -Note that {a: _} pattern matches all the tables that have the .a field. 202 -It also matches to {a: 123, b: 456} having extra .b field. So, changing the 203 -order of "when"s in the above code changes the behavior. 216 +<p> 217 +適当に実装されたパターンマッチがあります。 218 +リストの 2n 番目と 2n+1 番目を足して長さを半分にする関数: 219 +</p> 220 +<pre> 221 + def adjSum(lst) 222 + { 223 + case( lst ) 224 + when( {car:x, cdr:{car: y, cdr:z}} ) { {car: x+y, cdr: adjSum(z)} } 225 + when( {car:x, cdr:{}} ) { lst } 226 + when( {} ) { {} } 227 + } 228 +</pre> 229 +<p> 230 +動かすときには、処理系がそれっぽい if-then-else に展開しています。 231 +<tt>when</tt> を上から試していって、最初にマッチしたところを実行します。 232 +</p> 233 +<pre> 234 + PAT ::= "_" $(D_COMMENT # ワイルドカード) 235 + | ID $(D_COMMENT # 変数パターン) 236 + | "{" ID ":" PAT "," ... "," ID : PAT "}" $(D_COMMENT # テーブルパターン) 237 + | E $(D_COMMENT # 値パターン) 238 +</pre> 239 +<p> 240 +変数パターンは常にマッチして、値をその変数に束縛します。 241 +ワイルドカードも常にマッチしますが、変数束縛しません。 242 +値パターンは、任意の式が書けます。その式を評価した結果と <tt>==</tt> ならマッチします。 243 +外で束縛された変数を値パターンとして配置、は直接はできないので 244 +</p> 245 +<pre> 246 + var x = 123; 247 + case( foo ) 248 + when( {val: x+0} ) { ... } $(D_COMMENT # これは任意の {val:123} と同じ) 249 + when( {val: x} ) { ... } $(D_COMMENT # これは任意の foo.?val なら常にマッチ) 250 +</pre> 251 +<p> 252 +適当にちょっと複雑な式にしてやるとよいかも(裏技)。 253 +</p> 254 +<p> 255 +テーブルパターンは、書かれたキーが全てあればマッチします。 256 +<tt>{a: _}</tt> は、<tt>.a</tt> を持ってさえいればマッチするので、 257 +<tt>{a: 123, b: 456}</tt> なんかにもマッチします。 258 +なので、リストに対するパターンを書くときには、car/cdr の場合を先に書かないと 259 +<tt>when({})</tt> を上に書くと全部マッチしちゃいます。注意。 260 +</p> 204 261 )) 205 262 ) 206 263 )) 207 264 208 265 209 266 210 267 ................................................................................ 355 412 is@value:app, arg@value:{... 356 413 /fst@value:3 357 414 /} 358 415 359 416 its corresponding arguments are evaluated in the layer and passed to it. 360 417 If you specify multiple layers, the argument expression is run multiple times. 361 418 If you do not specify any layer for a parameter, it works in the neutral layer. 419 +</pre> 420 +)) 362 421 363 422 423 +$(SECTION Macro Layers, $(SECBODY 424 +<p> 425 +Polemy 言語組み込みのレイヤは <code>@value</code> と <code>@macro</code> の二つです。 426 +(内部的にはもういくつかありますが、ユーザから直接は使えません。) 427 +<code>@value</code> は、「普通に」普通のセマンティクスでプログラムを実行するレイヤでした。 428 +<code>@macro</code> は、実は、<code>@value</code> よりも前に実行されるレイヤで、 429 +「プログラムを実行するとその構文木を返す」というセマンティクスで動きます。 430 +</p> 431 +<pre> 432 + (ここに例) 433 +</pre> 434 +<p> 435 +動きとしてはこうです。 436 +</p> 437 +<ol> 438 +<li>関数呼び出し時(とトップレベル環境の実行開始時)に、 439 + まず、<code>@macro</code> レイヤでコードを実行。</li> 440 +<li>返ってきた構文木を、<code>@value</code> レイヤ、 441 + またはその関数を呼び出したときのレイヤで実行。</li> 442 +</ol> 443 +<p> 444 +<code>@macro</code> レイヤも所詮ただのレイヤですので、 445 +上で説明した方法で <code>@macro</code> レイヤに関数などを登録しておくことで、 446 +構文木の生成をいじることが可能です。まさにマクロ。 447 +</p> 364 448 365 -[@macro layer] 366 - 449 +$(DDOC_MEMBERS 450 +$(SECTION 使い方, $(SECBODY 451 +<pre> 367 452 When function is invoked, it first run in the @macro layer, and after that, 368 453 it run in the neutral layer. Here is an example. 369 454 370 455 >> @macro twice(x) { x; x } 371 456 >> def f() { twice(print("Hello")); 999 } 372 457 (function:173b6a0:1789720) 373 458 >> f() ................................................................................ 380 465 in the @macro layer. Basically what it does is to just construct its syntax tree. 381 466 But, since we have defined the "twice" function in the @macro layer, it is 382 467 execute as a function. Resulting syntax tree is 383 468 "print("Hello"); print("Hello"); 999" 384 469 and this is executed on the neutral (in this example, @value) layer. 385 470 This is the reason why you see two "Hello"s. 386 471 472 + [[quote and unquote]] 387 473 474 + Here is more involved example of code genration. 475 + From "x", it generates "x*x*x*x*x*x*x*x*x*x". 476 + 477 + @macro pow10(x) { 478 + @value( 479 + def pow(x, n) { 480 + if( n == 1 ) { x } 481 + else { 482 + @macro( @value(x) * @value(pow(x,n-1)) ) 483 + } 484 + } 485 + in 486 + pow(@macro(x),10) 487 + ) 488 + }; 489 + 490 + Here, x is a syntax tree but n is an actual integer. If you read carefully, 491 + you should get what is going on. Basically, @macro can be considered like 492 + quasiquoting and @value to be an escape from it. 493 +</pre> 494 +)) 495 +$(SECTION 微妙な挙動, $(SECBODY 496 +<pre> 497 + (rawmacro) レイヤの話 388 498 389 499 [[limitations]] 390 500 391 501 This @macro layer is a very primitive one, and not a perfect macro language. 392 502 Two major limitations are seen in the following "it" example. 393 503 394 504 >> @macro LetItBe(x, y) { let it = x in y }; ................................................................................ 407 517 So 408 518 409 519 >> LetItBe( 1+2+3, it*it ) 410 520 ...\value.d(173): [<REPL>:24:1] variable LetItBe is not set in layer @value 411 521 412 522 you cannot directly use the macro in the same scope as the definition. 413 523 You need to wrap it up in a function (like the foo() in the above example). 414 - 415 - 416 - 417 - [[quote and unquote]] 418 - 419 - Here is more involved example of code genration. 420 - From "x", it generates "x*x*x*x*x*x*x*x*x*x". 421 - 422 - @macro pow10(x) { 423 - @value( 424 - def pow(x, n) { 425 - if( n == 1 ) { x } 426 - else { 427 - @macro( @value(x) * @value(pow(x,n-1)) ) 428 - } 429 - } 430 - in 431 - pow(@macro(x),10) 432 - ) 433 - }; 434 - 435 - Here, x is a syntax tree but n is an actual integer. If you read carefully, 436 - you should get what is going on. Basically, @macro can be considered like 437 - quasiquoting and @value to be an escape from it. 438 524 </pre> 525 +)) 526 +) 439 527 )) 440 528 441 529 442 530 $(SECTION Built-in Primitives, $(SECBODY 443 531 <p> 444 532 組み込み関数・変数の一覧。 445 533 </p>