From 9e751bb8c0cdf771d34c839cb6591d892b8e62de Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Tue, 7 Mar 2017 01:41:48 -0800 Subject: 3761 --- html/lambda-to-mu.mu.html | 343 +++++++++++++++++++++++----------------------- 1 file changed, 172 insertions(+), 171 deletions(-) (limited to 'html/lambda-to-mu.mu.html') diff --git a/html/lambda-to-mu.mu.html b/html/lambda-to-mu.mu.html index 2aa7689b..92edd7c5 100644 --- a/html/lambda-to-mu.mu.html +++ b/html/lambda-to-mu.mu.html @@ -15,17 +15,18 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color a { text-decoration: none; } a:hover { text-decoration: underline; } * { font-size: 12pt; font-size: 1em; } -.muData { color: #ffff00; } -.muControl { color: #c0a020; } +.Conceal { color: #4e4e4e; } +.muScenario { color: #00af00; } .Special { color: #c00000; } .Delimiter { color: #800080; } .SalientComment { color: #00ffff; } .Constant { color: #00a0a0; } .LineNr { color: #444444; } -.CommentedCode { color: #6c6c6c; } -.Comment { color: #9090ff; } .muRecipe { color: #ff8700; } -.muScenario { color: #00af00; } +.Comment { color: #9090ff; } +.muControl { color: #c0a020; } +.CommentedCode { color: #6c6c6c; } +.muData { color: #ffff00; } --> @@ -71,12 +72,12 @@ if ('onhashchange' in window) { 9 10 scenario convert-lambda [ 11 run [ - 12 local-scope - 13 1:text/raw <- lambda-to-mu [(add a (multiply b c))] - 14 2:@:char/raw <- copy *1:text/raw + 12 ¦ local-scope + 13 ¦ 1:text/raw <- lambda-to-mu [(add a (multiply b c))] + 14 ¦ 2:@:char/raw <- copy *1:text/raw 15 ] 16 memory-should-contain [ - 17 2:array:character <- [t1 <- multiply b c + 17 ¦ 2:array:character <- [t1 <- multiply b c 18 result <- add a t1] 19 ] 20 ] @@ -136,8 +137,8 @@ if ('onhashchange' in window) { 74 10:bool/raw <- is-atom? x 75 11:bool/raw <- is-pair? x 76 memory-should-contain [ - 77 10 <- 1 - 78 11 <- 0 + 77 ¦ 10 <- 1 + 78 ¦ 11 <- 0 79 ] 80 ] 81 @@ -150,8 +151,8 @@ if ('onhashchange' in window) { 88 10:bool/raw <- is-atom? y 89 11:bool/raw <- is-pair? y 90 memory-should-contain [ - 91 10 <- 0 - 92 11 <- 1 + 91 ¦ 10 <- 0 + 92 ¦ 11 <- 1 93 ] 94 ] 95 @@ -168,7 +169,7 @@ if ('onhashchange' in window) { 106 x:&:cell <- new-atom [abc] 107 10:bool/raw <- atom-match? x, [abc] 108 memory-should-contain [ -109 10 <- 1 +109 ¦ 10 <- 1 110 ] 111 ] 112 @@ -213,8 +214,8 @@ if ('onhashchange' in window) { 151 10:&:cell/raw <- first x 152 11:&:cell/raw <- rest x 153 memory-should-contain [ -154 10 <- 0 # first is nil -155 11 <- 0 # rest is nil +154 ¦ 10 <- 0 # first is nil +155 ¦ 11 <- 0 # rest is nil 156 ] 157 ] 158 @@ -228,8 +229,8 @@ if ('onhashchange' in window) { 166 10:bool/raw <- equal x, x2 167 11:&:cell/raw <- rest y 168 memory-should-contain [ -169 10 <- 1 # first is correct -170 11 <- 0 # rest is nil +169 ¦ 10 <- 1 # first is correct +170 ¦ 11 <- 0 # rest is nil 171 ] 172 ] 173 @@ -252,84 +253,84 @@ if ('onhashchange' in window) { 190 return-if eof?, 0/nil 191 pair?:bool <- equal c, 40/open-paren 192 { -193 break-if pair? -194 # atom -195 buf:&:buffer <- new-buffer 30 -196 { -197 done?:bool <- end-of-stream? in -198 break-if done? -199 # stop before close paren or space -200 c:char <- peek in -201 done? <- equal c, 41/close-paren -202 break-if done? -203 done? <- space? c -204 break-if done? -205 c <- read in -206 buf <- append buf, c -207 loop -208 } -209 s:text <- buffer-to-array buf -210 out <- new-atom s +193 ¦ break-if pair? +194 ¦ # atom +195 ¦ buf:&:buffer <- new-buffer 30 +196 ¦ { +197 ¦ ¦ done?:bool <- end-of-stream? in +198 ¦ ¦ break-if done? +199 ¦ ¦ # stop before close paren or space +200 ¦ ¦ c:char <- peek in +201 ¦ ¦ done? <- equal c, 41/close-paren +202 ¦ ¦ break-if done? +203 ¦ ¦ done? <- space? c +204 ¦ ¦ break-if done? +205 ¦ ¦ c <- read in +206 ¦ ¦ buf <- append buf, c +207 ¦ ¦ loop +208 ¦ } +209 ¦ s:text <- buffer-to-array buf +210 ¦ out <- new-atom s 211 } 212 { -213 break-unless pair? -214 # pair -215 read in # skip the open-paren -216 out <- new cell:type # start out with nil -217 # read in first element of pair -218 { -219 end?:bool <- end-of-stream? in -220 not-end?:bool <- not end? -221 assert not-end?, [unbalanced '(' in expression] -222 c <- peek in -223 close-paren?:bool <- equal c, 41/close-paren -224 break-if close-paren? -225 first:&:cell, in <- parse in -226 *out <- merge 1/pair, first, 0/nil -227 } -228 # read in any remaining elements -229 curr:&:cell <- copy out -230 { -231 in <- skip-whitespace in -232 end?:bool <- end-of-stream? in -233 not-end?:bool <- not end? -234 assert not-end?, [unbalanced '(' in expression] -235 # termination check: ')' -236 c <- peek in -237 { -238 close-paren?:bool <- equal c, 41/close-paren -239 break-unless close-paren? -240 read in # skip ')' -241 break +end-pair -242 } -243 # still here? read next element of pair -244 next:&:cell, in <- parse in -245 is-dot?:bool <- atom-match? next, [.] -246 { -247 break-if is-dot? -248 next-curr:&:cell <- new-pair next, 0/nil -249 curr <- set-rest curr, next-curr -250 curr <- rest curr -251 } -252 { -253 break-unless is-dot? -254 # deal with dotted pair -255 in <- skip-whitespace in -256 c <- peek in -257 not-close-paren?:bool <- not-equal c, 41/close-paren -258 assert not-close-paren?, [')' cannot immediately follow '.'] -259 final:&:cell <- parse in -260 curr <- set-rest curr, final -261 # we're not gonna update curr, so better make sure the next iteration -262 # is going to end the pair -263 in <- skip-whitespace in -264 c <- peek in -265 close-paren?:bool <- equal c, 41/close-paren -266 assert close-paren?, ['.' must be followed by exactly one expression before ')'] -267 } -268 loop -269 } -270 +end-pair +213 ¦ break-unless pair? +214 ¦ # pair +215 ¦ read in # skip the open-paren +216 ¦ out <- new cell:type # start out with nil +217 ¦ # read in first element of pair +218 ¦ { +219 ¦ ¦ end?:bool <- end-of-stream? in +220 ¦ ¦ not-end?:bool <- not end? +221 ¦ ¦ assert not-end?, [unbalanced '(' in expression] +222 ¦ ¦ c <- peek in +223 ¦ ¦ close-paren?:bool <- equal c, 41/close-paren +224 ¦ ¦ break-if close-paren? +225 ¦ ¦ first:&:cell, in <- parse in +226 ¦ ¦ *out <- merge 1/pair, first, 0/nil +227 ¦ } +228 ¦ # read in any remaining elements +229 ¦ curr:&:cell <- copy out +230 ¦ { +231 ¦ ¦ in <- skip-whitespace in +232 ¦ ¦ end?:bool <- end-of-stream? in +233 ¦ ¦ not-end?:bool <- not end? +234 ¦ ¦ assert not-end?, [unbalanced '(' in expression] +235 ¦ ¦ # termination check: ')' +236 ¦ ¦ c <- peek in +237 ¦ ¦ { +238 ¦ ¦ ¦ close-paren?:bool <- equal c, 41/close-paren +239 ¦ ¦ ¦ break-unless close-paren? +240 ¦ ¦ ¦ read in # skip ')' +241 ¦ ¦ ¦ break +end-pair +242 ¦ ¦ } +243 ¦ ¦ # still here? read next element of pair +244 ¦ ¦ next:&:cell, in <- parse in +245 ¦ ¦ is-dot?:bool <- atom-match? next, [.] +246 ¦ ¦ { +247 ¦ ¦ ¦ break-if is-dot? +248 ¦ ¦ ¦ next-curr:&:cell <- new-pair next, 0/nil +249 ¦ ¦ ¦ curr <- set-rest curr, next-curr +250 ¦ ¦ ¦ curr <- rest curr +251 ¦ ¦ } +252 ¦ ¦ { +253 ¦ ¦ ¦ break-unless is-dot? +254 ¦ ¦ ¦ # deal with dotted pair +255 ¦ ¦ ¦ in <- skip-whitespace in +256 ¦ ¦ ¦ c <- peek in +257 ¦ ¦ ¦ not-close-paren?:bool <- not-equal c, 41/close-paren +258 ¦ ¦ ¦ assert not-close-paren?, [')' cannot immediately follow '.'] +259 ¦ ¦ ¦ final:&:cell <- parse in +260 ¦ ¦ ¦ curr <- set-rest curr, final +261 ¦ ¦ ¦ # we're not gonna update curr, so better make sure the next iteration +262 ¦ ¦ ¦ # is going to end the pair +263 ¦ ¦ ¦ in <- skip-whitespace in +264 ¦ ¦ ¦ c <- peek in +265 ¦ ¦ ¦ close-paren?:bool <- equal c, 41/close-paren +266 ¦ ¦ ¦ assert close-paren?, ['.' must be followed by exactly one expression before ')'] +267 ¦ ¦ } +268 ¦ ¦ loop +269 ¦ } +270 ¦ +end-pair 271 } 272 ] 273 @@ -337,13 +338,13 @@ if ('onhashchange' in window) { 275 local-scope 276 load-ingredients 277 { -278 done?:bool <- end-of-stream? in -279 return-if done?, 0/null -280 c:char <- peek in -281 space?:bool <- space? c -282 break-unless space? -283 read in # skip -284 loop +278 ¦ done?:bool <- end-of-stream? in +279 ¦ return-if done?, 0/null +280 ¦ c:char <- peek in +281 ¦ space?:bool <- space? c +282 ¦ break-unless space? +283 ¦ read in # skip +284 ¦ loop 285 } 286 ] 287 @@ -360,16 +361,16 @@ if ('onhashchange' in window) { 298 load-ingredients 299 # base case: empty cell 300 { -301 break-if x -302 buf <- append buf, [<>] -303 return +301 ¦ break-if x +302 ¦ buf <- append buf, [<>] +303 ¦ return 304 } 305 # base case: atom 306 { -307 s:text, atom?:bool <- maybe-convert *x, atom:variant -308 break-unless atom? -309 buf <- append buf, s -310 return +307 ¦ s:text, atom?:bool <- maybe-convert *x, atom:variant +308 ¦ break-unless atom? +309 ¦ buf <- append buf, s +310 ¦ return 311 } 312 # recursive case: pair 313 buf <- append buf, [< ] @@ -388,8 +389,8 @@ if ('onhashchange' in window) { 326 s2:text, 10:bool/raw <- maybe-convert *x, atom:variant 327 11:@:char/raw <- copy *s2 328 memory-should-contain [ -329 10 <- 1 # parse result is an atom -330 11:array:character <- [a] +329 ¦ 10 <- 1 # parse result is an atom +330 ¦ 11:array:character <- [a] 331 ] 332 ] 333 @@ -400,8 +401,8 @@ if ('onhashchange' in window) { 338 s2:text, 10:bool/raw <- maybe-convert *x, atom:variant 339 11:@:char/raw <- copy *s2 340 memory-should-contain [ -341 10 <- 1 # parse result is an atom -342 11:array:character <- [abc] +341 ¦ 10 <- 1 # parse result is an atom +342 ¦ 11:array:character <- [abc] 343 ] 344 ] 345 @@ -410,7 +411,7 @@ if ('onhashchange' in window) { 348 s:text <- new [(abc def)] 349 x:&:cell <- parse s 350 trace-should-contain [ -351 app/parse: < abc | < def | <> > > +351 ¦ app/parse: < abc | < def | <> > > 352 ] 353 10:bool/raw <- is-pair? x 354 x1:&:cell <- first x @@ -423,13 +424,13 @@ if ('onhashchange' in window) { 361 20:@:char/raw <- copy *s1 362 30:@:char/raw <- copy *s2 363 memory-should-contain [ -364 10 <- 1 # parse result is a pair -365 11 <- 1 # result.first is an atom -366 12 <- 1 # result.rest is a pair -367 13 <- 1 # result.rest.first is an atom -368 14 <- 0 # result.rest.rest is nil -369 20:array:character <- [abc] # result.first -370 30:array:character <- [def] # result.rest.first +364 ¦ 10 <- 1 # parse result is a pair +365 ¦ 11 <- 1 # result.first is an atom +366 ¦ 12 <- 1 # result.rest is a pair +367 ¦ 13 <- 1 # result.rest.first is an atom +368 ¦ 14 <- 0 # result.rest.rest is nil +369 ¦ 20:array:character <- [abc] # result.first +370 ¦ 30:array:character <- [def] # result.rest.first 371 ] 372 ] 373 @@ -438,7 +439,7 @@ if ('onhashchange' in window) { 376 s:text <- new [ ( abc def ) ] # extra spaces 377 x:&:cell <- parse s 378 trace-should-contain [ -379 app/parse: < abc | < def | <> > > +379 ¦ app/parse: < abc | < def | <> > > 380 ] 381 10:bool/raw <- is-pair? x 382 x1:&:cell <- first x @@ -451,13 +452,13 @@ if ('onhashchange' in window) { 389 20:@:char/raw <- copy *s1 390 30:@:char/raw <- copy *s2 391 memory-should-contain [ -392 10 <- 1 # parse result is a pair -393 11 <- 1 # result.first is an atom -394 12 <- 1 # result.rest is a pair -395 13 <- 1 # result.rest.first is an atom -396 14 <- 0 # result.rest.rest is nil -397 20:array:character <- [abc] # result.first -398 30:array:character <- [def] # result.rest.first +392 ¦ 10 <- 1 # parse result is a pair +393 ¦ 11 <- 1 # result.first is an atom +394 ¦ 12 <- 1 # result.rest is a pair +395 ¦ 13 <- 1 # result.rest.first is an atom +396 ¦ 14 <- 0 # result.rest.rest is nil +397 ¦ 20:array:character <- [abc] # result.first +398 ¦ 30:array:character <- [def] # result.rest.first 399 ] 400 ] 401 @@ -466,7 +467,7 @@ if ('onhashchange' in window) { 404 s:text <- new [(abc def ghi)] 405 x:&:cell <- parse s 406 trace-should-contain [ -407 app/parse: < abc | < def | < ghi | <> > > > +407 ¦ app/parse: < abc | < def | < ghi | <> > > > 408 ] 409 10:bool/raw <- is-pair? x 410 x1:&:cell <- first x @@ -484,16 +485,16 @@ if ('onhashchange' in window) { 422 30:@:char/raw <- copy *s2 423 40:@:char/raw <- copy *s3 424 memory-should-contain [ -425 10 <- 1 # parse result is a pair -426 11 <- 1 # result.first is an atom -427 12 <- 1 # result.rest is a pair -428 13 <- 1 # result.rest.first is an atom -429 14 <- 1 # result.rest.rest is a pair -430 15 <- 1 # result.rest.rest.first is an atom -431 16 <- 0 # result.rest.rest.rest is nil -432 20:array:character <- [abc] # result.first -433 30:array:character <- [def] # result.rest.first -434 40:array:character <- [ghi] # result.rest.rest +425 ¦ 10 <- 1 # parse result is a pair +426 ¦ 11 <- 1 # result.first is an atom +427 ¦ 12 <- 1 # result.rest is a pair +428 ¦ 13 <- 1 # result.rest.first is an atom +429 ¦ 14 <- 1 # result.rest.rest is a pair +430 ¦ 15 <- 1 # result.rest.rest.first is an atom +431 ¦ 16 <- 0 # result.rest.rest.rest is nil +432 ¦ 20:array:character <- [abc] # result.first +433 ¦ 30:array:character <- [def] # result.rest.first +434 ¦ 40:array:character <- [ghi] # result.rest.rest 435 ] 436 ] 437 @@ -502,7 +503,7 @@ if ('onhashchange' in window) { 440 s:text <- new [((abc))] 441 x:&:cell <- parse s 442 trace-should-contain [ -443 app/parse: < < abc | <> > | <> > +443 ¦ app/parse: < < abc | <> > | <> > 444 ] 445 10:bool/raw <- is-pair? x 446 x1:&:cell <- first x @@ -513,12 +514,12 @@ if ('onhashchange' in window) { 451 14:&:cell/raw <- rest x 452 20:@:char/raw <- copy *s1 453 memory-should-contain [ -454 10 <- 1 # parse result is a pair -455 11 <- 1 # result.first is a pair -456 12 <- 1 # result.first.first is an atom -457 13 <- 0 # result.first.rest is nil -458 14 <- 0 # result.rest is nil -459 20:array:character <- [abc] # result.first.first +454 ¦ 10 <- 1 # parse result is a pair +455 ¦ 11 <- 1 # result.first is a pair +456 ¦ 12 <- 1 # result.first.first is an atom +457 ¦ 13 <- 0 # result.first.rest is nil +458 ¦ 14 <- 0 # result.rest is nil +459 ¦ 20:array:character <- [abc] # result.first.first 460 ] 461 ] 462 @@ -527,7 +528,7 @@ if ('onhashchange' in window) { 465 s:text <- new [((abc) def)] 466 x:&:cell <- parse s 467 trace-should-contain [ -468 app/parse: < < abc | <> > | < def | <> > > +468 ¦ app/parse: < < abc | <> > | < def | <> > > 469 ] 470 10:bool/raw <- is-pair? x 471 x1:&:cell <- first x @@ -542,14 +543,14 @@ if ('onhashchange' in window) { 480 20:@:char/raw <- copy *s1 481 30:@:char/raw <- copy *s2 482 memory-should-contain [ -483 10 <- 1 # parse result is a pair -484 11 <- 1 # result.first is a pair -485 12 <- 1 # result.first.first is an atom -486 13 <- 0 # result.first.rest is nil -487 14 <- 1 # result.rest.first is an atom -488 15 <- 0 # result.rest.rest is nil -489 20:array:character <- [abc] # result.first.first -490 30:array:character <- [def] # result.rest.first +483 ¦ 10 <- 1 # parse result is a pair +484 ¦ 11 <- 1 # result.first is a pair +485 ¦ 12 <- 1 # result.first.first is an atom +486 ¦ 13 <- 0 # result.first.rest is nil +487 ¦ 14 <- 1 # result.rest.first is an atom +488 ¦ 15 <- 0 # result.rest.rest is nil +489 ¦ 20:array:character <- [abc] # result.first.first +490 ¦ 30:array:character <- [def] # result.rest.first 491 ] 492 ] 493 @@ -582,7 +583,7 @@ if ('onhashchange' in window) { 520 s:text <- new [(abc . def)] 521 x:&:cell <- parse s 522 trace-should-contain [ -523 app/parse: < abc | def > +523 ¦ app/parse: < abc | def > 524 ] 525 10:bool/raw <- is-pair? x 526 x1:&:cell <- first x @@ -592,12 +593,12 @@ if ('onhashchange' in window) { 530 20:@:char/raw <- copy *s1 531 30:@:char/raw <- copy *s2 532 memory-should-contain [ -533 # parses to < abc | def > -534 10 <- 1 # parse result is a pair -535 11 <- 1 # result.first is an atom -536 12 <- 1 # result.rest is an atom -537 20:array:character <- [abc] # result.first -538 30:array:character <- [def] # result.rest +533 ¦ # parses to < abc | def > +534 ¦ 10 <- 1 # parse result is a pair +535 ¦ 11 <- 1 # result.first is an atom +536 ¦ 12 <- 1 # result.rest is an atom +537 ¦ 20:array:character <- [abc] # result.first +538 ¦ 30:array:character <- [def] # result.rest 539 ] 540 ] 541 @@ -606,7 +607,7 @@ if ('onhashchange' in window) { 544 s:text <- new [(abc def . ghi)] 545 x:&:cell <- parse s 546 trace-should-contain [ -547 app/parse: < abc | < def | ghi > > +547 ¦ app/parse: < abc | < def | ghi > > 548 ] 549 10:bool/raw <- is-pair? x 550 x1:&:cell <- first x @@ -621,14 +622,14 @@ if ('onhashchange' in window) { 559 30:@:char/raw <- copy *s2 560 40:@:char/raw <- copy *s3 561 memory-should-contain [ -562 10 <- 1 # parse result is a pair -563 11 <- 1 # result.first is an atom -564 12 <- 1 # result.rest is a pair -565 13 <- 1 # result.rest.first is an atom -566 14 <- 1 # result.rest.rest is an atom -567 20:array:character <- [abc] # result.first -568 30:array:character <- [def] # result.rest.first -569 40:array:character <- [ghi] # result.rest.rest +562 ¦ 10 <- 1 # parse result is a pair +563 ¦ 11 <- 1 # result.first is an atom +564 ¦ 12 <- 1 # result.rest is a pair +565 ¦ 13 <- 1 # result.rest.first is an atom +566 ¦ 14 <- 1 # result.rest.rest is an atom +567 ¦ 20:array:character <- [abc] # result.first +568 ¦ 30:array:character <- [def] # result.rest.first +569 ¦ 40:array:character <- [ghi] # result.rest.rest 570 ] 571 ] 572 -- cgit 1.4.1-2-gfad0