Check-in [f7e9e77316]
Not logged in
Overview
SHA1 Hash:f7e9e773169d8428df5d23b0fbf3e7a04bc8746b
Date: 2010-11-26 16:42:38
User: kinaba
Comment:introduced "..." expression, and replaced the pattern match failure with this.
Timelines: family | ancestors | descendants | both | trunk
Downloads: Tarball | ZIP archive
Other Links: files | file ages | manifest
Tags And Properties
Changes

Modified doc/_common.html from [9340890a47c908ed] to [b9095bf676f7ac7c].

22 22 23 23 The list of modules globaly used inside Polemy.<br><br> 24 24 25 25 </td></tr> 26 26 <tr><td id="docfooter"> 27 27 Page was generated with 28 28 <img src="candydoc/img/candydoc.gif" style="vertical-align:middle; position:relative; top:-1px"> 29 - on Thu Nov 25 12:13:45 2010 29 + on Fri Nov 26 16:41:43 2010 30 30 31 31 </td></tr> 32 32 </table> 33 33 </div> 34 34 <script> 35 35 explorer.packageExplorer.addModule("index"); 36 36 explorer.packageExplorer.addModule("main");

Modified doc/ast.html from [378b6fe37d6f4ecd] to [7559b28d1aa75ece].

406 406 <dd><br><br> 407 407 </dd> 408 408 </dl> 409 409 <script>explorer.outline.decSymbolLevel();</script> 410 410 411 411 412 412 </dd> 413 + 414 +<script>explorer.outline.writeEnabled = true;</script> 415 +<dt><span class="decl">class 416 +<span class="currsymbol">Die</span> 417 +<script>explorer.outline.addDecl('Die');</script> 418 + 419 +: polemy.ast.AST; 420 +</span></dt> 421 +<script>explorer.outline.writeEnabled = false;</script> 422 + 423 + 424 +<dd>AST node for deadend<br><br> 425 + 426 +</dd> 413 427 414 428 <script>explorer.outline.writeEnabled = true;</script> 415 429 <dt><span class="decl">alias 416 430 <span class="currsymbol">ListOfASTTypes</span> 417 431 <script>explorer.outline.addDecl('ListOfASTTypes');</script> 418 432 419 433 ; ................................................................................ 550 564 (string <span class="funcparam">name</span>, string[] <span class="funcparam">lay</span>...); 551 565 </span></dt> 552 566 <script>explorer.outline.writeEnabled = false;</script> 553 567 554 568 555 569 <dd><br><br> 556 570 </dd> 571 + 572 +<script>explorer.outline.writeEnabled = true;</script> 573 +<dt><span class="decl">alias 574 +<span class="currsymbol">dieast</span> 575 +<script>explorer.outline.addDecl('dieast');</script> 576 + 577 +; 578 +</span></dt> 579 +<script>explorer.outline.writeEnabled = false;</script> 580 + 581 + 582 +<dd><br><br> 583 +</dd> 557 584 </dl> 558 585 <script>explorer.outline.decSymbolLevel();</script> 559 586 560 587 561 588 </dd> 562 589 </dl> 563 590 <script>explorer.outline.decSymbolLevel();</script> 564 591 565 592 566 593 </td></tr> 567 594 <tr><td id="docfooter"> 568 595 Page was generated with 569 596 <img src="candydoc/img/candydoc.gif" style="vertical-align:middle; position:relative; top:-1px"> 570 - on Thu Nov 25 12:13:46 2010 597 + on Fri Nov 26 16:41:44 2010 571 598 572 599 </td></tr> 573 600 </table> 574 601 </div> 575 602 <script> 576 603 explorer.packageExplorer.addModule("index"); 577 604 explorer.packageExplorer.addModule("main");

Modified doc/eval.html from [694d60ab663f1749] to [2f7c4dc496477f14].

128 128 <script>explorer.outline.decSymbolLevel();</script> 129 129 130 130 131 131 </td></tr> 132 132 <tr><td id="docfooter"> 133 133 Page was generated with 134 134 <img src="candydoc/img/candydoc.gif" style="vertical-align:middle; position:relative; top:-1px"> 135 - on Thu Nov 25 12:13:46 2010 135 + on Fri Nov 26 16:41:45 2010 136 136 137 137 </td></tr> 138 138 </table> 139 139 </div> 140 140 <script> 141 141 explorer.packageExplorer.addModule("index"); 142 142 explorer.packageExplorer.addModule("main");

Modified doc/failure.html from [40513c24ea54cf40] to [73b33ccfe21436b6].

178 178 <script>explorer.outline.decSymbolLevel();</script> 179 179 180 180 181 181 </td></tr> 182 182 <tr><td id="docfooter"> 183 183 Page was generated with 184 184 <img src="candydoc/img/candydoc.gif" style="vertical-align:middle; position:relative; top:-1px"> 185 - on Thu Nov 25 12:13:47 2010 185 + on Fri Nov 26 16:41:45 2010 186 186 187 187 </td></tr> 188 188 </table> 189 189 </div> 190 190 <script> 191 191 explorer.packageExplorer.addModule("index"); 192 192 explorer.packageExplorer.addModule("main");

Modified doc/fresh.html from [c181d051b30c5ddc] to [9043a131c52ae01a].

46 46 <script>explorer.outline.decSymbolLevel();</script> 47 47 48 48 49 49 </td></tr> 50 50 <tr><td id="docfooter"> 51 51 Page was generated with 52 52 <img src="candydoc/img/candydoc.gif" style="vertical-align:middle; position:relative; top:-1px"> 53 - on Thu Nov 25 12:13:47 2010 53 + on Fri Nov 26 16:41:46 2010 54 54 55 55 </td></tr> 56 56 </table> 57 57 </div> 58 58 <script> 59 59 explorer.packageExplorer.addModule("index"); 60 60 explorer.packageExplorer.addModule("main");

Modified doc/index.html from [56b12828066b590e] to [dc242393e80db0b7].

89 89 90 90 <dd><pre> 91 91 ID ::= 適当に識別子っぽい文字列 92 92 LAYER ::= "@" ID 93 93 94 94 E ::= 95 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 "}" 96 + | DECL "=" E (";"|"in") E 97 + | DECL "(" PARAMS ")" "{" E "}" (";"|"in") E 98 + | DECL "=" E 99 + | DECL "(" PARAMS ")" "{" E "}" 100 + 101 + where DECL ::= ("var"|"let"|"def"|LAYER) ID | "@" LAYER 100 102 101 103 <font color=green># リテラル</font> 102 104 | INTEGER <font color=green># 非負整数</font> 103 105 | STRING <font color=green># "" でくくった文字列。\" と \\ は使える</font> 104 106 | "{" ENTRYS "}" <font color=green># テーブル</font> 105 107 | "fun" "(" PARAMS ")" "{" E "}" <font color=green># 無名関数</font> 106 108 | "λ" "(" PARAMS ")" "{" E "}" <font color=green># 無名関数</font> ................................................................................ 110 112 111 113 where ARGS ::= E "," ... "," E 112 114 PARAMS ::= (ID|LAYER)+ "," ... "," (ID|LAYER)+ 113 115 ENTRYS ::= ID ":" E "," ... "," ID ":" E 114 116 115 117 <font color=green># 演算子など</font> 116 118 | "(" E ")" <font color=green># ただの括弧</font> 119 + | "..." <font color=green># これを実行するとdie</font> 117 120 | E BINOP E <font color=green># 二項演算子いろいろ</font> 118 121 | E "." ID <font color=green># テーブルのフィールドアクセス</font> 119 122 | E ".?" ID <font color=green># テーブルにフィールドがあるか否か</font> 120 123 | E "{" ENTRYS "}" <font color=green># テーブル拡張</font> 121 124 | "if" E ("then"|":"|"then" ":") E 122 125 | "if" E ("then"|":"|"then" ":") E "else" ":"? E 123 126 ................................................................................ 285 288 以下のデータ型があります。 286 289 </p> 287 290 <ul> 288 291 <li>整数: <tt>0</tt>, <tt>123</tt>, <tt>456666666666666666666666666666666666666789</tt>, ...</li> 289 292 <li>文字列: <tt>"hello, world!"</tt>, ...</li> 290 293 <li>関数: <tt>fun(x){x+1}</tt></li> 291 294 <li>テーブル: <tt>{car: 1, cdr: {car: 2, cdr: {}}}</tt></li> 292 - <li>未定義値: (undefined。特殊なケースで作られます)</li> 295 + <li>未定義値: (特殊なケースで作られます。「レイヤ」の説明参照のこと。)</li> 293 296 </ul> 294 297 <p> 295 298 関数はいわゆる「クロージャ」です。静的スコープで外側の環境にアクセスできます。 296 299 テーブルはいわゆるプロトタイプチェーンを持っていて、 297 300 自分にないフィールドの場合は親に問い合わせが行く感じになっていますが、 298 301 フィールドの書き換えがないので、これは特に意味ないかもしれない…。 299 302 </p> ................................................................................ 325 328 when {car:x, cdr:{}}: lst 326 329 when {}: {} 327 330 } 328 331 </pre> 329 332 <p> 330 333 動かすときには、処理系がそれっぽい if-then-else に展開しています。 331 334 <tt>when</tt> を上から試していって、最初にマッチしたところを実行します。 335 +どれにもマッチしないとエラーでプログラム終了します。 332 336 </p> 333 337 <pre> 334 338 PAT ::= "_" <font color=green># ワイルドカード</font> 335 339 | ID <font color=green># 変数パターン</font> 336 340 | "{" ID ":" PAT "," ... "," ID : PAT "}" <font color=green># テーブルパターン</font> 337 341 | E <font color=green># 値パターン</font> 338 342 </pre> ................................................................................ 873 877 <script>explorer.outline.decSymbolLevel();</script> 874 878 875 879 876 880 </td></tr> 877 881 <tr><td id="docfooter"> 878 882 Page was generated with 879 883 <img src="candydoc/img/candydoc.gif" style="vertical-align:middle; position:relative; top:-1px"> 880 - on Fri Nov 26 10:02:52 2010 884 + on Fri Nov 26 16:41:52 2010 881 885 882 886 </td></tr> 883 887 </table> 884 888 </div> 885 889 <script> 886 890 explorer.packageExplorer.addModule("index"); 887 891 explorer.packageExplorer.addModule("main");

Modified doc/layer.html from [26ac57c2c82a7847] to [a4f78e6e3d8c715a].

37 37 38 38 <dd>Type for the layer ID<br><br> 39 39 40 40 </dd> 41 41 42 42 <script>explorer.outline.writeEnabled = true;</script> 43 43 <dt><span class="decl"> 44 -<span class="currsymbol">SystemLayer</span> 45 -<script>explorer.outline.addDecl('SystemLayer');</script> 44 +<span class="currsymbol">LiftLayer</span> 45 +<script>explorer.outline.addDecl('LiftLayer');</script> 46 + 47 +</span></dt> 48 +<script>explorer.outline.writeEnabled = false;</script> 49 + 50 + 51 +<dd>Predefined layer for storing lift functions<br><br> 52 + 53 +</dd> 54 + 55 +<script>explorer.outline.writeEnabled = true;</script> 56 +<dt><span class="decl"> 57 +<span class="currsymbol">NoopLayer</span> 58 +<script>explorer.outline.addDecl('NoopLayer');</script> 46 59 47 60 </span></dt> 48 61 <script>explorer.outline.writeEnabled = false;</script> 49 62 50 63 51 -<dd>Predefined layer for internal data<br><br> 64 +<dd>Predefined layer for just allocating a slot for table<br><br> 52 65 53 66 </dd> 54 67 55 68 <script>explorer.outline.writeEnabled = true;</script> 56 69 <dt><span class="decl"> 57 70 <span class="currsymbol">ValueLayer</span> 58 71 <script>explorer.outline.addDecl('ValueLayer');</script> ................................................................................ 150 163 <script>explorer.outline.decSymbolLevel();</script> 151 164 152 165 153 166 </td></tr> 154 167 <tr><td id="docfooter"> 155 168 Page was generated with 156 169 <img src="candydoc/img/candydoc.gif" style="vertical-align:middle; position:relative; top:-1px"> 157 - on Thu Nov 25 12:13:48 2010 170 + on Fri Nov 26 16:41:46 2010 158 171 159 172 </td></tr> 160 173 </table> 161 174 </div> 162 175 <script> 163 176 explorer.packageExplorer.addModule("index"); 164 177 explorer.packageExplorer.addModule("main");

Modified doc/lex.html from [a48f5afeb590d4a5] to [b039dcaea4552a8f].

307 307 <script>explorer.outline.decSymbolLevel();</script> 308 308 309 309 310 310 </td></tr> 311 311 <tr><td id="docfooter"> 312 312 Page was generated with 313 313 <img src="candydoc/img/candydoc.gif" style="vertical-align:middle; position:relative; top:-1px"> 314 - on Thu Nov 25 12:15:05 2010 314 + on Fri Nov 26 16:41:47 2010 315 315 316 316 </td></tr> 317 317 </table> 318 318 </div> 319 319 <script> 320 320 explorer.packageExplorer.addModule("index"); 321 321 explorer.packageExplorer.addModule("main");

Modified doc/main.html from [47fac5459c7c889e] to [d5dd76810e38b7f6].

62 62 <script>explorer.outline.decSymbolLevel();</script> 63 63 64 64 65 65 </td></tr> 66 66 <tr><td id="docfooter"> 67 67 Page was generated with 68 68 <img src="candydoc/img/candydoc.gif" style="vertical-align:middle; position:relative; top:-1px"> 69 - on Thu Nov 25 12:15:04 2010 69 + on Fri Nov 26 16:41:42 2010 70 70 71 71 </td></tr> 72 72 </table> 73 73 </div> 74 74 <script> 75 75 explorer.packageExplorer.addModule("index"); 76 76 explorer.packageExplorer.addModule("main");

Modified doc/parse.html from [bff389c3a8da9e67] to [e3b4b64f19f93798].

56 56 <script>explorer.outline.decSymbolLevel();</script> 57 57 58 58 59 59 </td></tr> 60 60 <tr><td id="docfooter"> 61 61 Page was generated with 62 62 <img src="candydoc/img/candydoc.gif" style="vertical-align:middle; position:relative; top:-1px"> 63 - on Thu Nov 25 12:15:05 2010 63 + on Fri Nov 26 16:41:48 2010 64 64 65 65 </td></tr> 66 66 </table> 67 67 </div> 68 68 <script> 69 69 explorer.packageExplorer.addModule("index"); 70 70 explorer.packageExplorer.addModule("main");

Modified doc/repl.html from [bbc57ada8c3877f2] to [f38bae3012b6b256].

156 156 <script>explorer.outline.decSymbolLevel();</script> 157 157 158 158 159 159 </td></tr> 160 160 <tr><td id="docfooter"> 161 161 Page was generated with 162 162 <img src="candydoc/img/candydoc.gif" style="vertical-align:middle; position:relative; top:-1px"> 163 - on Thu Nov 25 12:15:06 2010 163 + on Fri Nov 26 16:41:48 2010 164 164 165 165 </td></tr> 166 166 </table> 167 167 </div> 168 168 <script> 169 169 explorer.packageExplorer.addModule("index"); 170 170 explorer.packageExplorer.addModule("main");

Modified doc/runtime.html from [c03951e325eae3e8] to [fb971a54db14120e].

42 42 <script>explorer.outline.decSymbolLevel();</script> 43 43 44 44 45 45 </td></tr> 46 46 <tr><td id="docfooter"> 47 47 Page was generated with 48 48 <img src="candydoc/img/candydoc.gif" style="vertical-align:middle; position:relative; top:-1px"> 49 - on Thu Nov 25 12:30:12 2010 49 + on Fri Nov 26 16:41:49 2010 50 50 51 51 </td></tr> 52 52 </table> 53 53 </div> 54 54 <script> 55 55 explorer.packageExplorer.addModule("index"); 56 56 explorer.packageExplorer.addModule("main");

Modified doc/test.html from [3cf05b87d24962dc] to [65937464daabbe41].

143 143 <script>explorer.outline.decSymbolLevel();</script> 144 144 145 145 146 146 </td></tr> 147 147 <tr><td id="docfooter"> 148 148 Page was generated with 149 149 <img src="candydoc/img/candydoc.gif" style="vertical-align:middle; position:relative; top:-1px"> 150 - on Thu Nov 25 12:15:08 2010 150 + on Fri Nov 26 16:41:51 2010 151 151 152 152 </td></tr> 153 153 </table> 154 154 </div> 155 155 <script> 156 156 explorer.packageExplorer.addModule("index"); 157 157 explorer.packageExplorer.addModule("main");

Modified doc/tricks.html from [67d9668f00ab5789] to [66f1242be8634b07].

246 246 <script>explorer.outline.decSymbolLevel();</script> 247 247 248 248 249 249 </td></tr> 250 250 <tr><td id="docfooter"> 251 251 Page was generated with 252 252 <img src="candydoc/img/candydoc.gif" style="vertical-align:middle; position:relative; top:-1px"> 253 - on Thu Nov 25 12:15:09 2010 253 + on Fri Nov 26 16:41:52 2010 254 254 255 255 </td></tr> 256 256 </table> 257 257 </div> 258 258 <script> 259 259 explorer.packageExplorer.addModule("index"); 260 260 explorer.packageExplorer.addModule("main");

Modified doc/value.html from [c36eaebf49fd7834] to [4d6f8832c63e974c].

259 259 <script>explorer.outline.decSymbolLevel();</script> 260 260 261 261 262 262 </td></tr> 263 263 <tr><td id="docfooter"> 264 264 Page was generated with 265 265 <img src="candydoc/img/candydoc.gif" style="vertical-align:middle; position:relative; top:-1px"> 266 - on Thu Nov 25 12:15:07 2010 266 + on Fri Nov 26 16:41:50 2010 267 267 268 268 </td></tr> 269 269 </table> 270 270 </div> 271 271 <script> 272 272 explorer.packageExplorer.addModule("index"); 273 273 explorer.packageExplorer.addModule("main");

Modified doc/valueconv.html from [86d592872cc32a6a] to [e08638d4763e1185].

84 84 <script>explorer.outline.decSymbolLevel();</script> 85 85 86 86 87 87 </td></tr> 88 88 <tr><td id="docfooter"> 89 89 Page was generated with 90 90 <img src="candydoc/img/candydoc.gif" style="vertical-align:middle; position:relative; top:-1px"> 91 - on Thu Nov 25 12:15:47 2010 91 + on Fri Nov 26 16:41:51 2010 92 92 93 93 </td></tr> 94 94 </table> 95 95 </div> 96 96 <script> 97 97 explorer.packageExplorer.addModule("index"); 98 98 explorer.packageExplorer.addModule("main");

Modified index.dd from [80b16f2bd31d3d7f] to [a7325259b4f09952].

40 40 $(SECTION BNF, $(SECBODY 41 41 <pre> 42 42 ID ::= 適当に識別子っぽい文字列 43 43 LAYER ::= "@" ID 44 44 45 45 E ::= 46 46 $(D_COMMENT # 変数宣言) 47 - | ("var"|"let"|"def"|LAYER) ID "=" E (";"|"in") E 48 - | ("var"|"let"|"def"|LAYER) ID "(" PARAMS ")" "{" E "}" (";"|"in") E 49 - | ("var"|"let"|"def"|LAYER) ID "=" E 50 - | ("var"|"let"|"def"|LAYER) ID "(" PARAMS ")" "{" E "}" 47 + | DECL "=" E (";"|"in") E 48 + | DECL "(" PARAMS ")" "{" E "}" (";"|"in") E 49 + | DECL "=" E 50 + | DECL "(" PARAMS ")" "{" E "}" 51 + 52 + where DECL ::= ("var"|"let"|"def"|LAYER) ID | "@" LAYER 51 53 52 54 $(D_COMMENT # リテラル) 53 55 | INTEGER $(D_COMMENT # 非負整数) 54 56 | STRING $(D_COMMENT # "" でくくった文字列。\" と \\ は使える) 55 57 | "{" ENTRYS "}" $(D_COMMENT # テーブル) 56 58 | "fun" "(" PARAMS ")" "{" E "}" $(D_COMMENT # 無名関数) 57 59 | "λ" "(" PARAMS ")" "{" E "}" $(D_COMMENT # 無名関数) ................................................................................ 61 63 62 64 where ARGS ::= E "," ... "," E 63 65 PARAMS ::= (ID|LAYER)+ "," ... "," (ID|LAYER)+ 64 66 ENTRYS ::= ID ":" E "," ... "," ID ":" E 65 67 66 68 $(D_COMMENT # 演算子など) 67 69 | "(" E ")" $(D_COMMENT # ただの括弧) 70 + | "..." $(D_COMMENT # これを実行するとdie) 68 71 | E BINOP E $(D_COMMENT # 二項演算子いろいろ) 69 72 | E "." ID $(D_COMMENT # テーブルのフィールドアクセス) 70 73 | E ".?" ID $(D_COMMENT # テーブルにフィールドがあるか否か) 71 74 | E "{" ENTRYS "}" $(D_COMMENT # テーブル拡張) 72 75 | "if" E ("then"|":"|"then" ":") E 73 76 | "if" E ("then"|":"|"then" ":") E "else" ":"? E 74 77 ................................................................................ 200 203 以下のデータ型があります。 201 204 </p> 202 205 <ul> 203 206 <li>整数: <tt>0</tt>, <tt>123</tt>, <tt>456666666666666666666666666666666666666789</tt>, ...</li> 204 207 <li>文字列: <tt>"hello, world!"</tt>, ...</li> 205 208 <li>関数: <tt>fun(x){x+1}</tt></li> 206 209 <li>テーブル: <tt>{car: 1, cdr: {car: 2, cdr: {}}}</tt></li> 207 - <li>未定義値: (undefined。特殊なケースで作られます)</li> 210 + <li>未定義値: (特殊なケースで作られます。「レイヤ」の説明参照のこと。)</li> 208 211 </ul> 209 212 <p> 210 213 関数はいわゆる「クロージャ」です。静的スコープで外側の環境にアクセスできます。 211 214 テーブルはいわゆるプロトタイプチェーンを持っていて、 212 215 自分にないフィールドの場合は親に問い合わせが行く感じになっていますが、 213 216 フィールドの書き換えがないので、これは特に意味ないかもしれない…。 214 217 </p> ................................................................................ 232 235 when {car:x, cdr:{}}: lst 233 236 when {}: {} 234 237 } 235 238 </pre> 236 239 <p> 237 240 動かすときには、処理系がそれっぽい if-then-else に展開しています。 238 241 <tt>when</tt> を上から試していって、最初にマッチしたところを実行します。 242 +どれにもマッチしないとエラーでプログラム終了します。 239 243 </p> 240 244 <pre> 241 245 PAT ::= "_" $(D_COMMENT # ワイルドカード) 242 246 | ID $(D_COMMENT # 変数パターン) 243 247 | "{" ID ":" PAT "," ... "," ID : PAT "}" $(D_COMMENT # テーブルパターン) 244 248 | E $(D_COMMENT # 値パターン) 245 249 </pre>

Modified polemy/ast.d from [98d6a7a3304f7043] to [8ec2df800d3eb579].

89 89 class Fun : AST 90 90 { 91 91 Parameter[] params; /// 92 92 AST funbody; /// 93 93 94 94 mixin SimpleClass; 95 95 } 96 + 97 +/// AST node for deadend 98 +class Die : AST 99 +{ 100 + mixin SimpleClass; 101 +} 96 102 97 103 /// List of AST Types 98 104 99 -alias TypeTuple!(Int,Str,Var,Lay,Let,App,Fun) ListOfASTTypes; 105 +alias TypeTuple!(Int,Str,Var,Lay,Let,App,Fun,Die) ListOfASTTypes; 100 106 101 107 /// Handy Generator for AST nodes. To use this, mixin EasyAst; 102 108 103 109 /*mixin*/ 104 110 template EasyAST() 105 111 { 106 112 /// ................................................................................ 113 119 return genEast!Fun(array(map!((string x){return new Parameter(x,[]);})(xs)),ps); } 114 120 auto funp(Parameter[] xs, AST ps) { return genEast!Fun(xs,ps); } /// 115 121 alias genEast!Var var; /// 116 122 alias genEast!Lay lay; /// 117 123 alias genEast!Let let; /// 118 124 alias genEast!App call; /// 119 125 auto param(string name, string[] lay...) { return new Parameter(name, lay); } /// 126 + alias genEast!Die dieast; /// 120 127 }

Modified polemy/eval.d from [47affa2343c633ca] to [8d6e708eceba536a].

149 149 { 150 150 Value ri = eval(e.init, lay, newCtx); 151 151 if(e.name!="_") 152 152 newCtx.set(e.name, e.layer.empty ? lay : e.layer, ri); 153 153 return eval(e.expr, lay, newCtx, OverwriteCtx); 154 154 } 155 155 } 156 + 157 + Value eval( Die e, Layer lay, Table ctx, bool overwriteCtx=CascadeCtx ) 158 + { 159 + if( isMacroLayer(lay) ) 160 + return ast2table(e, (AST e){return eval(e,lay,ctx);}); 161 + if( isUserDefinedLayer(lay) ) 162 + return new UndefinedValue; 163 + throw genex!RuntimeException(e.pos, "undefined case"); 164 + } 156 165 157 166 private: 158 167 // little little bit incremental macro defining version. 159 168 // enables @macro foo(x)=... in ... foo ..., only at the top level of the 160 169 // interpreter and functions. better than nothing :P 161 170 Tuple!(Value,AST) macroAndEval( AST e_, Layer lay, Table ctx, bool overwriteCtx 162 171 , ref AST[void*] mandeCache) // [TODO] avoid assuming non-moving GC ................................................................................ 479 488 main() 480 489 `) ); 481 490 } 482 491 unittest 483 492 { 484 493 auto e = new Evaluator; 485 494 enrollRuntimeLibrary(e); 486 - assert_nothrow( e.evalString(`case 1`) ); 495 + assert_throw!RuntimeException( e.evalString(`case 1`) ); 487 496 assert_nothrow( e.evalString(`case 1 when 1: 2`) ); 488 497 489 498 // this is a shorthand for 490 499 // @macro x = fun(){} in @macro(x) 491 500 // so it is ok to fail, but it is really incovenient on REPL 492 501 assert_nothrow( e.evalString(`@macro x=fun(){}`) ); 493 502 } 503 + 504 +unittest 505 +{ 506 + auto e = new Evaluator; 507 + enrollRuntimeLibrary(e); 508 + assert_throw!RuntimeException( e.evalString(`...`) ); 509 + assert_eq( e.evalString(`@@foo(x){x}; @foo(...)`), new UndefinedValue ); 510 +}

Modified polemy/parse.d from [3ad9850246d5111f] to [45c4aa9e0628516e].

265 265 return new Str(pos, lex.front.str); 266 266 } 267 267 if( isNumber(lex.front.str) ) 268 268 { 269 269 scope(exit) lex.popFront; 270 270 return new Int(pos, BigInt(cast(string)lex.front.str)); 271 271 } 272 + if( tryEat("...") ) 273 + { 274 + return new Die(pos); 275 + } 272 276 if( tryEat("@") ) 273 277 { 274 278 auto lay = "@"~eatId("for layer ID"); 275 279 eat("(", "for layered execution"); 276 280 auto e = Body(); 277 281 eat(")", "after "~lay~"(..."); 278 282 return new Lay(pos, lay, e); ................................................................................ 356 360 return parsePatternMatchCases(casePos, pmVar, failBranchVar, 357 361 new Let(pos, tryThisBranchVar, [], 358 362 new Fun(pos,[],judgement), thenDoThis) 359 363 ); 360 364 } 361 365 else 362 366 { 363 - AST doNothing = new Fun(casePos,[], 364 - new Str(casePos, sprintf!"(pattern match failure:%s)"(casePos))); 367 + AST doNothing = new Fun(casePos,[], new Die(casePos)); 365 368 return new Let(casePos, tryThisBranchVar, [], doNothing, thenDoThis); 366 369 } 367 370 } 368 371 369 372 // hageshiku tenuki 370 373 abstract class SinglePattern 371 374 {