about summary refs log tree commit diff stats
path: root/html/011load.cc.html
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-05-06 00:19:03 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-05-06 00:19:03 -0700
commit672e3e50c6ed6de161e40aa256c3fc0f2b1f7cf9 (patch)
tree5fa3d82e40137b15dec2941a3446e838ce43d3e5 /html/011load.cc.html
parent20d1c9057a559ce8db83bbc2787ca91348bcb16f (diff)
downloadmu-672e3e50c6ed6de161e40aa256c3fc0f2b1f7cf9.tar.gz
1279 - colorized rendering of the source files
Diffstat (limited to 'html/011load.cc.html')
-rw-r--r--html/011load.cc.html355
1 files changed, 355 insertions, 0 deletions
diff --git a/html/011load.cc.html b/html/011load.cc.html
new file mode 100644
index 00000000..1928668e
--- /dev/null
+++ b/html/011load.cc.html
@@ -0,0 +1,355 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html>
+<head>
+<meta http-equiv="content-type" content="text/html; charset=UTF-8">
+<title>~/Desktop/s/mu/011load.cc.html</title>
+<meta name="Generator" content="Vim/7.4">
+<meta name="plugin-version" content="vim7.4_v1">
+<meta name="syntax" content="cpp">
+<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy=">
+<meta name="colorscheme" content="minimal">
+<style type="text/css">
+<!--
+pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #000000; }
+body { font-family: monospace; color: #d0d0d0; background-color: #000000; }
+* { font-size: 1em; }
+.cSpecial { color: #008000; }
+.CommentedCode { color: #6c6c6c; }
+.Constant { color: #008080; }
+.Comment { color: #8080ff; }
+.Delimiter { color: #c000c0; }
+.Special { color: #ff6060; }
+.Identifier { color: #008080; }
+.traceContains { color: #008000; }
+-->
+</style>
+
+<script type='text/javascript'>
+<!--
+
+-->
+</script>
+</head>
+<body>
+<pre id='vimCodeElement'>
+<span class="Comment">//: Phase 1 of running mu code: load it from a textual representation.</span>
+
+<span class="Delimiter">:(scenarios load)</span>
+<span class="Delimiter">:(scenario first_recipe)</span>
+recipe main [
+  <span class="Constant">1</span>:integer<span class="Special"> &lt;- </span>copy <span class="Constant">23</span>:literal
+]
+<span class="traceContains">+parse: instruction: copy</span>
+<span class="traceContains">+parse:   ingredient: {name: &quot;23&quot;, value: 0, type: 0, properties: [&quot;23&quot;: &quot;literal&quot;]}</span>
+<span class="traceContains">+parse:   product: {name: &quot;1&quot;, value: 0, type: 1, properties: [&quot;1&quot;: &quot;integer&quot;]}</span>
+
+<span class="Delimiter">:(code)</span>
+vector&lt;recipe_number&gt; load<span class="Delimiter">(</span>string form<span class="Delimiter">)</span> <span class="Delimiter">{</span>
+  istringstream in<span class="Delimiter">(</span>form<span class="Delimiter">);</span>
+  in &gt;&gt; std::noskipws<span class="Delimiter">;</span>
+  <span class="Identifier">return</span> load<span class="Delimiter">(</span>in<span class="Delimiter">);</span>
+<span class="Delimiter">}</span>
+
+vector&lt;recipe_number&gt; load<span class="Delimiter">(</span>istream&amp; in<span class="Delimiter">)</span> <span class="Delimiter">{</span>
+  vector&lt;recipe_number&gt; result<span class="Delimiter">;</span>
+  while <span class="Delimiter">(</span>!in<span class="Delimiter">.</span>eof<span class="Delimiter">())</span> <span class="Delimiter">{</span>
+    skip_whitespace_and_comments<span class="Delimiter">(</span>in<span class="Delimiter">);</span>
+    if <span class="Delimiter">(</span>in<span class="Delimiter">.</span>eof<span class="Delimiter">())</span> <span class="Identifier">break</span><span class="Delimiter">;</span>
+    string command = next_word<span class="Delimiter">(</span>in<span class="Delimiter">);</span>
+    <span class="Comment">// Command Handlers</span>
+    if <span class="Delimiter">(</span>command == <span class="Constant">&quot;recipe&quot;</span><span class="Delimiter">)</span> <span class="Delimiter">{</span>
+      string recipe_name = next_word<span class="Delimiter">(</span>in<span class="Delimiter">);</span>
+      if <span class="Delimiter">(</span>recipe_name<span class="Delimiter">.</span>empty<span class="Delimiter">())</span>
+        raise &lt;&lt; <span class="Constant">&quot;empty recipe name</span><span class="cSpecial">\n</span><span class="Constant">&quot;</span><span class="Delimiter">;</span>
+      if <span class="Delimiter">(</span>Recipe_number<span class="Delimiter">.</span>find<span class="Delimiter">(</span>recipe_name<span class="Delimiter">)</span> == Recipe_number<span class="Delimiter">.</span>end<span class="Delimiter">())</span> <span class="Delimiter">{</span>
+        Recipe_number[recipe_name] = Next_recipe_number++<span class="Delimiter">;</span>
+      <span class="Delimiter">}</span>
+      if <span class="Delimiter">(</span>Recipe<span class="Delimiter">.</span>find<span class="Delimiter">(</span>Recipe_number[recipe_name]<span class="Delimiter">)</span> != Recipe<span class="Delimiter">.</span>end<span class="Delimiter">())</span> <span class="Delimiter">{</span>
+        raise &lt;&lt; <span class="Constant">&quot;redefining recipe &quot;</span> &lt;&lt; Recipe[Recipe_number[recipe_name]]<span class="Delimiter">.</span>name &lt;&lt; <span class="Constant">&quot;</span><span class="cSpecial">\n</span><span class="Constant">&quot;</span><span class="Delimiter">;</span>
+        Recipe<span class="Delimiter">.</span>erase<span class="Delimiter">(</span>Recipe_number[recipe_name]<span class="Delimiter">);</span>
+      <span class="Delimiter">}</span>
+      Recipe[Recipe_number[recipe_name]] = slurp_recipe<span class="Delimiter">(</span>in<span class="Delimiter">);</span>
+      Recipe[Recipe_number[recipe_name]]<span class="Delimiter">.</span>name = recipe_name<span class="Delimiter">;</span>
+      <span class="Comment">// track added recipes because we may need to undo them in tests; see below</span>
+      recently_added_recipes<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>Recipe_number[recipe_name]<span class="Delimiter">);</span>
+      result<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>Recipe_number[recipe_name]<span class="Delimiter">);</span>
+    <span class="Delimiter">}</span>
+    <span class="Comment">// End Command Handlers</span>
+    else <span class="Delimiter">{</span>
+      raise &lt;&lt; <span class="Constant">&quot;unknown top-level command: &quot;</span> &lt;&lt; command &lt;&lt; <span class="cSpecial">'\n'</span><span class="Delimiter">;</span>
+    <span class="Delimiter">}</span>
+  <span class="Delimiter">}</span>
+  <span class="Identifier">return</span> result<span class="Delimiter">;</span>
+<span class="Delimiter">}</span>
+
+recipe slurp_recipe<span class="Delimiter">(</span>istream&amp; in<span class="Delimiter">)</span> <span class="Delimiter">{</span>
+  recipe result<span class="Delimiter">;</span>
+  skip_whitespace<span class="Delimiter">(</span>in<span class="Delimiter">);</span>
+  if <span class="Delimiter">(</span>in<span class="Delimiter">.</span>get<span class="Delimiter">()</span> != <span class="Constant">'['</span><span class="Delimiter">)</span>
+    raise &lt;&lt; <span class="Constant">&quot;recipe body must begin with '['</span><span class="cSpecial">\n</span><span class="Constant">&quot;</span><span class="Delimiter">;</span>
+  skip_whitespace_and_comments<span class="Delimiter">(</span>in<span class="Delimiter">);</span>
+  instruction curr<span class="Delimiter">;</span>
+  while <span class="Delimiter">(</span>next_instruction<span class="Delimiter">(</span>in<span class="Delimiter">,</span> &amp;curr<span class="Delimiter">))</span> <span class="Delimiter">{</span>
+    <span class="Comment">// End Rewrite Instruction(curr)</span>
+    result<span class="Delimiter">.</span>steps<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>curr<span class="Delimiter">);</span>
+  <span class="Delimiter">}</span>
+  <span class="Identifier">return</span> result<span class="Delimiter">;</span>
+<span class="Delimiter">}</span>
+
+bool next_instruction<span class="Delimiter">(</span>istream&amp; in<span class="Delimiter">,</span> instruction* curr<span class="Delimiter">)</span> <span class="Delimiter">{</span>
+  curr<span class="Delimiter">-&gt;</span>clear<span class="Delimiter">();</span>
+  if <span class="Delimiter">(</span>in<span class="Delimiter">.</span>eof<span class="Delimiter">())</span> <span class="Identifier">return</span> <span class="Constant">false</span><span class="Delimiter">;</span>
+<span class="CommentedCode">//?   show_rest_of_stream(in); //? 1</span>
+  skip_whitespace<span class="Delimiter">(</span>in<span class="Delimiter">);</span>  if <span class="Delimiter">(</span>in<span class="Delimiter">.</span>eof<span class="Delimiter">())</span> <span class="Identifier">return</span> <span class="Constant">false</span><span class="Delimiter">;</span>
+<span class="CommentedCode">//?   show_rest_of_stream(in); //? 1</span>
+  skip_whitespace_and_comments<span class="Delimiter">(</span>in<span class="Delimiter">);</span>  if <span class="Delimiter">(</span>in<span class="Delimiter">.</span>eof<span class="Delimiter">())</span> <span class="Identifier">return</span> <span class="Constant">false</span><span class="Delimiter">;</span>
+
+  vector&lt;string&gt; words<span class="Delimiter">;</span>
+<span class="CommentedCode">//?   show_rest_of_stream(in); //? 1</span>
+  while <span class="Delimiter">(</span>in<span class="Delimiter">.</span>peek<span class="Delimiter">()</span> != <span class="cSpecial">'\n'</span><span class="Delimiter">)</span> <span class="Delimiter">{</span>
+    skip_whitespace<span class="Delimiter">(</span>in<span class="Delimiter">);</span>  if <span class="Delimiter">(</span>in<span class="Delimiter">.</span>eof<span class="Delimiter">())</span> <span class="Identifier">return</span> <span class="Constant">false</span><span class="Delimiter">;</span>
+<span class="CommentedCode">//?     show_rest_of_stream(in); //? 1</span>
+    string word = next_word<span class="Delimiter">(</span>in<span class="Delimiter">);</span>  if <span class="Delimiter">(</span>in<span class="Delimiter">.</span>eof<span class="Delimiter">())</span> <span class="Identifier">return</span> <span class="Constant">false</span><span class="Delimiter">;</span>
+    words<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>word<span class="Delimiter">);</span>
+    skip_whitespace<span class="Delimiter">(</span>in<span class="Delimiter">);</span>  if <span class="Delimiter">(</span>in<span class="Delimiter">.</span>eof<span class="Delimiter">())</span> <span class="Identifier">return</span> <span class="Constant">false</span><span class="Delimiter">;</span>
+  <span class="Delimiter">}</span>
+  skip_whitespace_and_comments<span class="Delimiter">(</span>in<span class="Delimiter">);</span>  if <span class="Delimiter">(</span>in<span class="Delimiter">.</span>eof<span class="Delimiter">())</span> <span class="Identifier">return</span> <span class="Constant">false</span><span class="Delimiter">;</span>
+
+<span class="CommentedCode">//?   if (words.size() == 1) cout &lt;&lt; words[0] &lt;&lt; ' ' &lt;&lt; words[0].size() &lt;&lt; '\n'; //? 1</span>
+  if <span class="Delimiter">(</span>words<span class="Delimiter">.</span>size<span class="Delimiter">()</span> == <span class="Constant">1</span> &amp;&amp; words[<span class="Constant">0</span>] == <span class="Constant">&quot;]&quot;</span><span class="Delimiter">)</span> <span class="Delimiter">{</span>
+<span class="CommentedCode">//?     cout &lt;&lt; &quot;AAA\n&quot;; //? 1</span>
+    <span class="Identifier">return</span> <span class="Constant">false</span><span class="Delimiter">;</span>  <span class="Comment">// end of recipe</span>
+  <span class="Delimiter">}</span>
+
+  if <span class="Delimiter">(</span>words<span class="Delimiter">.</span>size<span class="Delimiter">()</span> == <span class="Constant">1</span> &amp;&amp; !isalnum<span class="Delimiter">(</span>words[<span class="Constant">0</span>][<span class="Constant">0</span>]<span class="Delimiter">)</span> &amp;&amp; words[<span class="Constant">0</span>][<span class="Constant">0</span>] != <span class="Constant">'$'</span><span class="Delimiter">)</span> <span class="Delimiter">{</span>
+    curr<span class="Delimiter">-&gt;</span>is_label = <span class="Constant">true</span><span class="Delimiter">;</span>
+    curr<span class="Delimiter">-&gt;</span>label = words[<span class="Constant">0</span>]<span class="Delimiter">;</span>
+    trace<span class="Delimiter">(</span><span class="Constant">&quot;parse&quot;</span><span class="Delimiter">)</span> &lt;&lt; <span class="Constant">&quot;label: &quot;</span> &lt;&lt; curr<span class="Delimiter">-&gt;</span>label<span class="Delimiter">;</span>
+    <span class="Identifier">return</span> !in<span class="Delimiter">.</span>eof<span class="Delimiter">();</span>
+  <span class="Delimiter">}</span>
+
+  vector&lt;string&gt;::iterator p = words<span class="Delimiter">.</span>begin<span class="Delimiter">();</span>
+  if <span class="Delimiter">(</span>find<span class="Delimiter">(</span>words<span class="Delimiter">.</span>begin<span class="Delimiter">(),</span> words<span class="Delimiter">.</span>end<span class="Delimiter">(),</span> <span class="Constant">&quot;&lt;-&quot;</span><span class="Delimiter">)</span> != words<span class="Delimiter">.</span>end<span class="Delimiter">())</span> <span class="Delimiter">{</span>
+    for <span class="Delimiter">(;</span> *p != <span class="Constant">&quot;&lt;-&quot;</span><span class="Delimiter">;</span> ++p<span class="Delimiter">)</span> <span class="Delimiter">{</span>
+      if <span class="Delimiter">(</span>*p == <span class="Constant">&quot;,&quot;</span><span class="Delimiter">)</span> <span class="Identifier">continue</span><span class="Delimiter">;</span>
+      curr<span class="Delimiter">-&gt;</span>products<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>reagent<span class="Delimiter">(</span>*p<span class="Delimiter">));</span>
+    <span class="Delimiter">}</span>
+    ++p<span class="Delimiter">;</span>  <span class="Comment">// skip &lt;-</span>
+  <span class="Delimiter">}</span>
+
+  curr<span class="Delimiter">-&gt;</span>name = *p<span class="Delimiter">;</span>
+  if <span class="Delimiter">(</span>Recipe_number<span class="Delimiter">.</span>find<span class="Delimiter">(</span>*p<span class="Delimiter">)</span> == Recipe_number<span class="Delimiter">.</span>end<span class="Delimiter">())</span> <span class="Delimiter">{</span>
+    Recipe_number[*p] = Next_recipe_number++<span class="Delimiter">;</span>
+<span class="CommentedCode">//?     cout &lt;&lt; &quot;AAA: &quot; &lt;&lt; *p &lt;&lt; &quot; is now &quot; &lt;&lt; Recipe_number[*p] &lt;&lt; '\n'; //? 1</span>
+  <span class="Delimiter">}</span>
+  if <span class="Delimiter">(</span>Recipe_number[*p] == <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Delimiter">{</span>
+    raise &lt;&lt; <span class="Constant">&quot;Recipe &quot;</span> &lt;&lt; *p &lt;&lt; <span class="Constant">&quot; has number 0, which is reserved for IDLE.</span><span class="cSpecial">\n</span><span class="Constant">&quot;</span> &lt;&lt; die<span class="Delimiter">();</span>
+  <span class="Delimiter">}</span>
+  curr<span class="Delimiter">-&gt;</span>operation = Recipe_number[*p]<span class="Delimiter">;</span>  ++p<span class="Delimiter">;</span>
+
+  for <span class="Delimiter">(;</span> p != words<span class="Delimiter">.</span>end<span class="Delimiter">();</span> ++p<span class="Delimiter">)</span> <span class="Delimiter">{</span>
+    if <span class="Delimiter">(</span>*p == <span class="Constant">&quot;,&quot;</span><span class="Delimiter">)</span> <span class="Identifier">continue</span><span class="Delimiter">;</span>
+    curr<span class="Delimiter">-&gt;</span>ingredients<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>reagent<span class="Delimiter">(</span>*p<span class="Delimiter">));</span>
+  <span class="Delimiter">}</span>
+
+  trace<span class="Delimiter">(</span><span class="Constant">&quot;parse&quot;</span><span class="Delimiter">)</span> &lt;&lt; <span class="Constant">&quot;instruction: &quot;</span> &lt;&lt; curr<span class="Delimiter">-&gt;</span>name<span class="Delimiter">;</span>
+  for <span class="Delimiter">(</span>vector&lt;reagent&gt;::iterator p = curr<span class="Delimiter">-&gt;</span>ingredients<span class="Delimiter">.</span>begin<span class="Delimiter">();</span> p != curr<span class="Delimiter">-&gt;</span>ingredients<span class="Delimiter">.</span>end<span class="Delimiter">();</span> ++p<span class="Delimiter">)</span> <span class="Delimiter">{</span>
+    trace<span class="Delimiter">(</span><span class="Constant">&quot;parse&quot;</span><span class="Delimiter">)</span> &lt;&lt; <span class="Constant">&quot;  ingredient: &quot;</span> &lt;&lt; p<span class="Delimiter">-&gt;</span>to_string<span class="Delimiter">();</span>
+  <span class="Delimiter">}</span>
+  for <span class="Delimiter">(</span>vector&lt;reagent&gt;::iterator p = curr<span class="Delimiter">-&gt;</span>products<span class="Delimiter">.</span>begin<span class="Delimiter">();</span> p != curr<span class="Delimiter">-&gt;</span>products<span class="Delimiter">.</span>end<span class="Delimiter">();</span> ++p<span class="Delimiter">)</span> <span class="Delimiter">{</span>
+    trace<span class="Delimiter">(</span><span class="Constant">&quot;parse&quot;</span><span class="Delimiter">)</span> &lt;&lt; <span class="Constant">&quot;  product: &quot;</span> &lt;&lt; p<span class="Delimiter">-&gt;</span>to_string<span class="Delimiter">();</span>
+  <span class="Delimiter">}</span>
+  <span class="Identifier">return</span> !in<span class="Delimiter">.</span>eof<span class="Delimiter">();</span>
+<span class="Delimiter">}</span>
+
+string next_word<span class="Delimiter">(</span>istream&amp; in<span class="Delimiter">)</span> <span class="Delimiter">{</span>
+<span class="CommentedCode">//?   cout &lt;&lt; &quot;AAA next_word\n&quot;; //? 1</span>
+  ostringstream out<span class="Delimiter">;</span>
+  skip_whitespace<span class="Delimiter">(</span>in<span class="Delimiter">);</span>
+  slurp_word<span class="Delimiter">(</span>in<span class="Delimiter">,</span> out<span class="Delimiter">);</span>
+  skip_whitespace<span class="Delimiter">(</span>in<span class="Delimiter">);</span>
+  skip_comment<span class="Delimiter">(</span>in<span class="Delimiter">);</span>
+  <span class="Identifier">return</span> out<span class="Delimiter">.</span>str<span class="Delimiter">();</span>
+<span class="Delimiter">}</span>
+
+void slurp_word<span class="Delimiter">(</span>istream&amp; in<span class="Delimiter">,</span> ostream&amp; out<span class="Delimiter">)</span> <span class="Delimiter">{</span>
+<span class="CommentedCode">//?   cout &lt;&lt; &quot;AAA slurp_word\n&quot;; //? 1</span>
+  char c<span class="Delimiter">;</span>
+  if <span class="Delimiter">(</span>in<span class="Delimiter">.</span>peek<span class="Delimiter">()</span> == <span class="Constant">','</span><span class="Delimiter">)</span> <span class="Delimiter">{</span>
+    in &gt;&gt; c<span class="Delimiter">;</span>
+    out &lt;&lt; c<span class="Delimiter">;</span>
+    <span class="Identifier">return</span><span class="Delimiter">;</span>
+  <span class="Delimiter">}</span>
+  while <span class="Delimiter">(</span>in &gt;&gt; c<span class="Delimiter">)</span> <span class="Delimiter">{</span>
+<span class="CommentedCode">//?     cout &lt;&lt; c &lt;&lt; '\n'; //? 1</span>
+    if <span class="Delimiter">(</span>isspace<span class="Delimiter">(</span>c<span class="Delimiter">)</span> || c == <span class="Constant">','</span><span class="Delimiter">)</span> <span class="Delimiter">{</span>
+      in<span class="Delimiter">.</span>putback<span class="Delimiter">(</span>c<span class="Delimiter">);</span>
+      <span class="Identifier">break</span><span class="Delimiter">;</span>
+    <span class="Delimiter">}</span>
+    out &lt;&lt; c<span class="Delimiter">;</span>
+  <span class="Delimiter">}</span>
+<span class="Delimiter">}</span>
+
+void skip_whitespace<span class="Delimiter">(</span>istream&amp; in<span class="Delimiter">)</span> <span class="Delimiter">{</span>
+  while <span class="Delimiter">(</span>isspace<span class="Delimiter">(</span>in<span class="Delimiter">.</span>peek<span class="Delimiter">())</span> &amp;&amp; in<span class="Delimiter">.</span>peek<span class="Delimiter">()</span> != <span class="cSpecial">'\n'</span><span class="Delimiter">)</span> <span class="Delimiter">{</span>
+    in<span class="Delimiter">.</span>get<span class="Delimiter">();</span>
+  <span class="Delimiter">}</span>
+<span class="Delimiter">}</span>
+
+void skip_whitespace_and_comments<span class="Delimiter">(</span>istream&amp; in<span class="Delimiter">)</span> <span class="Delimiter">{</span>
+  while <span class="Delimiter">(</span><span class="Constant">true</span><span class="Delimiter">)</span> <span class="Delimiter">{</span>
+    if <span class="Delimiter">(</span>isspace<span class="Delimiter">(</span>in<span class="Delimiter">.</span>peek<span class="Delimiter">()))</span> in<span class="Delimiter">.</span>get<span class="Delimiter">();</span>
+    else if <span class="Delimiter">(</span>in<span class="Delimiter">.</span>peek<span class="Delimiter">()</span> == <span class="Constant">'#'</span><span class="Delimiter">)</span> skip_comment<span class="Delimiter">(</span>in<span class="Delimiter">);</span>
+    else <span class="Identifier">break</span><span class="Delimiter">;</span>
+  <span class="Delimiter">}</span>
+<span class="Delimiter">}</span>
+
+void skip_comment<span class="Delimiter">(</span>istream&amp; in<span class="Delimiter">)</span> <span class="Delimiter">{</span>
+  if <span class="Delimiter">(</span>in<span class="Delimiter">.</span>peek<span class="Delimiter">()</span> == <span class="Constant">'#'</span><span class="Delimiter">)</span> <span class="Delimiter">{</span>
+    in<span class="Delimiter">.</span>get<span class="Delimiter">();</span>
+    while <span class="Delimiter">(</span>in<span class="Delimiter">.</span>peek<span class="Delimiter">()</span> != <span class="cSpecial">'\n'</span><span class="Delimiter">)</span> in<span class="Delimiter">.</span>get<span class="Delimiter">();</span>
+  <span class="Delimiter">}</span>
+<span class="Delimiter">}</span>
+
+void skip_comma<span class="Delimiter">(</span>istream&amp; in<span class="Delimiter">)</span> <span class="Delimiter">{</span>
+  skip_whitespace<span class="Delimiter">(</span>in<span class="Delimiter">);</span>
+  if <span class="Delimiter">(</span>in<span class="Delimiter">.</span>peek<span class="Delimiter">()</span> == <span class="Constant">','</span><span class="Delimiter">)</span> in<span class="Delimiter">.</span>get<span class="Delimiter">();</span>
+  skip_whitespace<span class="Delimiter">(</span>in<span class="Delimiter">);</span>
+<span class="Delimiter">}</span>
+
+<span class="Comment">// for debugging</span>
+<span class="Delimiter">:(before &quot;End Globals&quot;)</span>
+bool Show_rest_of_stream = <span class="Constant">false</span><span class="Delimiter">;</span>
+<span class="Delimiter">:(code)</span>
+void show_rest_of_stream<span class="Delimiter">(</span>istream&amp; in<span class="Delimiter">)</span> <span class="Delimiter">{</span>
+  if <span class="Delimiter">(</span>!Show_rest_of_stream<span class="Delimiter">)</span> <span class="Identifier">return</span><span class="Delimiter">;</span>
+  cerr &lt;&lt; <span class="Constant">'^'</span><span class="Delimiter">;</span>
+  char c<span class="Delimiter">;</span>
+  while <span class="Delimiter">(</span>in &gt;&gt; c<span class="Delimiter">)</span> <span class="Delimiter">{</span>
+    cerr &lt;&lt; c<span class="Delimiter">;</span>
+  <span class="Delimiter">}</span>
+  cerr &lt;&lt; <span class="Constant">&quot;$</span><span class="cSpecial">\n</span><span class="Constant">&quot;</span><span class="Delimiter">;</span>
+  exit<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span>
+<span class="Delimiter">}</span>
+
+<span class="Comment">//: Have tests clean up any recipes they added.</span>
+<span class="Delimiter">:(before &quot;End Globals&quot;)</span>
+vector&lt;recipe_number&gt; recently_added_recipes<span class="Delimiter">;</span>
+<span class="Delimiter">:(before &quot;End Setup&quot;)</span>
+for <span class="Delimiter">(</span>index_t i = <span class="Constant">0</span><span class="Delimiter">;</span> i &lt; recently_added_recipes<span class="Delimiter">.</span>size<span class="Delimiter">();</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span>
+<span class="CommentedCode">//?   cout &lt;&lt; &quot;AAA clearing &quot; &lt;&lt; Recipe[recently_added_recipes[i]].name &lt;&lt; '\n'; //? 2</span>
+  Recipe_number<span class="Delimiter">.</span>erase<span class="Delimiter">(</span>Recipe[recently_added_recipes[i]]<span class="Delimiter">.</span>name<span class="Delimiter">);</span>
+  Recipe<span class="Delimiter">.</span>erase<span class="Delimiter">(</span>recently_added_recipes[i]<span class="Delimiter">);</span>
+<span class="Delimiter">}</span>
+<span class="Comment">// Clear Other State For recently_added_recipes</span>
+recently_added_recipes<span class="Delimiter">.</span>clear<span class="Delimiter">();</span>
+
+<span class="Delimiter">:(scenario parse_comment_outside_recipe)</span>
+<span class="Comment"># this comment will be dropped by the tangler, so we need a dummy recipe to stop that</span>
+recipe f1 [ ]
+<span class="Comment"># this comment will go through to 'load'</span>
+recipe main [
+  <span class="Constant">1</span>:integer<span class="Special"> &lt;- </span>copy <span class="Constant">23</span>:literal
+]
+<span class="traceContains">+parse: instruction: copy</span>
+<span class="traceContains">+parse:   ingredient: {name: &quot;23&quot;, value: 0, type: 0, properties: [&quot;23&quot;: &quot;literal&quot;]}</span>
+<span class="traceContains">+parse:   product: {name: &quot;1&quot;, value: 0, type: 1, properties: [&quot;1&quot;: &quot;integer&quot;]}</span>
+
+<span class="Delimiter">:(scenario parse_comment_amongst_instruction)</span>
+recipe main [
+  <span class="Comment"># comment</span>
+  <span class="Constant">1</span>:integer<span class="Special"> &lt;- </span>copy <span class="Constant">23</span>:literal
+]
+<span class="traceContains">+parse: instruction: copy</span>
+<span class="traceContains">+parse:   ingredient: {name: &quot;23&quot;, value: 0, type: 0, properties: [&quot;23&quot;: &quot;literal&quot;]}</span>
+<span class="traceContains">+parse:   product: {name: &quot;1&quot;, value: 0, type: 1, properties: [&quot;1&quot;: &quot;integer&quot;]}</span>
+
+<span class="Delimiter">:(scenario parse_comment_amongst_instruction2)</span>
+recipe main [
+  <span class="Comment"># comment</span>
+  <span class="Constant">1</span>:integer<span class="Special"> &lt;- </span>copy <span class="Constant">23</span>:literal
+  <span class="Comment"># comment</span>
+]
+<span class="traceContains">+parse: instruction: copy</span>
+<span class="traceContains">+parse:   ingredient: {name: &quot;23&quot;, value: 0, type: 0, properties: [&quot;23&quot;: &quot;literal&quot;]}</span>
+<span class="traceContains">+parse:   product: {name: &quot;1&quot;, value: 0, type: 1, properties: [&quot;1&quot;: &quot;integer&quot;]}</span>
+
+<span class="Delimiter">:(scenario parse_comment_amongst_instruction3)</span>
+recipe main [
+  <span class="Constant">1</span>:integer<span class="Special"> &lt;- </span>copy <span class="Constant">23</span>:literal
+  <span class="Comment"># comment</span>
+  <span class="Constant">2</span>:integer<span class="Special"> &lt;- </span>copy <span class="Constant">23</span>:literal
+]
+<span class="traceContains">+parse: instruction: copy</span>
+<span class="traceContains">+parse:   ingredient: {name: &quot;23&quot;, value: 0, type: 0, properties: [&quot;23&quot;: &quot;literal&quot;]}</span>
+<span class="traceContains">+parse:   product: {name: &quot;1&quot;, value: 0, type: 1, properties: [&quot;1&quot;: &quot;integer&quot;]}</span>
+<span class="traceContains">+parse: instruction: copy</span>
+<span class="traceContains">+parse:   ingredient: {name: &quot;23&quot;, value: 0, type: 0, properties: [&quot;23&quot;: &quot;literal&quot;]}</span>
+<span class="traceContains">+parse:   product: {name: &quot;2&quot;, value: 0, type: 1, properties: [&quot;2&quot;: &quot;integer&quot;]}</span>
+
+<span class="Delimiter">:(scenario parse_comment_after_instruction)</span>
+recipe main [
+  <span class="Constant">1</span>:integer<span class="Special"> &lt;- </span>copy <span class="Constant">23</span>:literal  <span class="Comment"># comment</span>
+]
+<span class="traceContains">+parse: instruction: copy</span>
+<span class="traceContains">+parse:   ingredient: {name: &quot;23&quot;, value: 0, type: 0, properties: [&quot;23&quot;: &quot;literal&quot;]}</span>
+<span class="traceContains">+parse:   product: {name: &quot;1&quot;, value: 0, type: 1, properties: [&quot;1&quot;: &quot;integer&quot;]}</span>
+
+<span class="Delimiter">:(scenario parse_label)</span>
+recipe main [
+  +foo
+]
+<span class="traceContains">+parse: label: +foo</span>
+
+<span class="Delimiter">:(scenario parse_dollar_as_recipe_name)</span>
+recipe main [
+  $foo
+]
+<span class="traceContains">+parse: instruction: $foo</span>
+
+<span class="Delimiter">:(scenario parse_multiple_properties)</span>
+recipe main [
+  <span class="Constant">1</span>:integer<span class="Special"> &lt;- </span>copy <span class="Constant">23</span>:literal/foo:bar:baz
+]
+<span class="traceContains">+parse: instruction: copy</span>
+<span class="traceContains">+parse:   ingredient: {name: &quot;23&quot;, value: 0, type: 0, properties: [&quot;23&quot;: &quot;literal&quot;, &quot;foo&quot;: &quot;bar&quot;:&quot;baz&quot;]}</span>
+<span class="traceContains">+parse:   product: {name: &quot;1&quot;, value: 0, type: 1, properties: [&quot;1&quot;: &quot;integer&quot;]}</span>
+
+<span class="Delimiter">:(scenario parse_multiple_products)</span>
+recipe main [
+  <span class="Constant">1</span>:integer<span class="Delimiter">,</span> <span class="Constant">2</span>:integer<span class="Special"> &lt;- </span>copy <span class="Constant">23</span>:literal
+]
+<span class="traceContains">+parse: instruction: copy</span>
+<span class="traceContains">+parse:   ingredient: {name: &quot;23&quot;, value: 0, type: 0, properties: [&quot;23&quot;: &quot;literal&quot;]}</span>
+<span class="traceContains">+parse:   product: {name: &quot;1&quot;, value: 0, type: 1, properties: [&quot;1&quot;: &quot;integer&quot;]}</span>
+<span class="traceContains">+parse:   product: {name: &quot;2&quot;, value: 0, type: 1, properties: [&quot;2&quot;: &quot;integer&quot;]}</span>
+
+<span class="Delimiter">:(scenario parse_multiple_ingredients)</span>
+recipe main [
+  <span class="Constant">1</span>:integer<span class="Delimiter">,</span> <span class="Constant">2</span>:integer<span class="Special"> &lt;- </span>copy <span class="Constant">23</span>:literal<span class="Delimiter">,</span> <span class="Constant">4</span>:integer
+]
+<span class="traceContains">+parse: instruction: copy</span>
+<span class="traceContains">+parse:   ingredient: {name: &quot;23&quot;, value: 0, type: 0, properties: [&quot;23&quot;: &quot;literal&quot;]}</span>
+<span class="traceContains">+parse:   ingredient: {name: &quot;4&quot;, value: 0, type: 1, properties: [&quot;4&quot;: &quot;integer&quot;]}</span>
+<span class="traceContains">+parse:   product: {name: &quot;1&quot;, value: 0, type: 1, properties: [&quot;1&quot;: &quot;integer&quot;]}</span>
+<span class="traceContains">+parse:   product: {name: &quot;2&quot;, value: 0, type: 1, properties: [&quot;2&quot;: &quot;integer&quot;]}</span>
+
+<span class="Delimiter">:(scenario parse_multiple_types)</span>
+recipe main [
+  <span class="Constant">1</span>:integer<span class="Delimiter">,</span> <span class="Constant">2</span>:address:integer<span class="Special"> &lt;- </span>copy <span class="Constant">23</span>:literal<span class="Delimiter">,</span> <span class="Constant">4</span>:integer
+]
+<span class="traceContains">+parse: instruction: copy</span>
+<span class="traceContains">+parse:   ingredient: {name: &quot;23&quot;, value: 0, type: 0, properties: [&quot;23&quot;: &quot;literal&quot;]}</span>
+<span class="traceContains">+parse:   ingredient: {name: &quot;4&quot;, value: 0, type: 1, properties: [&quot;4&quot;: &quot;integer&quot;]}</span>
+<span class="traceContains">+parse:   product: {name: &quot;1&quot;, value: 0, type: 1, properties: [&quot;1&quot;: &quot;integer&quot;]}</span>
+<span class="traceContains">+parse:   product: {name: &quot;2&quot;, value: 0, type: 2-1, properties: [&quot;2&quot;: &quot;address&quot;:&quot;integer&quot;]}</span>
+
+<span class="Delimiter">:(scenario parse_properties)</span>
+recipe main [
+  <span class="Constant">1</span>:integer:address/deref<span class="Special"> &lt;- </span>copy <span class="Constant">23</span>:literal
+]
+<span class="traceContains">+parse:   product: {name: &quot;1&quot;, value: 0, type: 1-2, properties: [&quot;1&quot;: &quot;integer&quot;:&quot;address&quot;, &quot;deref&quot;: ]}</span>
+</pre>
+</body>
+</html>
+<!-- vim: set foldmethod=manual : -->