about summary refs log tree commit diff stats
path: root/html/052tangle.cc.html
diff options
context:
space:
mode:
Diffstat (limited to 'html/052tangle.cc.html')
-rw-r--r--html/052tangle.cc.html225
1 files changed, 176 insertions, 49 deletions
diff --git a/html/052tangle.cc.html b/html/052tangle.cc.html
index 93323d00..95fc502f 100644
--- a/html/052tangle.cc.html
+++ b/html/052tangle.cc.html
@@ -13,12 +13,12 @@
 pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; }
 body { font-family: monospace; color: #eeeeee; background-color: #080808; }
 * { font-size: 1.05em; }
-.Identifier { color: #804000; }
+.traceAbsent { color: #c00000; }
 .cSpecial { color: #008000; }
 .Comment { color: #9090ff; }
 .Delimiter { color: #a04060; }
 .Special { color: #ff6060; }
-.CommentedCode { color: #6c6c6c; }
+.Identifier { color: #804000; }
 .Constant { color: #00a0a0; }
 .traceContains { color: #008000; }
 -->
@@ -32,18 +32,22 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; }
 </head>
 <body>
 <pre id='vimCodeElement'>
-<span class="Comment">//: Allow code for recipes to be pulled in from multiple places.</span>
+<span class="Comment">//: Allow code for recipes to be pulled in from multiple places and inserted</span>
+<span class="Comment">//: at special labels called 'waypoints'. Unlike jump targets, a recipe can</span>
+<span class="Comment">//: have multiple ambiguous waypoints with the same name. Any 'before' and</span>
+<span class="Comment">//: 'after' fragments will simply be inserted at all applicable waypoints.</span>
+<span class="Comment">//: Waypoints are always surrounded by '&lt;&gt;', e.g. &lt;handle-request&gt;.</span>
 <span class="Comment">//:</span>
 <span class="Comment">//: TODO: switch recipe.steps to a more efficient data structure.</span>
 
 <span class="Delimiter">:(scenario tangle_before)</span>
 recipe main [
   <span class="Constant">1</span>:number<span class="Special"> &lt;- </span>copy <span class="Constant">0</span>
-  +label1
+  &lt;label1&gt;
   <span class="Constant">3</span>:number<span class="Special"> &lt;- </span>copy <span class="Constant">0</span>
 ]
 
-before +label1 [
+before &lt;label1&gt; [
   <span class="Constant">2</span>:number<span class="Special"> &lt;- </span>copy <span class="Constant">0</span>
 ]
 <span class="traceContains">+mem: storing 0 in location 1</span>
@@ -65,15 +69,19 @@ Fragments_used<span class="Delimiter">.</span>clear<span class="Delimiter">();</
 <span class="Delimiter">:(before &quot;End Command Handlers&quot;)</span>
 else if <span class="Delimiter">(</span>command == <span class="Constant">&quot;before&quot;</span><span class="Delimiter">)</span> <span class="Delimiter">{</span>
   string label = next_word<span class="Delimiter">(</span>in<span class="Delimiter">);</span>
-  recipe tmp = slurp_recipe<span class="Delimiter">(</span>in<span class="Delimiter">);</span>
-<span class="CommentedCode">//?   cerr &lt;&lt; &quot;adding before fragment &quot; &lt;&lt; label &lt;&lt; '\n'; //? 1</span>
-  Before_fragments[label]<span class="Delimiter">.</span>steps<span class="Delimiter">.</span>insert<span class="Delimiter">(</span>Before_fragments[label]<span class="Delimiter">.</span>steps<span class="Delimiter">.</span>end<span class="Delimiter">(),</span> tmp<span class="Delimiter">.</span>steps<span class="Delimiter">.</span>begin<span class="Delimiter">(),</span> tmp<span class="Delimiter">.</span>steps<span class="Delimiter">.</span>end<span class="Delimiter">());</span>
+  recipe tmp = slurp_body<span class="Delimiter">(</span>in<span class="Delimiter">);</span>
+  if <span class="Delimiter">(</span>is_waypoint<span class="Delimiter">(</span>label<span class="Delimiter">))</span>
+    Before_fragments[label]<span class="Delimiter">.</span>steps<span class="Delimiter">.</span>insert<span class="Delimiter">(</span>Before_fragments[label]<span class="Delimiter">.</span>steps<span class="Delimiter">.</span>end<span class="Delimiter">(),</span> tmp<span class="Delimiter">.</span>steps<span class="Delimiter">.</span>begin<span class="Delimiter">(),</span> tmp<span class="Delimiter">.</span>steps<span class="Delimiter">.</span>end<span class="Delimiter">());</span>
+  else
+    raise &lt;&lt; <span class="Constant">&quot;can't tangle before label &quot;</span> &lt;&lt; label &lt;&lt; <span class="cSpecial">'\n'</span> &lt;&lt; end<span class="Delimiter">();</span>
 <span class="Delimiter">}</span>
 else if <span class="Delimiter">(</span>command == <span class="Constant">&quot;after&quot;</span><span class="Delimiter">)</span> <span class="Delimiter">{</span>
   string label = next_word<span class="Delimiter">(</span>in<span class="Delimiter">);</span>
-  recipe tmp = slurp_recipe<span class="Delimiter">(</span>in<span class="Delimiter">);</span>
-<span class="CommentedCode">//?   cerr &lt;&lt; &quot;adding after fragment &quot; &lt;&lt; label &lt;&lt; '\n'; //? 1</span>
-  After_fragments[label]<span class="Delimiter">.</span>steps<span class="Delimiter">.</span>insert<span class="Delimiter">(</span>After_fragments[label]<span class="Delimiter">.</span>steps<span class="Delimiter">.</span>begin<span class="Delimiter">(),</span> tmp<span class="Delimiter">.</span>steps<span class="Delimiter">.</span>begin<span class="Delimiter">(),</span> tmp<span class="Delimiter">.</span>steps<span class="Delimiter">.</span>end<span class="Delimiter">());</span>
+  recipe tmp = slurp_body<span class="Delimiter">(</span>in<span class="Delimiter">);</span>
+  if <span class="Delimiter">(</span>is_waypoint<span class="Delimiter">(</span>label<span class="Delimiter">))</span>
+    After_fragments[label]<span class="Delimiter">.</span>steps<span class="Delimiter">.</span>insert<span class="Delimiter">(</span>After_fragments[label]<span class="Delimiter">.</span>steps<span class="Delimiter">.</span>begin<span class="Delimiter">(),</span> tmp<span class="Delimiter">.</span>steps<span class="Delimiter">.</span>begin<span class="Delimiter">(),</span> tmp<span class="Delimiter">.</span>steps<span class="Delimiter">.</span>end<span class="Delimiter">());</span>
+  else
+    raise &lt;&lt; <span class="Constant">&quot;can't tangle after label &quot;</span> &lt;&lt; label &lt;&lt; <span class="cSpecial">'\n'</span> &lt;&lt; end<span class="Delimiter">();</span>
 <span class="Delimiter">}</span>
 
 <span class="Comment">//: after all recipes are loaded, insert fragments at appropriate labels.</span>
@@ -92,33 +100,70 @@ tangle_done = <span class="Constant">false</span><span class="Delimiter">;</span
 <span class="Delimiter">:(code)</span>
 void insert_fragments<span class="Delimiter">(</span>const recipe_ordinal r<span class="Delimiter">)</span> <span class="Delimiter">{</span>
   bool made_progress = <span class="Constant">true</span><span class="Delimiter">;</span>
+  long long int pass = <span class="Constant">0</span><span class="Delimiter">;</span>
   while <span class="Delimiter">(</span>made_progress<span class="Delimiter">)</span> <span class="Delimiter">{</span>
     made_progress = <span class="Constant">false</span><span class="Delimiter">;</span>
     <span class="Comment">// create a new vector because insertions invalidate iterators</span>
     vector&lt;instruction&gt; result<span class="Delimiter">;</span>
     for <span class="Delimiter">(</span>long long int i = <span class="Constant">0</span><span class="Delimiter">;</span> i &lt; SIZE<span class="Delimiter">(</span>Recipe[r]<span class="Delimiter">.</span>steps<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span>
-      const instruction inst = Recipe[r]<span class="Delimiter">.</span>steps<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span>
-      if <span class="Delimiter">(</span>!inst<span class="Delimiter">.</span>is_label || inst<span class="Delimiter">.</span>tangle_done<span class="Delimiter">)</span> <span class="Delimiter">{</span>
+      const instruction&amp; inst = Recipe[r]<span class="Delimiter">.</span>steps<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span>
+      if <span class="Delimiter">(</span>!inst<span class="Delimiter">.</span>is_label || !is_waypoint<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>label<span class="Delimiter">)</span> || inst<span class="Delimiter">.</span>tangle_done<span class="Delimiter">)</span> <span class="Delimiter">{</span>
         result<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>inst<span class="Delimiter">);</span>
         <span class="Identifier">continue</span><span class="Delimiter">;</span>
       <span class="Delimiter">}</span>
       inst<span class="Delimiter">.</span>tangle_done = <span class="Constant">true</span><span class="Delimiter">;</span>
       made_progress = <span class="Constant">true</span><span class="Delimiter">;</span>
       Fragments_used<span class="Delimiter">.</span>insert<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>label<span class="Delimiter">);</span>
+      ostringstream prefix<span class="Delimiter">;</span>
+      prefix &lt;&lt; <span class="Constant">'+'</span> &lt;&lt; Recipe[r]<span class="Delimiter">.</span>name &lt;&lt; <span class="Constant">'_'</span> &lt;&lt; pass &lt;&lt; <span class="Constant">'_'</span> &lt;&lt; i<span class="Delimiter">;</span>
       if <span class="Delimiter">(</span>Before_fragments<span class="Delimiter">.</span>find<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>label<span class="Delimiter">)</span> != Before_fragments<span class="Delimiter">.</span>end<span class="Delimiter">())</span> <span class="Delimiter">{</span>
-<span class="CommentedCode">//?         cerr &lt;&lt; &quot;loading code before &quot; &lt;&lt; inst.label &lt;&lt; '\n'; //? 1</span>
-        result<span class="Delimiter">.</span>insert<span class="Delimiter">(</span>result<span class="Delimiter">.</span>end<span class="Delimiter">(),</span> Before_fragments[inst<span class="Delimiter">.</span>label]<span class="Delimiter">.</span>steps<span class="Delimiter">.</span>begin<span class="Delimiter">(),</span> Before_fragments[inst<span class="Delimiter">.</span>label]<span class="Delimiter">.</span>steps<span class="Delimiter">.</span>end<span class="Delimiter">());</span>
+        append_fragment<span class="Delimiter">(</span>result<span class="Delimiter">,</span> Before_fragments[inst<span class="Delimiter">.</span>label]<span class="Delimiter">.</span>steps<span class="Delimiter">,</span> prefix<span class="Delimiter">.</span>str<span class="Delimiter">());</span>
       <span class="Delimiter">}</span>
       result<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>inst<span class="Delimiter">);</span>
       if <span class="Delimiter">(</span>After_fragments<span class="Delimiter">.</span>find<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>label<span class="Delimiter">)</span> != After_fragments<span class="Delimiter">.</span>end<span class="Delimiter">())</span> <span class="Delimiter">{</span>
-<span class="CommentedCode">//?         cerr &lt;&lt; &quot;loading code after &quot; &lt;&lt; inst.label &lt;&lt; '\n'; //? 1</span>
-        result<span class="Delimiter">.</span>insert<span class="Delimiter">(</span>result<span class="Delimiter">.</span>end<span class="Delimiter">(),</span> After_fragments[inst<span class="Delimiter">.</span>label]<span class="Delimiter">.</span>steps<span class="Delimiter">.</span>begin<span class="Delimiter">(),</span> After_fragments[inst<span class="Delimiter">.</span>label]<span class="Delimiter">.</span>steps<span class="Delimiter">.</span>end<span class="Delimiter">());</span>
+        append_fragment<span class="Delimiter">(</span>result<span class="Delimiter">,</span> After_fragments[inst<span class="Delimiter">.</span>label]<span class="Delimiter">.</span>steps<span class="Delimiter">,</span> prefix<span class="Delimiter">.</span>str<span class="Delimiter">());</span>
       <span class="Delimiter">}</span>
     <span class="Delimiter">}</span>
     Recipe[r]<span class="Delimiter">.</span>steps<span class="Delimiter">.</span>swap<span class="Delimiter">(</span>result<span class="Delimiter">);</span>
+    ++pass<span class="Delimiter">;</span>
   <span class="Delimiter">}</span>
 <span class="Delimiter">}</span>
 
+void append_fragment<span class="Delimiter">(</span>vector&lt;instruction&gt;&amp; base<span class="Delimiter">,</span> const vector&lt;instruction&gt;&amp; patch<span class="Delimiter">,</span> const string prefix<span class="Delimiter">)</span> <span class="Delimiter">{</span>
+  <span class="Comment">// append 'patch' to 'base' while keeping 'base' oblivious to any new jump</span>
+  <span class="Comment">// targets in 'patch' oblivious to 'base' by prepending 'prefix' to them.</span>
+  <span class="Comment">// we might tangle the same fragment at multiple points in a single recipe,</span>
+  <span class="Comment">// and we need to avoid duplicate jump targets.</span>
+  <span class="Comment">// so we'll keep jump targets local to the specific before/after fragment</span>
+  <span class="Comment">// that introduces them.</span>
+  set&lt;string&gt; jump_targets<span class="Delimiter">;</span>
+  for <span class="Delimiter">(</span>long long int i = <span class="Constant">0</span><span class="Delimiter">;</span> i &lt; SIZE<span class="Delimiter">(</span>patch<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span>
+    const instruction&amp; inst = patch<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span>
+    if <span class="Delimiter">(</span>inst<span class="Delimiter">.</span>is_label &amp;&amp; is_jump_target<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>label<span class="Delimiter">))</span>
+      jump_targets<span class="Delimiter">.</span>insert<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>label<span class="Delimiter">);</span>
+  <span class="Delimiter">}</span>
+  for <span class="Delimiter">(</span>long long int i = <span class="Constant">0</span><span class="Delimiter">;</span> i &lt; SIZE<span class="Delimiter">(</span>patch<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span>
+    instruction inst = patch<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span>
+    if <span class="Delimiter">(</span>inst<span class="Delimiter">.</span>is_label<span class="Delimiter">)</span> <span class="Delimiter">{</span>
+      if <span class="Delimiter">(</span>jump_targets<span class="Delimiter">.</span>find<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>label<span class="Delimiter">)</span> != jump_targets<span class="Delimiter">.</span>end<span class="Delimiter">())</span>
+        inst<span class="Delimiter">.</span>label = prefix+inst<span class="Delimiter">.</span>label<span class="Delimiter">;</span>
+      base<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>inst<span class="Delimiter">);</span>
+      <span class="Identifier">continue</span><span class="Delimiter">;</span>
+    <span class="Delimiter">}</span>
+    for <span class="Delimiter">(</span>long long int j = <span class="Constant">0</span><span class="Delimiter">;</span> j &lt; SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span> ++j<span class="Delimiter">)</span> <span class="Delimiter">{</span>
+      reagent&amp; x = inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>j<span class="Delimiter">);</span>
+      if <span class="Delimiter">(</span>!is_literal<span class="Delimiter">(</span>x<span class="Delimiter">))</span> <span class="Identifier">continue</span><span class="Delimiter">;</span>
+      if <span class="Delimiter">(</span>x<span class="Delimiter">.</span>properties<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>second<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)</span> == <span class="Constant">&quot;label&quot;</span> &amp;&amp; jump_targets<span class="Delimiter">.</span>find<span class="Delimiter">(</span>x<span class="Delimiter">.</span>name<span class="Delimiter">)</span> != jump_targets<span class="Delimiter">.</span>end<span class="Delimiter">())</span>
+        x<span class="Delimiter">.</span>name = prefix+x<span class="Delimiter">.</span>name<span class="Delimiter">;</span>
+    <span class="Delimiter">}</span>
+    base<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>inst<span class="Delimiter">);</span>
+  <span class="Delimiter">}</span>
+<span class="Delimiter">}</span>
+
+bool is_waypoint<span class="Delimiter">(</span>string label<span class="Delimiter">)</span> <span class="Delimiter">{</span>
+  <span class="Identifier">return</span> *label<span class="Delimiter">.</span>begin<span class="Delimiter">()</span> == <span class="Constant">'&lt;'</span> &amp;&amp; *label<span class="Delimiter">.</span>rbegin<span class="Delimiter">()</span> == <span class="Constant">'&gt;'</span><span class="Delimiter">;</span>
+<span class="Delimiter">}</span>
+
 <span class="Comment">//: warn about unapplied fragments</span>
 <span class="Delimiter">:(before &quot;End Globals&quot;)</span>
 bool Transform_check_insert_fragments_Ran = <span class="Constant">false</span><span class="Delimiter">;</span>
@@ -141,13 +186,13 @@ void check_insert_fragments<span class="Delimiter">(</span>unused recipe_ordinal
 <span class="Delimiter">:(scenario tangle_before_and_after)</span>
 recipe main [
   <span class="Constant">1</span>:number<span class="Special"> &lt;- </span>copy <span class="Constant">0</span>
-  +label1
+  &lt;label1&gt;
   <span class="Constant">4</span>:number<span class="Special"> &lt;- </span>copy <span class="Constant">0</span>
 ]
-before +label1 [
+before &lt;label1&gt; [
   <span class="Constant">2</span>:number<span class="Special"> &lt;- </span>copy <span class="Constant">0</span>
 ]
-after +label1 [
+after &lt;label1&gt; [
   <span class="Constant">3</span>:number<span class="Special"> &lt;- </span>copy <span class="Constant">0</span>
 ]
 <span class="traceContains">+mem: storing 0 in location 1</span>
@@ -158,23 +203,41 @@ after +label1 [
 <span class="Comment"># nothing else</span>
 $mem: <span class="Constant">4</span>
 
-<span class="Delimiter">:(scenario tangle_keeps_labels_separate)</span>
+<span class="Delimiter">:(scenario tangle_ignores_jump_target)</span>
+<span class="Special">% Hide_warnings = true;</span>
 recipe main [
   <span class="Constant">1</span>:number<span class="Special"> &lt;- </span>copy <span class="Constant">0</span>
   +label1
-  +label2
-  <span class="Constant">6</span>:number<span class="Special"> &lt;- </span>copy <span class="Constant">0</span>
+  <span class="Constant">4</span>:number<span class="Special"> &lt;- </span>copy <span class="Constant">0</span>
 ]
 before +label1 [
   <span class="Constant">2</span>:number<span class="Special"> &lt;- </span>copy <span class="Constant">0</span>
 ]
-after +label1 [
+<span class="traceContains">+warn: can't tangle before label +label1</span>
+<span class="traceContains">+mem: storing 0 in location 1</span>
+<span class="traceContains">+mem: storing 0 in location 4</span>
+<span class="Comment"># label1</span>
+<span class="traceAbsent">-mem: storing 0 in location 2</span>
+<span class="Comment"># nothing else</span>
+$mem: <span class="Constant">2</span>
+
+<span class="Delimiter">:(scenario tangle_keeps_labels_separate)</span>
+recipe main [
+  <span class="Constant">1</span>:number<span class="Special"> &lt;- </span>copy <span class="Constant">0</span>
+  &lt;label1&gt;
+  &lt;label2&gt;
+  <span class="Constant">6</span>:number<span class="Special"> &lt;- </span>copy <span class="Constant">0</span>
+]
+before &lt;label1&gt; [
+  <span class="Constant">2</span>:number<span class="Special"> &lt;- </span>copy <span class="Constant">0</span>
+]
+after &lt;label1&gt; [
   <span class="Constant">3</span>:number<span class="Special"> &lt;- </span>copy <span class="Constant">0</span>
 ]
-before +label2 [
+before &lt;label2&gt; [
   <span class="Constant">4</span>:number<span class="Special"> &lt;- </span>copy <span class="Constant">0</span>
 ]
-after +label2 [
+after &lt;label2&gt; [
   <span class="Constant">5</span>:number<span class="Special"> &lt;- </span>copy <span class="Constant">0</span>
 ]
 <span class="traceContains">+mem: storing 0 in location 1</span>
@@ -192,19 +255,19 @@ $mem: <span class="Constant">6</span>
 <span class="Delimiter">:(scenario tangle_stacks_multiple_fragments)</span>
 recipe main [
   <span class="Constant">1</span>:number<span class="Special"> &lt;- </span>copy <span class="Constant">0</span>
-  +label1
+  &lt;label1&gt;
   <span class="Constant">6</span>:number<span class="Special"> &lt;- </span>copy <span class="Constant">0</span>
 ]
-before +label1 [
+before &lt;label1&gt; [
   <span class="Constant">2</span>:number<span class="Special"> &lt;- </span>copy <span class="Constant">0</span>
 ]
-after +label1 [
+after &lt;label1&gt; [
   <span class="Constant">3</span>:number<span class="Special"> &lt;- </span>copy <span class="Constant">0</span>
 ]
-before +label1 [
+before &lt;label1&gt; [
   <span class="Constant">4</span>:number<span class="Special"> &lt;- </span>copy <span class="Constant">0</span>
 ]
-after +label1 [
+after &lt;label1&gt; [
   <span class="Constant">5</span>:number<span class="Special"> &lt;- </span>copy <span class="Constant">0</span>
 ]
 <span class="traceContains">+mem: storing 0 in location 1</span>
@@ -222,14 +285,14 @@ $mem: <span class="Constant">6</span>
 <span class="Delimiter">:(scenario tangle_supports_fragments_with_multiple_instructions)</span>
 recipe main [
   <span class="Constant">1</span>:number<span class="Special"> &lt;- </span>copy <span class="Constant">0</span>
-  +label1
+  &lt;label1&gt;
   <span class="Constant">6</span>:number<span class="Special"> &lt;- </span>copy <span class="Constant">0</span>
 ]
-before +label1 [
+before &lt;label1&gt; [
   <span class="Constant">2</span>:number<span class="Special"> &lt;- </span>copy <span class="Constant">0</span>
   <span class="Constant">3</span>:number<span class="Special"> &lt;- </span>copy <span class="Constant">0</span>
 ]
-after +label1 [
+after &lt;label1&gt; [
   <span class="Constant">4</span>:number<span class="Special"> &lt;- </span>copy <span class="Constant">0</span>
   <span class="Constant">5</span>:number<span class="Special"> &lt;- </span>copy <span class="Constant">0</span>
 ]
@@ -246,19 +309,19 @@ $mem: <span class="Constant">6</span>
 <span class="Delimiter">:(scenario tangle_tangles_into_all_labels_with_same_name)</span>
 recipe main [
   <span class="Constant">1</span>:number<span class="Special"> &lt;- </span>copy <span class="Constant">10</span>
-  +label1
+  &lt;label1&gt;
   <span class="Constant">4</span>:number<span class="Special"> &lt;- </span>copy <span class="Constant">10</span>
   recipe2
 ]
 recipe recipe2 [
   <span class="Constant">1</span>:number<span class="Special"> &lt;- </span>copy <span class="Constant">11</span>
-  +label1
+  &lt;label1&gt;
   <span class="Constant">4</span>:number<span class="Special"> &lt;- </span>copy <span class="Constant">11</span>
 ]
-before +label1 [
+before &lt;label1&gt; [
   <span class="Constant">2</span>:number<span class="Special"> &lt;- </span>copy <span class="Constant">12</span>
 ]
-after +label1 [
+after &lt;label1&gt; [
   <span class="Constant">3</span>:number<span class="Special"> &lt;- </span>copy <span class="Constant">12</span>
 ]
 <span class="traceContains">+mem: storing 10 in location 1</span>
@@ -278,14 +341,14 @@ $mem: <span class="Constant">8</span>
 <span class="Delimiter">:(scenario tangle_tangles_into_all_labels_with_same_name_2)</span>
 recipe main [
   <span class="Constant">1</span>:number<span class="Special"> &lt;- </span>copy <span class="Constant">10</span>
-  +label1
-  +label1
+  &lt;label1&gt;
+  &lt;label1&gt;
   <span class="Constant">4</span>:number<span class="Special"> &lt;- </span>copy <span class="Constant">10</span>
 ]
-before +label1 [
+before &lt;label1&gt; [
   <span class="Constant">2</span>:number<span class="Special"> &lt;- </span>copy <span class="Constant">12</span>
 ]
-after +label1 [
+after &lt;label1&gt; [
   <span class="Constant">3</span>:number<span class="Special"> &lt;- </span>copy <span class="Constant">12</span>
 ]
 <span class="traceContains">+mem: storing 10 in location 1</span>
@@ -302,29 +365,93 @@ $mem: <span class="Constant">6</span>
 <span class="Delimiter">:(scenario tangle_tangles_into_all_labels_with_same_name_3)</span>
 recipe main [
   <span class="Constant">1</span>:number<span class="Special"> &lt;- </span>copy <span class="Constant">10</span>
-  +label1
-  +foo
+  &lt;label1&gt;
+  &lt;foo&gt;
   <span class="Constant">4</span>:number<span class="Special"> &lt;- </span>copy <span class="Constant">10</span>
 ]
-before +label1 [
+before &lt;label1&gt; [
   <span class="Constant">2</span>:number<span class="Special"> &lt;- </span>copy <span class="Constant">12</span>
 ]
-after +label1 [
+after &lt;label1&gt; [
   <span class="Constant">3</span>:number<span class="Special"> &lt;- </span>copy <span class="Constant">12</span>
 ]
-after +foo [
-  +label1
+after &lt;foo&gt; [
+  &lt;label1&gt;
 ]
 <span class="traceContains">+mem: storing 10 in location 1</span>
 <span class="traceContains">+mem: storing 12 in location 2</span>
 <span class="Comment"># label1</span>
 <span class="traceContains">+mem: storing 12 in location 3</span>
 <span class="traceContains">+mem: storing 12 in location 2</span>
-<span class="Comment"># +foo/label1</span>
+<span class="Comment"># foo/label1</span>
 <span class="traceContains">+mem: storing 12 in location 3</span>
 <span class="traceContains">+mem: storing 10 in location 4</span>
 <span class="Comment"># nothing else</span>
 $mem: <span class="Constant">6</span>
+
+<span class="Delimiter">:(scenario tangle_handles_jump_target_inside_fragment)</span>
+recipe main [
+  <span class="Constant">1</span>:number<span class="Special"> &lt;- </span>copy <span class="Constant">10</span>
+  &lt;label1&gt;
+  <span class="Constant">4</span>:number<span class="Special"> &lt;- </span>copy <span class="Constant">10</span>
+]
+before &lt;label1&gt; [
+  jump +label2:label
+  <span class="Constant">2</span>:number<span class="Special"> &lt;- </span>copy <span class="Constant">12</span>
+  +label2
+  <span class="Constant">3</span>:number<span class="Special"> &lt;- </span>copy <span class="Constant">12</span>
+]
+<span class="traceContains">+mem: storing 10 in location 1</span>
+<span class="Comment"># label1</span>
+<span class="traceContains">+mem: storing 12 in location 3</span>
+<span class="traceContains">+mem: storing 10 in location 4</span>
+<span class="Comment"># ignored by jump</span>
+<span class="traceAbsent">-mem: storing 12 in label 2</span>
+<span class="Comment"># nothing else</span>
+$mem: <span class="Constant">3</span>
+
+<span class="Delimiter">:(scenario tangle_renames_jump_target)</span>
+recipe main [
+  <span class="Constant">1</span>:number<span class="Special"> &lt;- </span>copy <span class="Constant">10</span>
+  &lt;label1&gt;
+  +label2
+  <span class="Constant">4</span>:number<span class="Special"> &lt;- </span>copy <span class="Constant">10</span>
+]
+before &lt;label1&gt; [
+  jump +label2:label
+  <span class="Constant">2</span>:number<span class="Special"> &lt;- </span>copy <span class="Constant">12</span>
+  +label2  <span class="Comment"># renamed</span>
+  <span class="Constant">3</span>:number<span class="Special"> &lt;- </span>copy <span class="Constant">12</span>
+]
+<span class="traceContains">+mem: storing 10 in location 1</span>
+<span class="Comment"># label1</span>
+<span class="traceContains">+mem: storing 12 in location 3</span>
+<span class="traceContains">+mem: storing 10 in location 4</span>
+<span class="Comment"># ignored by jump</span>
+<span class="traceAbsent">-mem: storing 12 in label 2</span>
+<span class="Comment"># nothing else</span>
+$mem: <span class="Constant">3</span>
+
+<span class="Delimiter">:(scenario tangle_jump_to_base_recipe)</span>
+recipe main [
+  <span class="Constant">1</span>:number<span class="Special"> &lt;- </span>copy <span class="Constant">10</span>
+  &lt;label1&gt;
+  +label2
+  <span class="Constant">4</span>:number<span class="Special"> &lt;- </span>copy <span class="Constant">10</span>
+]
+before &lt;label1&gt; [
+  jump +label2:label
+  <span class="Constant">2</span>:number<span class="Special"> &lt;- </span>copy <span class="Constant">12</span>
+  <span class="Constant">3</span>:number<span class="Special"> &lt;- </span>copy <span class="Constant">12</span>
+]
+<span class="traceContains">+mem: storing 10 in location 1</span>
+<span class="Comment"># label1</span>
+<span class="traceContains">+mem: storing 10 in location 4</span>
+<span class="Comment"># ignored by jump</span>
+<span class="traceAbsent">-mem: storing 12 in label 2</span>
+<span class="traceAbsent">-mem: storing 12 in location 3</span>
+<span class="Comment"># nothing else</span>
+$mem: <span class="Constant">2</span>
 </pre>
 </body>
 </html>