diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2016-10-23 19:45:36 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2016-10-23 19:56:28 -0700 |
commit | f918675c8b11adb80a83000a3a984e4ff3bdcf1b (patch) | |
tree | 2472316e3bf536e0bad76751c5f3504d029b8215 /html/lambda-to-mu.mu.html | |
parent | af7349d50c40e0604c9bb1e9a50aa1c3c0d407d8 (diff) | |
download | mu-f918675c8b11adb80a83000a3a984e4ff3bdcf1b.tar.gz |
3569
Update syntax highlighting to not color numeric locations like literals.
Diffstat (limited to 'html/lambda-to-mu.mu.html')
-rw-r--r-- | html/lambda-to-mu.mu.html | 532 |
1 files changed, 266 insertions, 266 deletions
diff --git a/html/lambda-to-mu.mu.html b/html/lambda-to-mu.mu.html index 98b868fc..b4d44558 100644 --- a/html/lambda-to-mu.mu.html +++ b/html/lambda-to-mu.mu.html @@ -40,11 +40,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> convert-lambda [ run [ <span class="Constant">local-scope</span> - <span class="Constant">1</span>:text/<span class="Special">raw <- </span>lambda-to-mu <span class="Constant">[(add a (multiply b c))]</span> - <span class="Constant">2</span>:@:char/<span class="Special">raw <- </span>copy *<span class="Constant">1</span>:text/<span class="Special">raw</span> + 1:text/<span class="Special">raw</span> <span class="Special"><-</span> lambda-to-mu <span class="Constant">[(add a (multiply b c))]</span> + 2:@:char/<span class="Special">raw</span> <span class="Special"><-</span> copy *1:text/<span class="Special">raw</span> ] memory-should-contain [ - <span class="Constant">2</span>:@:char<span class="Special"> <- </span><span class="Constant">[t1 <- multiply b c</span> + 2:@:char <span class="Special"><-</span> <span class="Constant">[t1 <- multiply b c</span> <span class="Constant">result <- add a t1]</span> ] ] @@ -52,9 +52,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">def</span> lambda-to-mu in:text<span class="muRecipe"> -> </span>out:text [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - out<span class="Special"> <- </span>copy <span class="Constant">0</span> - cells:&:cell<span class="Special"> <- </span>parse in - out<span class="Special"> <- </span>to-mu cells + out <span class="Special"><-</span> copy<span class="Constant"> 0</span> + cells:&:cell <span class="Special"><-</span> parse in + out <span class="Special"><-</span> to-mu cells ] <span class="Comment"># 'parse' will turn lambda expressions into trees made of cells</span> @@ -72,132 +72,132 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">def</span> new-atom name:text<span class="muRecipe"> -> </span>result:&:cell [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - result<span class="Special"> <- </span>new <span class="Constant">cell:type</span> - *result<span class="Special"> <- </span>merge <span class="Constant">0/tag:atom</span>, name + result <span class="Special"><-</span> new <span class="Constant">cell:type</span> + *result <span class="Special"><-</span> merge <span class="Constant">0/tag:atom</span>, name ] <span class="muRecipe">def</span> new-pair a:&:cell, b:&:cell<span class="muRecipe"> -> </span>result:&:cell [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - result<span class="Special"> <- </span>new <span class="Constant">cell:type</span> - *result<span class="Special"> <- </span>merge <span class="Constant">1/tag:pair</span>, a/first, b/rest + result <span class="Special"><-</span> new <span class="Constant">cell:type</span> + *result <span class="Special"><-</span> merge <span class="Constant">1/tag:pair</span>, a/first, b/rest ] <span class="muRecipe">def</span> is-atom? x:&:cell<span class="muRecipe"> -> </span>result:bool [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="muControl">reply-unless</span> x, <span class="Constant">0/false</span> - _, result<span class="Special"> <- </span>maybe-convert *x, <span class="Constant">atom:variant</span> + _, result <span class="Special"><-</span> maybe-convert *x, <span class="Constant">atom:variant</span> ] <span class="muRecipe">def</span> is-pair? x:&:cell<span class="muRecipe"> -> </span>result:bool [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="muControl">reply-unless</span> x, <span class="Constant">0/false</span> - _, result<span class="Special"> <- </span>maybe-convert *x, <span class="Constant">pair:variant</span> + _, result <span class="Special"><-</span> maybe-convert *x, <span class="Constant">pair:variant</span> ] <span class="muScenario">scenario</span> atom-is-not-pair [ <span class="Constant">local-scope</span> - s:text<span class="Special"> <- </span>new <span class="Constant">[a]</span> - x:&:cell<span class="Special"> <- </span>new-atom s - <span class="Constant">10</span>:bool/<span class="Special">raw <- </span>is-atom? x - <span class="Constant">11</span>:bool/<span class="Special">raw <- </span>is-pair? x + s:text <span class="Special"><-</span> new <span class="Constant">[a]</span> + x:&:cell <span class="Special"><-</span> new-atom s + 10:bool/<span class="Special">raw</span> <span class="Special"><-</span> is-atom? x + 11:bool/<span class="Special">raw</span> <span class="Special"><-</span> is-pair? x memory-should-contain [ - <span class="Constant">10</span><span class="Special"> <- </span><span class="Constant">1</span> - <span class="Constant">11</span><span class="Special"> <- </span><span class="Constant">0</span> + <span class="Constant"> 10</span> <span class="Special"><-</span><span class="Constant"> 1</span> + <span class="Constant"> 11</span> <span class="Special"><-</span><span class="Constant"> 0</span> ] ] <span class="muScenario">scenario</span> pair-is-not-atom [ <span class="Constant">local-scope</span> <span class="Comment"># construct (a . nil)</span> - s:text<span class="Special"> <- </span>new <span class="Constant">[a]</span> - x:&:cell<span class="Special"> <- </span>new-atom s - y:&:cell<span class="Special"> <- </span>new-pair x, <span class="Constant">0/nil</span> - <span class="Constant">10</span>:bool/<span class="Special">raw <- </span>is-atom? y - <span class="Constant">11</span>:bool/<span class="Special">raw <- </span>is-pair? y + s:text <span class="Special"><-</span> new <span class="Constant">[a]</span> + x:&:cell <span class="Special"><-</span> new-atom s + y:&:cell <span class="Special"><-</span> new-pair x, <span class="Constant">0/nil</span> + 10:bool/<span class="Special">raw</span> <span class="Special"><-</span> is-atom? y + 11:bool/<span class="Special">raw</span> <span class="Special"><-</span> is-pair? y memory-should-contain [ - <span class="Constant">10</span><span class="Special"> <- </span><span class="Constant">0</span> - <span class="Constant">11</span><span class="Special"> <- </span><span class="Constant">1</span> + <span class="Constant"> 10</span> <span class="Special"><-</span><span class="Constant"> 0</span> + <span class="Constant"> 11</span> <span class="Special"><-</span><span class="Constant"> 1</span> ] ] <span class="muRecipe">def</span> atom-match? x:&:cell, pat:text<span class="muRecipe"> -> </span>result:bool [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - s:text, is-atom?:bool<span class="Special"> <- </span>maybe-convert *x, <span class="Constant">atom:variant</span> + s:text, is-atom?:bool <span class="Special"><-</span> maybe-convert *x, <span class="Constant">atom:variant</span> <span class="muControl">reply-unless</span> is-atom?, <span class="Constant">0/false</span> - result<span class="Special"> <- </span>equal pat, s + result <span class="Special"><-</span> equal pat, s ] <span class="muScenario">scenario</span> atom-match [ <span class="Constant">local-scope</span> - x:&:cell<span class="Special"> <- </span>new-atom <span class="Constant">[abc]</span> - <span class="Constant">10</span>:bool/<span class="Special">raw <- </span>atom-match? x, <span class="Constant">[abc]</span> + x:&:cell <span class="Special"><-</span> new-atom <span class="Constant">[abc]</span> + 10:bool/<span class="Special">raw</span> <span class="Special"><-</span> atom-match? x, <span class="Constant">[abc]</span> memory-should-contain [ - <span class="Constant">10</span><span class="Special"> <- </span><span class="Constant">1</span> + <span class="Constant"> 10</span> <span class="Special"><-</span><span class="Constant"> 1</span> ] ] <span class="muRecipe">def</span> first x:&:cell<span class="muRecipe"> -> </span>result:&:cell [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - pair:pair, pair?:bool<span class="Special"> <- </span>maybe-convert *x, <span class="Constant">pair:variant</span> + pair:pair, pair?:bool <span class="Special"><-</span> maybe-convert *x, <span class="Constant">pair:variant</span> <span class="muControl">reply-unless</span> pair?, <span class="Constant">0/nil</span> - result<span class="Special"> <- </span>get pair, <span class="Constant">first:offset</span> + result <span class="Special"><-</span> get pair, <span class="Constant">first:offset</span> ] <span class="muRecipe">def</span> rest x:&:cell<span class="muRecipe"> -> </span>result:&:cell [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - pair:pair, pair?:bool<span class="Special"> <- </span>maybe-convert *x, <span class="Constant">pair:variant</span> + pair:pair, pair?:bool <span class="Special"><-</span> maybe-convert *x, <span class="Constant">pair:variant</span> <span class="muControl">reply-unless</span> pair?, <span class="Constant">0/nil</span> - result<span class="Special"> <- </span>get pair, <span class="Constant">rest:offset</span> + result <span class="Special"><-</span> get pair, <span class="Constant">rest:offset</span> ] <span class="muRecipe">def</span> set-first base:&:cell, new-first:&:cell<span class="muRecipe"> -> </span>base:&:cell [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - pair:pair, is-pair?:bool<span class="Special"> <- </span>maybe-convert *base, <span class="Constant">pair:variant</span> + pair:pair, is-pair?:bool <span class="Special"><-</span> maybe-convert *base, <span class="Constant">pair:variant</span> <span class="muControl">reply-unless</span> is-pair? - pair<span class="Special"> <- </span>put pair, <span class="Constant">first:offset</span>, new-first - *base<span class="Special"> <- </span>merge <span class="Constant">1/pair</span>, pair + pair <span class="Special"><-</span> put pair, <span class="Constant">first:offset</span>, new-first + *base <span class="Special"><-</span> merge <span class="Constant">1/pair</span>, pair ] <span class="muRecipe">def</span> set-rest base:&:cell, new-rest:&:cell<span class="muRecipe"> -> </span>base:&:cell [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - pair:pair, is-pair?:bool<span class="Special"> <- </span>maybe-convert *base, <span class="Constant">pair:variant</span> + pair:pair, is-pair?:bool <span class="Special"><-</span> maybe-convert *base, <span class="Constant">pair:variant</span> <span class="muControl">reply-unless</span> is-pair? - pair<span class="Special"> <- </span>put pair, <span class="Constant">rest:offset</span>, new-rest - *base<span class="Special"> <- </span>merge <span class="Constant">1/pair</span>, pair + pair <span class="Special"><-</span> put pair, <span class="Constant">rest:offset</span>, new-rest + *base <span class="Special"><-</span> merge <span class="Constant">1/pair</span>, pair ] <span class="muScenario">scenario</span> cell-operations-on-atom [ <span class="Constant">local-scope</span> - s:text<span class="Special"> <- </span>new <span class="Constant">[a]</span> - x:&:cell<span class="Special"> <- </span>new-atom s - <span class="Constant">10</span>:&:cell/<span class="Special">raw <- </span>first x - <span class="Constant">11</span>:&:cell/<span class="Special">raw <- </span>rest x + s:text <span class="Special"><-</span> new <span class="Constant">[a]</span> + x:&:cell <span class="Special"><-</span> new-atom s + 10:&:cell/<span class="Special">raw</span> <span class="Special"><-</span> first x + 11:&:cell/<span class="Special">raw</span> <span class="Special"><-</span> rest x memory-should-contain [ - <span class="Constant">10</span><span class="Special"> <- </span><span class="Constant">0</span> <span class="Comment"># first is nil</span> - <span class="Constant">11</span><span class="Special"> <- </span><span class="Constant">0</span> <span class="Comment"># rest is nil</span> + <span class="Constant"> 10</span> <span class="Special"><-</span><span class="Constant"> 0</span> <span class="Comment"># first is nil</span> + <span class="Constant"> 11</span> <span class="Special"><-</span><span class="Constant"> 0</span> <span class="Comment"># rest is nil</span> ] ] <span class="muScenario">scenario</span> cell-operations-on-pair [ <span class="Constant">local-scope</span> <span class="Comment"># construct (a . nil)</span> - s:text<span class="Special"> <- </span>new <span class="Constant">[a]</span> - x:&:cell<span class="Special"> <- </span>new-atom s - y:&:cell<span class="Special"> <- </span>new-pair x, <span class="Constant">0/nil</span> - x2:&:cell<span class="Special"> <- </span>first y - <span class="Constant">10</span>:bool/<span class="Special">raw <- </span>equal x, x2 - <span class="Constant">11</span>:&:cell/<span class="Special">raw <- </span>rest y + s:text <span class="Special"><-</span> new <span class="Constant">[a]</span> + x:&:cell <span class="Special"><-</span> new-atom s + y:&:cell <span class="Special"><-</span> new-pair x, <span class="Constant">0/nil</span> + x2:&:cell <span class="Special"><-</span> first y + 10:bool/<span class="Special">raw</span> <span class="Special"><-</span> equal x, x2 + 11:&:cell/<span class="Special">raw</span> <span class="Special"><-</span> rest y memory-should-contain [ - <span class="Constant">10</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># first is correct</span> - <span class="Constant">11</span><span class="Special"> <- </span><span class="Constant">0</span> <span class="Comment"># rest is nil</span> + <span class="Constant"> 10</span> <span class="Special"><-</span><span class="Constant"> 1</span> <span class="Comment"># first is correct</span> + <span class="Constant"> 11</span> <span class="Special"><-</span><span class="Constant"> 0</span> <span class="Comment"># rest is nil</span> ] ] @@ -206,93 +206,93 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">def</span> parse in:text<span class="muRecipe"> -> </span>out:&:cell [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - s:&:stream:char<span class="Special"> <- </span>new-stream in - out, s<span class="Special"> <- </span>parse s - trace <span class="Constant">2</span>, <span class="Constant">[app/parse]</span>, out + s:&:stream:char <span class="Special"><-</span> new-stream in + out, s <span class="Special"><-</span> parse s + trace<span class="Constant"> 2</span>, <span class="Constant">[app/parse]</span>, out ] <span class="muRecipe">def</span> parse in:&:stream:char<span class="muRecipe"> -> </span>out:&:cell, in:&:stream:char [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Comment"># skip whitespace</span> - in<span class="Special"> <- </span>skip-whitespace in - c:char, eof?:bool<span class="Special"> <- </span>peek in + in <span class="Special"><-</span> skip-whitespace in + c:char, eof?:bool <span class="Special"><-</span> peek in <span class="muControl">reply-if</span> eof?, <span class="Constant">0/nil</span> - pair?:bool<span class="Special"> <- </span>equal c, <span class="Constant">40/open-paren</span> + pair?:bool <span class="Special"><-</span> equal c, <span class="Constant">40/open-paren</span> <span class="Delimiter">{</span> <span class="muControl">break-if</span> pair? <span class="Comment"># atom</span> - buf:&:buffer<span class="Special"> <- </span>new-buffer <span class="Constant">30</span> + buf:&:buffer <span class="Special"><-</span> new-buffer<span class="Constant"> 30</span> <span class="Delimiter">{</span> - done?:bool<span class="Special"> <- </span>end-of-stream? in + done?:bool <span class="Special"><-</span> end-of-stream? in <span class="muControl">break-if</span> done? <span class="Comment"># stop before close paren or space</span> - c:char<span class="Special"> <- </span>peek in - done?<span class="Special"> <- </span>equal c, <span class="Constant">41/close-paren</span> + c:char <span class="Special"><-</span> peek in + done? <span class="Special"><-</span> equal c, <span class="Constant">41/close-paren</span> <span class="muControl">break-if</span> done? - done?<span class="Special"> <- </span>space? c + done? <span class="Special"><-</span> space? c <span class="muControl">break-if</span> done? - c<span class="Special"> <- </span>read in - buf<span class="Special"> <- </span>append buf, c + c <span class="Special"><-</span> read in + buf <span class="Special"><-</span> append buf, c <span class="muControl">loop</span> <span class="Delimiter">}</span> - s:text<span class="Special"> <- </span>buffer-to-array buf - out<span class="Special"> <- </span>new-atom s + s:text <span class="Special"><-</span> buffer-to-array buf + out <span class="Special"><-</span> new-atom s <span class="Delimiter">}</span> <span class="Delimiter">{</span> <span class="muControl">break-unless</span> pair? <span class="Comment"># pair</span> read in <span class="Comment"># skip the open-paren</span> - out<span class="Special"> <- </span>new <span class="Constant">cell:type</span> <span class="Comment"># start out with nil</span> + out <span class="Special"><-</span> new <span class="Constant">cell:type</span> <span class="Comment"># start out with nil</span> <span class="Comment"># read in first element of pair</span> <span class="Delimiter">{</span> - end?:bool<span class="Special"> <- </span>end-of-stream? in - not-end?:bool<span class="Special"> <- </span>not end? + end?:bool <span class="Special"><-</span> end-of-stream? in + not-end?:bool <span class="Special"><-</span> not end? assert not-end?, <span class="Constant">[unbalanced '(' in expression]</span> - c<span class="Special"> <- </span>peek in - close-paren?:bool<span class="Special"> <- </span>equal c, <span class="Constant">41/close-paren</span> + c <span class="Special"><-</span> peek in + close-paren?:bool <span class="Special"><-</span> equal c, <span class="Constant">41/close-paren</span> <span class="muControl">break-if</span> close-paren? - first:&:cell, in<span class="Special"> <- </span>parse in - *out<span class="Special"> <- </span>merge <span class="Constant">1/pair</span>, first, <span class="Constant">0/nil</span> + first:&:cell, in <span class="Special"><-</span> parse in + *out <span class="Special"><-</span> merge <span class="Constant">1/pair</span>, first, <span class="Constant">0/nil</span> <span class="Delimiter">}</span> <span class="Comment"># read in any remaining elements</span> - curr:&:cell<span class="Special"> <- </span>copy out + curr:&:cell <span class="Special"><-</span> copy out <span class="Delimiter">{</span> - in<span class="Special"> <- </span>skip-whitespace in - end?:bool<span class="Special"> <- </span>end-of-stream? in - not-end?:bool<span class="Special"> <- </span>not end? + in <span class="Special"><-</span> skip-whitespace in + end?:bool <span class="Special"><-</span> end-of-stream? in + not-end?:bool <span class="Special"><-</span> not end? assert not-end?, <span class="Constant">[unbalanced '(' in expression]</span> <span class="Comment"># termination check: ')'</span> - c<span class="Special"> <- </span>peek in + c <span class="Special"><-</span> peek in <span class="Delimiter">{</span> - close-paren?:bool<span class="Special"> <- </span>equal c, <span class="Constant">41/close-paren</span> + close-paren?:bool <span class="Special"><-</span> equal c, <span class="Constant">41/close-paren</span> <span class="muControl">break-unless</span> close-paren? read in <span class="Comment"># skip ')'</span> <span class="muControl">break</span> <span class="Constant">+end-pair</span> <span class="Delimiter">}</span> <span class="Comment"># still here? read next element of pair</span> - next:&:cell, in<span class="Special"> <- </span>parse in - is-dot?:bool<span class="Special"> <- </span>atom-match? next, <span class="Constant">[.]</span> + next:&:cell, in <span class="Special"><-</span> parse in + is-dot?:bool <span class="Special"><-</span> atom-match? next, <span class="Constant">[.]</span> <span class="Delimiter">{</span> <span class="muControl">break-if</span> is-dot? - next-curr:&:cell<span class="Special"> <- </span>new-pair next, <span class="Constant">0/nil</span> - curr<span class="Special"> <- </span>set-rest curr, next-curr - curr<span class="Special"> <- </span>rest curr + next-curr:&:cell <span class="Special"><-</span> new-pair next, <span class="Constant">0/nil</span> + curr <span class="Special"><-</span> set-rest curr, next-curr + curr <span class="Special"><-</span> rest curr <span class="Delimiter">}</span> <span class="Delimiter">{</span> <span class="muControl">break-unless</span> is-dot? <span class="Comment"># deal with dotted pair</span> - in<span class="Special"> <- </span>skip-whitespace in - c<span class="Special"> <- </span>peek in - not-close-paren?:bool<span class="Special"> <- </span>not-equal c, <span class="Constant">41/close-paren</span> + in <span class="Special"><-</span> skip-whitespace in + c <span class="Special"><-</span> peek in + not-close-paren?:bool <span class="Special"><-</span> not-equal c, <span class="Constant">41/close-paren</span> assert not-close-paren?, <span class="Constant">[')' cannot immediately follow '.']</span> - final:&:cell<span class="Special"> <- </span>parse in - curr<span class="Special"> <- </span>set-rest curr, final + final:&:cell <span class="Special"><-</span> parse in + curr <span class="Special"><-</span> set-rest curr, final <span class="Comment"># we're not gonna update curr, so better make sure the next iteration</span> <span class="Comment"># is going to end the pair</span> - in<span class="Special"> <- </span>skip-whitespace in - c<span class="Special"> <- </span>peek in - close-paren?:bool<span class="Special"> <- </span>equal c, <span class="Constant">41/close-paren</span> + in <span class="Special"><-</span> skip-whitespace in + c <span class="Special"><-</span> peek in + close-paren?:bool <span class="Special"><-</span> equal c, <span class="Constant">41/close-paren</span> assert close-paren?, <span class="Constant">['.' must be followed by exactly one expression before ')']</span> <span class="Delimiter">}</span> <span class="muControl">loop</span> @@ -305,10 +305,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Delimiter">{</span> - done?:bool<span class="Special"> <- </span>end-of-stream? in + done?:bool <span class="Special"><-</span> end-of-stream? in <span class="muControl">reply-if</span> done?, <span class="Constant">0/null</span> - c:char<span class="Special"> <- </span>peek in - space?:bool<span class="Special"> <- </span>space? c + c:char <span class="Special"><-</span> peek in + space?:bool <span class="Special"><-</span> space? c <span class="muControl">break-unless</span> space? read in <span class="Comment"># skip</span> <span class="muControl">loop</span> @@ -318,9 +318,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">def</span> to-text x:&:cell<span class="muRecipe"> -> </span>out:text [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - buf:&:buffer<span class="Special"> <- </span>new-buffer <span class="Constant">30</span> - buf<span class="Special"> <- </span>to-buffer x, buf - out<span class="Special"> <- </span>buffer-to-array buf + buf:&:buffer <span class="Special"><-</span> new-buffer<span class="Constant"> 30</span> + buf <span class="Special"><-</span> to-buffer x, buf + out <span class="Special"><-</span> buffer-to-array buf ] <span class="muRecipe">def</span> to-buffer x:&:cell, buf:&:buffer<span class="muRecipe"> -> </span>buf:&:buffer [ @@ -329,195 +329,195 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># base case: empty cell</span> <span class="Delimiter">{</span> <span class="muControl">break-if</span> x - buf<span class="Special"> <- </span>append buf, <span class="Constant">[<>]</span> + buf <span class="Special"><-</span> append buf, <span class="Constant">[<>]</span> <span class="muControl">reply</span> <span class="Delimiter">}</span> <span class="Comment"># base case: atom</span> <span class="Delimiter">{</span> - s:text, atom?:bool<span class="Special"> <- </span>maybe-convert *x, <span class="Constant">atom:variant</span> + s:text, atom?:bool <span class="Special"><-</span> maybe-convert *x, <span class="Constant">atom:variant</span> <span class="muControl">break-unless</span> atom? - buf<span class="Special"> <- </span>append buf, s + buf <span class="Special"><-</span> append buf, s <span class="muControl">reply</span> <span class="Delimiter">}</span> <span class="Comment"># recursive case: pair</span> - buf<span class="Special"> <- </span>append buf, <span class="Constant">[< ]</span> - first:&:cell<span class="Special"> <- </span>first x - buf<span class="Special"> <- </span>to-buffer first, buf - buf<span class="Special"> <- </span>append buf, <span class="Constant">[ | ]</span> - rest:&:cell<span class="Special"> <- </span>rest x - buf<span class="Special"> <- </span>to-buffer rest, buf - buf<span class="Special"> <- </span>append buf, <span class="Constant">[ >]</span> + buf <span class="Special"><-</span> append buf, <span class="Constant">[< ]</span> + first:&:cell <span class="Special"><-</span> first x + buf <span class="Special"><-</span> to-buffer first, buf + buf <span class="Special"><-</span> append buf, <span class="Constant">[ | ]</span> + rest:&:cell <span class="Special"><-</span> rest x + buf <span class="Special"><-</span> to-buffer rest, buf + buf <span class="Special"><-</span> append buf, <span class="Constant">[ >]</span> ] <span class="muScenario">scenario</span> parse-single-letter-atom [ <span class="Constant">local-scope</span> - s:text<span class="Special"> <- </span>new <span class="Constant">[a]</span> - x:&:cell<span class="Special"> <- </span>parse s - s2:text, <span class="Constant">10</span>:bool/<span class="Special">raw <- </span>maybe-convert *x, <span class="Constant">atom:variant</span> - <span class="Constant">11</span>:@:char/<span class="Special">raw <- </span>copy *s2 + s:text <span class="Special"><-</span> new <span class="Constant">[a]</span> + x:&:cell <span class="Special"><-</span> parse s + s2:text, 10:bool/<span class="Special">raw</span> <span class="Special"><-</span> maybe-convert *x, <span class="Constant">atom:variant</span> + 11:@:char/<span class="Special">raw</span> <span class="Special"><-</span> copy *s2 memory-should-contain [ - <span class="Constant">10</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># parse result is an atom</span> - <span class="Constant">11</span>:@:char<span class="Special"> <- </span><span class="Constant">[a]</span> + <span class="Constant"> 10</span> <span class="Special"><-</span><span class="Constant"> 1</span> <span class="Comment"># parse result is an atom</span> + 11:@:char <span class="Special"><-</span> <span class="Constant">[a]</span> ] ] <span class="muScenario">scenario</span> parse-atom [ <span class="Constant">local-scope</span> - s:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> - x:&:cell<span class="Special"> <- </span>parse s - s2:text, <span class="Constant">10</span>:bool/<span class="Special">raw <- </span>maybe-convert *x, <span class="Constant">atom:variant</span> - <span class="Constant">11</span>:@:char/<span class="Special">raw <- </span>copy *s2 + s:text <span class="Special"><-</span> new <span class="Constant">[abc]</span> + x:&:cell <span class="Special"><-</span> parse s + s2:text, 10:bool/<span class="Special">raw</span> <span class="Special"><-</span> maybe-convert *x, <span class="Constant">atom:variant</span> + 11:@:char/<span class="Special">raw</span> <span class="Special"><-</span> copy *s2 memory-should-contain [ - <span class="Constant">10</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># parse result is an atom</span> - <span class="Constant">11</span>:@:char<span class="Special"> <- </span><span class="Constant">[abc]</span> + <span class="Constant"> 10</span> <span class="Special"><-</span><span class="Constant"> 1</span> <span class="Comment"># parse result is an atom</span> + 11:@:char <span class="Special"><-</span> <span class="Constant">[abc]</span> ] ] <span class="muScenario">scenario</span> parse-list-of-two-atoms [ <span class="Constant">local-scope</span> - s:text<span class="Special"> <- </span>new <span class="Constant">[(abc def)]</span> - x:&:cell<span class="Special"> <- </span>parse s + s:text <span class="Special"><-</span> new <span class="Constant">[(abc def)]</span> + x:&:cell <span class="Special"><-</span> parse s trace-should-contain [ app/parse: <span class="Constant"><</span> abc <span class="Constant">|</span> <span class="Constant"><</span> def <span class="Constant">|</span> <span class="Constant"><></span> <span class="Constant">></span> <span class="Constant">></span> ] - <span class="Constant">10</span>:bool/<span class="Special">raw <- </span>is-pair? x - x1:&:cell<span class="Special"> <- </span>first x - x2:&:cell<span class="Special"> <- </span>rest x - s1:text, <span class="Constant">11</span>:bool/<span class="Special">raw <- </span>maybe-convert *x1, <span class="Constant">atom:variant</span> - <span class="Constant">12</span>:bool/<span class="Special">raw <- </span>is-pair? x2 - x3:&:cell<span class="Special"> <- </span>first x2 - s2:text, <span class="Constant">13</span>:bool/<span class="Special">raw <- </span>maybe-convert *x3, <span class="Constant">atom:variant</span> - <span class="Constant">14</span>:&:cell/<span class="Special">raw <- </span>rest x2 - <span class="Constant">20</span>:@:char/<span class="Special">raw <- </span>copy *s1 - <span class="Constant">30</span>:@:char/<span class="Special">raw <- </span>copy *s2 + 10:bool/<span class="Special">raw</span> <span class="Special"><-</span> is-pair? x + x1:&:cell <span class="Special"><-</span> first x + x2:&:cell <span class="Special"><-</span> rest x + s1:text, 11:bool/<span class="Special">raw</span> <span class="Special"><-</span> maybe-convert *x1, <span class="Constant">atom:variant</span> + 12:bool/<span class="Special">raw</span> <span class="Special"><-</span> is-pair? x2 + x3:&:cell <span class="Special"><-</span> first x2 + s2:text, 13:bool/<span class="Special">raw</span> <span class="Special"><-</span> maybe-convert *x3, <span class="Constant">atom:variant</span> + 14:&:cell/<span class="Special">raw</span> <span class="Special"><-</span> rest x2 + 20:@:char/<span class="Special">raw</span> <span class="Special"><-</span> copy *s1 + 30:@:char/<span class="Special">raw</span> <span class="Special"><-</span> copy *s2 memory-should-contain [ - <span class="Constant">10</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># parse result is a pair</span> - <span class="Constant">11</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># result.first is an atom</span> - <span class="Constant">12</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># result.rest is a pair</span> - <span class="Constant">13</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># result.rest.first is an atom</span> - <span class="Constant">14</span><span class="Special"> <- </span><span class="Constant">0</span> <span class="Comment"># result.rest.rest is nil</span> - <span class="Constant">20</span>:@:char<span class="Special"> <- </span><span class="Constant">[abc]</span> <span class="Comment"># result.first</span> - <span class="Constant">30</span>:@:char<span class="Special"> <- </span><span class="Constant">[def]</span> <span class="Comment"># result.rest.first</span> + <span class="Constant"> 10</span> <span class="Special"><-</span><span class="Constant"> 1</span> <span class="Comment"># parse result is a pair</span> + <span class="Constant"> 11</span> <span class="Special"><-</span><span class="Constant"> 1</span> <span class="Comment"># result.first is an atom</span> + <span class="Constant"> 12</span> <span class="Special"><-</span><span class="Constant"> 1</span> <span class="Comment"># result.rest is a pair</span> + <span class="Constant"> 13</span> <span class="Special"><-</span><span class="Constant"> 1</span> <span class="Comment"># result.rest.first is an atom</span> + <span class="Constant"> 14</span> <span class="Special"><-</span><span class="Constant"> 0</span> <span class="Comment"># result.rest.rest is nil</span> + 20:@:char <span class="Special"><-</span> <span class="Constant">[abc]</span> <span class="Comment"># result.first</span> + 30:@:char <span class="Special"><-</span> <span class="Constant">[def]</span> <span class="Comment"># result.rest.first</span> ] ] <span class="muScenario">scenario</span> parse-list-with-extra-spaces [ <span class="Constant">local-scope</span> - s:text<span class="Special"> <- </span>new <span class="Constant">[ ( abc def ) ]</span> <span class="Comment"># extra spaces</span> - x:&:cell<span class="Special"> <- </span>parse s + s:text <span class="Special"><-</span> new <span class="Constant">[ ( abc def ) ]</span> <span class="Comment"># extra spaces</span> + x:&:cell <span class="Special"><-</span> parse s trace-should-contain [ app/parse: <span class="Constant"><</span> abc <span class="Constant">|</span> <span class="Constant"><</span> def <span class="Constant">|</span> <span class="Constant"><></span> <span class="Constant">></span> <span class="Constant">></span> ] - <span class="Constant">10</span>:bool/<span class="Special">raw <- </span>is-pair? x - x1:&:cell<span class="Special"> <- </span>first x - x2:&:cell<span class="Special"> <- </span>rest x - s1:text, <span class="Constant">11</span>:bool/<span class="Special">raw <- </span>maybe-convert *x1, <span class="Constant">atom:variant</span> - <span class="Constant">12</span>:bool/<span class="Special">raw <- </span>is-pair? x2 - x3:&:cell<span class="Special"> <- </span>first x2 - s2:text, <span class="Constant">13</span>:bool/<span class="Special">raw <- </span>maybe-convert *x3, <span class="Constant">atom:variant</span> - <span class="Constant">14</span>:&:cell/<span class="Special">raw <- </span>rest x2 - <span class="Constant">20</span>:@:char/<span class="Special">raw <- </span>copy *s1 - <span class="Constant">30</span>:@:char/<span class="Special">raw <- </span>copy *s2 + 10:bool/<span class="Special">raw</span> <span class="Special"><-</span> is-pair? x + x1:&:cell <span class="Special"><-</span> first x + x2:&:cell <span class="Special"><-</span> rest x + s1:text, 11:bool/<span class="Special">raw</span> <span class="Special"><-</span> maybe-convert *x1, <span class="Constant">atom:variant</span> + 12:bool/<span class="Special">raw</span> <span class="Special"><-</span> is-pair? x2 + x3:&:cell <span class="Special"><-</span> first x2 + s2:text, 13:bool/<span class="Special">raw</span> <span class="Special"><-</span> maybe-convert *x3, <span class="Constant">atom:variant</span> + 14:&:cell/<span class="Special">raw</span> <span class="Special"><-</span> rest x2 + 20:@:char/<span class="Special">raw</span> <span class="Special"><-</span> copy *s1 + 30:@:char/<span class="Special">raw</span> <span class="Special"><-</span> copy *s2 memory-should-contain [ - <span class="Constant">10</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># parse result is a pair</span> - <span class="Constant">11</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># result.first is an atom</span> - <span class="Constant">12</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># result.rest is a pair</span> - <span class="Constant">13</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># result.rest.first is an atom</span> - <span class="Constant">14</span><span class="Special"> <- </span><span class="Constant">0</span> <span class="Comment"># result.rest.rest is nil</span> - <span class="Constant">20</span>:@:char<span class="Special"> <- </span><span class="Constant">[abc]</span> <span class="Comment"># result.first</span> - <span class="Constant">30</span>:@:char<span class="Special"> <- </span><span class="Constant">[def]</span> <span class="Comment"># result.rest.first</span> + <span class="Constant"> 10</span> <span class="Special"><-</span><span class="Constant"> 1</span> <span class="Comment"># parse result is a pair</span> + <span class="Constant"> 11</span> <span class="Special"><-</span><span class="Constant"> 1</span> <span class="Comment"># result.first is an atom</span> + <span class="Constant"> 12</span> <span class="Special"><-</span><span class="Constant"> 1</span> <span class="Comment"># result.rest is a pair</span> + <span class="Constant"> 13</span> <span class="Special"><-</span><span class="Constant"> 1</span> <span class="Comment"># result.rest.first is an atom</span> + <span class="Constant"> 14</span> <span class="Special"><-</span><span class="Constant"> 0</span> <span class="Comment"># result.rest.rest is nil</span> + 20:@:char <span class="Special"><-</span> <span class="Constant">[abc]</span> <span class="Comment"># result.first</span> + 30:@:char <span class="Special"><-</span> <span class="Constant">[def]</span> <span class="Comment"># result.rest.first</span> ] ] <span class="muScenario">scenario</span> parse-list-of-more-than-two-atoms [ <span class="Constant">local-scope</span> - s:text<span class="Special"> <- </span>new <span class="Constant">[(abc def ghi)]</span> - x:&:cell<span class="Special"> <- </span>parse s + s:text <span class="Special"><-</span> new <span class="Constant">[(abc def ghi)]</span> + x:&:cell <span class="Special"><-</span> parse s trace-should-contain [ app/parse: <span class="Constant"><</span> abc <span class="Constant">|</span> <span class="Constant"><</span> def <span class="Constant">|</span> <span class="Constant"><</span> ghi <span class="Constant">|</span> <span class="Constant"><></span> <span class="Constant">></span> <span class="Constant">></span> <span class="Constant">></span> ] - <span class="Constant">10</span>:bool/<span class="Special">raw <- </span>is-pair? x - x1:&:cell<span class="Special"> <- </span>first x - x2:&:cell<span class="Special"> <- </span>rest x - s1:text, <span class="Constant">11</span>:bool/<span class="Special">raw <- </span>maybe-convert *x1, <span class="Constant">atom:variant</span> - <span class="Constant">12</span>:bool/<span class="Special">raw <- </span>is-pair? x2 - x3:&:cell<span class="Special"> <- </span>first x2 - s2:text, <span class="Constant">13</span>:bool/<span class="Special">raw <- </span>maybe-convert *x3, <span class="Constant">atom:variant</span> - x4:&:cell<span class="Special"> <- </span>rest x2 - <span class="Constant">14</span>:bool/<span class="Special">raw <- </span>is-pair? x4 - x5:&:cell<span class="Special"> <- </span>first x4 - s3:text, <span class="Constant">15</span>:bool/<span class="Special">raw <- </span>maybe-convert *x5, <span class="Constant">atom:variant</span> - <span class="Constant">16</span>:&:cell/<span class="Special">raw <- </span>rest x4 - <span class="Constant">20</span>:@:char/<span class="Special">raw <- </span>copy *s1 - <span class="Constant">30</span>:@:char/<span class="Special">raw <- </span>copy *s2 - <span class="Constant">40</span>:@:char/<span class="Special">raw <- </span>copy *s3 + 10:bool/<span class="Special">raw</span> <span class="Special"><-</span> is-pair? x + x1:&:cell <span class="Special"><-</span> first x + x2:&:cell <span class="Special"><-</span> rest x + s1:text, 11:bool/<span class="Special">raw</span> <span class="Special"><-</span> maybe-convert *x1, <span class="Constant">atom:variant</span> + 12:bool/<span class="Special">raw</span> <span class="Special"><-</span> is-pair? x2 + x3:&:cell <span class="Special"><-</span> first x2 + s2:text, 13:bool/<span class="Special">raw</span> <span class="Special"><-</span> maybe-convert *x3, <span class="Constant">atom:variant</span> + x4:&:cell <span class="Special"><-</span> rest x2 + 14:bool/<span class="Special">raw</span> <span class="Special"><-</span> is-pair? x4 + x5:&:cell <span class="Special"><-</span> first x4 + s3:text, 15:bool/<span class="Special">raw</span> <span class="Special"><-</span> maybe-convert *x5, <span class="Constant">atom:variant</span> + 16:&:cell/<span class="Special">raw</span> <span class="Special"><-</span> rest x4 + 20:@:char/<span class="Special">raw</span> <span class="Special"><-</span> copy *s1 + 30:@:char/<span class="Special">raw</span> <span class="Special"><-</span> copy *s2 + 40:@:char/<span class="Special">raw</span> <span class="Special"><-</span> copy *s3 memory-should-contain [ - <span class="Constant">10</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># parse result is a pair</span> - <span class="Constant">11</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># result.first is an atom</span> - <span class="Constant">12</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># result.rest is a pair</span> - <span class="Constant">13</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># result.rest.first is an atom</span> - <span class="Constant">14</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># result.rest.rest is a pair</span> - <span class="Constant">15</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># result.rest.rest.first is an atom</span> - <span class="Constant">16</span><span class="Special"> <- </span><span class="Constant">0</span> <span class="Comment"># result.rest.rest.rest is nil</span> - <span class="Constant">20</span>:@:char<span class="Special"> <- </span><span class="Constant">[abc]</span> <span class="Comment"># result.first</span> - <span class="Constant">30</span>:@:char<span class="Special"> <- </span><span class="Constant">[def]</span> <span class="Comment"># result.rest.first</span> - <span class="Constant">40</span>:@:char<span class="Special"> <- </span><span class="Constant">[ghi]</span> <span class="Comment"># result.rest.rest</span> + <span class="Constant"> 10</span> <span class="Special"><-</span><span class="Constant"> 1</span> <span class="Comment"># parse result is a pair</span> + <span class="Constant"> 11</span> <span class="Special"><-</span><span class="Constant"> 1</span> <span class="Comment"># result.first is an atom</span> + <span class="Constant"> 12</span> <span class="Special"><-</span><span class="Constant"> 1</span> <span class="Comment"># result.rest is a pair</span> + <span class="Constant"> 13</span> <span class="Special"><-</span><span class="Constant"> 1</span> <span class="Comment"># result.rest.first is an atom</span> + <span class="Constant"> 14</span> <span class="Special"><-</span><span class="Constant"> 1</span> <span class="Comment"># result.rest.rest is a pair</span> + <span class="Constant"> 15</span> <span class="Special"><-</span><span class="Constant"> 1</span> <span class="Comment"># result.rest.rest.first is an atom</span> + <span class="Constant"> 16</span> <span class="Special"><-</span><span class="Constant"> 0</span> <span class="Comment"># result.rest.rest.rest is nil</span> + 20:@:char <span class="Special"><-</span> <span class="Constant">[abc]</span> <span class="Comment"># result.first</span> + 30:@:char <span class="Special"><-</span> <span class="Constant">[def]</span> <span class="Comment"># result.rest.first</span> + 40:@:char <span class="Special"><-</span> <span class="Constant">[ghi]</span> <span class="Comment"># result.rest.rest</span> ] ] <span class="muScenario">scenario</span> parse-nested-list [ <span class="Constant">local-scope</span> - s:text<span class="Special"> <- </span>new <span class="Constant">[((abc))]</span> - x:&:cell<span class="Special"> <- </span>parse s + s:text <span class="Special"><-</span> new <span class="Constant">[((abc))]</span> + x:&:cell <span class="Special"><-</span> parse s trace-should-contain [ app/parse: <span class="Constant"><</span> <span class="Constant"><</span> abc <span class="Constant">|</span> <span class="Constant"><></span> <span class="Constant">></span> <span class="Constant">|</span> <span class="Constant"><></span> <span class="Constant">></span> ] - <span class="Constant">10</span>:bool/<span class="Special">raw <- </span>is-pair? x - x1:&:cell<span class="Special"> <- </span>first x - <span class="Constant">11</span>:bool/<span class="Special">raw <- </span>is-pair? x - x2:&:cell<span class="Special"> <- </span>first x1 - s1:text, <span class="Constant">12</span>:bool/<span class="Special">raw <- </span>maybe-convert *x2, <span class="Constant">atom:variant</span> - <span class="Constant">13</span>:&:cell/<span class="Special">raw <- </span>rest x1 - <span class="Constant">14</span>:&:cell/<span class="Special">raw <- </span>rest x - <span class="Constant">20</span>:@:char/<span class="Special">raw <- </span>copy *s1 + 10:bool/<span class="Special">raw</span> <span class="Special"><-</span> is-pair? x + x1:&:cell <span class="Special"><-</span> first x + 11:bool/<span class="Special">raw</span> <span class="Special"><-</span> is-pair? x + x2:&:cell <span class="Special"><-</span> first x1 + s1:text, 12:bool/<span class="Special">raw</span> <span class="Special"><-</span> maybe-convert *x2, <span class="Constant">atom:variant</span> + 13:&:cell/<span class="Special">raw</span> <span class="Special"><-</span> rest x1 + 14:&:cell/<span class="Special">raw</span> <span class="Special"><-</span> rest x + 20:@:char/<span class="Special">raw</span> <span class="Special"><-</span> copy *s1 memory-should-contain [ - <span class="Constant">10</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># parse result is a pair</span> - <span class="Constant">11</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># result.first is a pair</span> - <span class="Constant">12</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># result.first.first is an atom</span> - <span class="Constant">13</span><span class="Special"> <- </span><span class="Constant">0</span> <span class="Comment"># result.first.rest is nil</span> - <span class="Constant">14</span><span class="Special"> <- </span><span class="Constant">0</span> <span class="Comment"># result.rest is nil</span> - <span class="Constant">20</span>:@:char<span class="Special"> <- </span><span class="Constant">[abc]</span> <span class="Comment"># result.first.first</span> + <span class="Constant"> 10</span> <span class="Special"><-</span><span class="Constant"> 1</span> <span class="Comment"># parse result is a pair</span> + <span class="Constant"> 11</span> <span class="Special"><-</span><span class="Constant"> 1</span> <span class="Comment"># result.first is a pair</span> + <span class="Constant"> 12</span> <span class="Special"><-</span><span class="Constant"> 1</span> <span class="Comment"># result.first.first is an atom</span> + <span class="Constant"> 13</span> <span class="Special"><-</span><span class="Constant"> 0</span> <span class="Comment"># result.first.rest is nil</span> + <span class="Constant"> 14</span> <span class="Special"><-</span><span class="Constant"> 0</span> <span class="Comment"># result.rest is nil</span> + 20:@:char <span class="Special"><-</span> <span class="Constant">[abc]</span> <span class="Comment"># result.first.first</span> ] ] <span class="muScenario">scenario</span> parse-nested-list-2 [ <span class="Constant">local-scope</span> - s:text<span class="Special"> <- </span>new <span class="Constant">[((abc) def)]</span> - x:&:cell<span class="Special"> <- </span>parse s + s:text <span class="Special"><-</span> new <span class="Constant">[((abc) def)]</span> + x:&:cell <span class="Special"><-</span> parse s trace-should-contain [ app/parse: <span class="Constant"><</span> <span class="Constant"><</span> abc <span class="Constant">|</span> <span class="Constant"><></span> <span class="Constant">></span> <span class="Constant">|</span> <span class="Constant"><</span> def <span class="Constant">|</span> <span class="Constant"><></span> <span class="Constant">></span> <span class="Constant">></span> ] - <span class="Constant">10</span>:bool/<span class="Special">raw <- </span>is-pair? x - x1:&:cell<span class="Special"> <- </span>first x - <span class="Constant">11</span>:bool/<span class="Special">raw <- </span>is-pair? x - x2:&:cell<span class="Special"> <- </span>first x1 - s1:text, <span class="Constant">12</span>:bool/<span class="Special">raw <- </span>maybe-convert *x2, <span class="Constant">atom:variant</span> - <span class="Constant">13</span>:&:cell/<span class="Special">raw <- </span>rest x1 - x3:&:cell<span class="Special"> <- </span>rest x - x4:&:cell<span class="Special"> <- </span>first x3 - s2:text, <span class="Constant">14</span>:bool/<span class="Special">raw <- </span>maybe-convert *x4, <span class="Constant">atom:variant</span> - <span class="Constant">15</span>:&:cell/<span class="Special">raw <- </span>rest x3 - <span class="Constant">20</span>:@:char/<span class="Special">raw <- </span>copy *s1 - <span class="Constant">30</span>:@:char/<span class="Special">raw <- </span>copy *s2 + 10:bool/<span class="Special">raw</span> <span class="Special"><-</span> is-pair? x + x1:&:cell <span class="Special"><-</span> first x + 11:bool/<span class="Special">raw</span> <span class="Special"><-</span> is-pair? x + x2:&:cell <span class="Special"><-</span> first x1 + s1:text, 12:bool/<span class="Special">raw</span> <span class="Special"><-</span> maybe-convert *x2, <span class="Constant">atom:variant</span> + 13:&:cell/<span class="Special">raw</span> <span class="Special"><-</span> rest x1 + x3:&:cell <span class="Special"><-</span> rest x + x4:&:cell <span class="Special"><-</span> first x3 + s2:text, 14:bool/<span class="Special">raw</span> <span class="Special"><-</span> maybe-convert *x4, <span class="Constant">atom:variant</span> + 15:&:cell/<span class="Special">raw</span> <span class="Special"><-</span> rest x3 + 20:@:char/<span class="Special">raw</span> <span class="Special"><-</span> copy *s1 + 30:@:char/<span class="Special">raw</span> <span class="Special"><-</span> copy *s2 memory-should-contain [ - <span class="Constant">10</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># parse result is a pair</span> - <span class="Constant">11</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># result.first is a pair</span> - <span class="Constant">12</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># result.first.first is an atom</span> - <span class="Constant">13</span><span class="Special"> <- </span><span class="Constant">0</span> <span class="Comment"># result.first.rest is nil</span> - <span class="Constant">14</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># result.rest.first is an atom</span> - <span class="Constant">15</span><span class="Special"> <- </span><span class="Constant">0</span> <span class="Comment"># result.rest.rest is nil</span> - <span class="Constant">20</span>:@:char<span class="Special"> <- </span><span class="Constant">[abc]</span> <span class="Comment"># result.first.first</span> - <span class="Constant">30</span>:@:char<span class="Special"> <- </span><span class="Constant">[def]</span> <span class="Comment"># result.rest.first</span> + <span class="Constant"> 10</span> <span class="Special"><-</span><span class="Constant"> 1</span> <span class="Comment"># parse result is a pair</span> + <span class="Constant"> 11</span> <span class="Special"><-</span><span class="Constant"> 1</span> <span class="Comment"># result.first is a pair</span> + <span class="Constant"> 12</span> <span class="Special"><-</span><span class="Constant"> 1</span> <span class="Comment"># result.first.first is an atom</span> + <span class="Constant"> 13</span> <span class="Special"><-</span><span class="Constant"> 0</span> <span class="Comment"># result.first.rest is nil</span> + <span class="Constant"> 14</span> <span class="Special"><-</span><span class="Constant"> 1</span> <span class="Comment"># result.rest.first is an atom</span> + <span class="Constant"> 15</span> <span class="Special"><-</span><span class="Constant"> 0</span> <span class="Comment"># result.rest.rest is nil</span> + 20:@:char <span class="Special"><-</span> <span class="Constant">[abc]</span> <span class="Comment"># result.first.first</span> + 30:@:char <span class="Special"><-</span> <span class="Constant">[def]</span> <span class="Comment"># result.rest.first</span> ] ] @@ -547,56 +547,56 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> parse-dotted-list-of-two-atoms [ <span class="Constant">local-scope</span> - s:text<span class="Special"> <- </span>new <span class="Constant">[(abc . def)]</span> - x:&:cell<span class="Special"> <- </span>parse s + s:text <span class="Special"><-</span> new <span class="Constant">[(abc . def)]</span> + x:&:cell <span class="Special"><-</span> parse s trace-should-contain [ app/parse: <span class="Constant"><</span> abc <span class="Constant">|</span> def <span class="Constant">></span> ] - <span class="Constant">10</span>:bool/<span class="Special">raw <- </span>is-pair? x - x1:&:cell<span class="Special"> <- </span>first x - x2:&:cell<span class="Special"> <- </span>rest x - s1:text, <span class="Constant">11</span>:bool/<span class="Special">raw <- </span>maybe-convert *x1, <span class="Constant">atom:variant</span> - s2:text, <span class="Constant">12</span>:bool/<span class="Special">raw <- </span>maybe-convert *x2, <span class="Constant">atom:variant</span> - <span class="Constant">20</span>:@:char/<span class="Special">raw <- </span>copy *s1 - <span class="Constant">30</span>:@:char/<span class="Special">raw <- </span>copy *s2 + 10:bool/<span class="Special">raw</span> <span class="Special"><-</span> is-pair? x + x1:&:cell <span class="Special"><-</span> first x + x2:&:cell <span class="Special"><-</span> rest x + s1:text, 11:bool/<span class="Special">raw</span> <span class="Special"><-</span> maybe-convert *x1, <span class="Constant">atom:variant</span> + s2:text, 12:bool/<span class="Special">raw</span> <span class="Special"><-</span> maybe-convert *x2, <span class="Constant">atom:variant</span> + 20:@:char/<span class="Special">raw</span> <span class="Special"><-</span> copy *s1 + 30:@:char/<span class="Special">raw</span> <span class="Special"><-</span> copy *s2 memory-should-contain [ <span class="Comment"># parses to < abc | def ></span> - <span class="Constant">10</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># parse result is a pair</span> - <span class="Constant">11</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># result.first is an atom</span> - <span class="Constant">12</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># result.rest is an atom</span> - <span class="Constant">20</span>:@:char<span class="Special"> <- </span><span class="Constant">[abc]</span> <span class="Comment"># result.first</span> - <span class="Constant">30</span>:@:char<span class="Special"> <- </span><span class="Constant">[def]</span> <span class="Comment"># result.rest</span> + <span class="Constant"> 10</span> <span class="Special"><-</span><span class="Constant"> 1</span> <span class="Comment"># parse result is a pair</span> + <span class="Constant"> 11</span> <span class="Special"><-</span><span class="Constant"> 1</span> <span class="Comment"># result.first is an atom</span> + <span class="Constant"> 12</span> <span class="Special"><-</span><span class="Constant"> 1</span> <span class="Comment"># result.rest is an atom</span> + 20:@:char <span class="Special"><-</span> <span class="Constant">[abc]</span> <span class="Comment"># result.first</span> + 30:@:char <span class="Special"><-</span> <span class="Constant">[def]</span> <span class="Comment"># result.rest</span> ] ] <span class="muScenario">scenario</span> parse-dotted-list-of-more-than-two-atoms [ <span class="Constant">local-scope</span> - s:text<span class="Special"> <- </span>new <span class="Constant">[(abc def . ghi)]</span> - x:&:cell<span class="Special"> <- </span>parse s + s:text <span class="Special"><-</span> new <span class="Constant">[(abc def . ghi)]</span> + x:&:cell <span class="Special"><-</span> parse s trace-should-contain [ app/parse: <span class="Constant"><</span> abc <span class="Constant">|</span> <span class="Constant"><</span> def <span class="Constant">|</span> ghi <span class="Constant">></span> <span class="Constant">></span> ] - <span class="Constant">10</span>:bool/<span class="Special">raw <- </span>is-pair? x - x1:&:cell<span class="Special"> <- </span>first x - x2:&:cell<span class="Special"> <- </span>rest x - s1:text, <span class="Constant">11</span>:bool/<span class="Special">raw <- </span>maybe-convert *x1, <span class="Constant">atom:variant</span> - <span class="Constant">12</span>:bool/<span class="Special">raw <- </span>is-pair? x2 - x3:&:cell<span class="Special"> <- </span>first x2 - s2:text, <span class="Constant">13</span>:bool/<span class="Special">raw <- </span>maybe-convert *x3, <span class="Constant">atom:variant</span> - x4:&:cell<span class="Special"> <- </span>rest x2 - s3:text, <span class="Constant">14</span>:bool/<span class="Special">raw <- </span>maybe-convert *x4, <span class="Constant">atom:variant</span> - <span class="Constant">20</span>:@:char/<span class="Special">raw <- </span>copy *s1 - <span class="Constant">30</span>:@:char/<span class="Special">raw <- </span>copy *s2 - <span class="Constant">40</span>:@:char/<span class="Special">raw <- </span>copy *s3 + 10:bool/<span class="Special">raw</span> <span class="Special"><-</span> is-pair? x + x1:&:cell <span class="Special"><-</span> first x + x2:&:cell <span class="Special"><-</span> rest x + s1:text, 11:bool/<span class="Special">raw</span> <span class="Special"><-</span> maybe-convert *x1, <span class="Constant">atom:variant</span> + 12:bool/<span class="Special">raw</span> <span class="Special"><-</span> is-pair? x2 + x3:&:cell <span class="Special"><-</span> first x2 + s2:text, 13:bool/<span class="Special">raw</span> <span class="Special"><-</span> maybe-convert *x3, <span class="Constant">atom:variant</span> + x4:&:cell <span class="Special"><-</span> rest x2 + s3:text, 14:bool/<span class="Special">raw</span> <span class="Special"><-</span> maybe-convert *x4, <span class="Constant">atom:variant</span> + 20:@:char/<span class="Special">raw</span> <span class="Special"><-</span> copy *s1 + 30:@:char/<span class="Special">raw</span> <span class="Special"><-</span> copy *s2 + 40:@:char/<span class="Special">raw</span> <span class="Special"><-</span> copy *s3 memory-should-contain [ - <span class="Constant">10</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># parse result is a pair</span> - <span class="Constant">11</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># result.first is an atom</span> - <span class="Constant">12</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># result.rest is a pair</span> - <span class="Constant">13</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># result.rest.first is an atom</span> - <span class="Constant">14</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># result.rest.rest is an atom</span> - <span class="Constant">20</span>:@:char<span class="Special"> <- </span><span class="Constant">[abc]</span> <span class="Comment"># result.first</span> - <span class="Constant">30</span>:@:char<span class="Special"> <- </span><span class="Constant">[def]</span> <span class="Comment"># result.rest.first</span> - <span class="Constant">40</span>:@:char<span class="Special"> <- </span><span class="Constant">[ghi]</span> <span class="Comment"># result.rest.rest</span> + <span class="Constant"> 10</span> <span class="Special"><-</span><span class="Constant"> 1</span> <span class="Comment"># parse result is a pair</span> + <span class="Constant"> 11</span> <span class="Special"><-</span><span class="Constant"> 1</span> <span class="Comment"># result.first is an atom</span> + <span class="Constant"> 12</span> <span class="Special"><-</span><span class="Constant"> 1</span> <span class="Comment"># result.rest is a pair</span> + <span class="Constant"> 13</span> <span class="Special"><-</span><span class="Constant"> 1</span> <span class="Comment"># result.rest.first is an atom</span> + <span class="Constant"> 14</span> <span class="Special"><-</span><span class="Constant"> 1</span> <span class="Comment"># result.rest.rest is an atom</span> + 20:@:char <span class="Special"><-</span> <span class="Constant">[abc]</span> <span class="Comment"># result.first</span> + 30:@:char <span class="Special"><-</span> <span class="Constant">[def]</span> <span class="Comment"># result.rest.first</span> + 40:@:char <span class="Special"><-</span> <span class="Constant">[ghi]</span> <span class="Comment"># result.rest.rest</span> ] ] @@ -605,9 +605,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">def</span> to-mu in:&:cell<span class="muRecipe"> -> </span>out:text [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - buf:&:buffer<span class="Special"> <- </span>new-buffer <span class="Constant">30</span> - buf<span class="Special"> <- </span>to-mu in, buf - out<span class="Special"> <- </span>buffer-to-array buf + buf:&:buffer <span class="Special"><-</span> new-buffer<span class="Constant"> 30</span> + buf <span class="Special"><-</span> to-mu in, buf + out <span class="Special"><-</span> buffer-to-array buf ] <span class="muRecipe">def</span> to-mu in:&:cell, buf:&:buffer<span class="muRecipe"> -> </span>buf:&:buffer, result-name:text [ @@ -616,7 +616,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># null cell? no change.</span> <span class="Comment"># pair with all atoms? gensym a new variable</span> <span class="Comment"># pair containing other pairs? recurse</span> - result-name<span class="Special"> <- </span>copy <span class="Constant">0</span> + result-name <span class="Special"><-</span> copy<span class="Constant"> 0</span> ] </pre> </body> |