Browse Source

fixing native foreach with complex exit

stepan-mitkin 3 years ago
parent
commit
356aa9ad2c
46 changed files with 1053 additions and 6164 deletions
  1. 3 2
      examples/AutoHotkey/Fibonacci sequence.ahk
  2. BIN
      examples/AutoHotkey/Fibonacci sequence.drn
  3. 2 2
      examples/AutoHotkey/Get position and color of pixel.ahk
  4. BIN
      examples/AutoHotkey/Get position and color of pixel.drn
  5. 53 0
      examples/C#/Demo.cs
  6. BIN
      examples/C#/Demo.drn
  7. 2 2
      examples/C/c_demo.h
  8. 53 0
      examples/D/test.d
  9. BIN
      examples/D/test.drn
  10. BIN
      examples/Java/Demo.drn
  11. 53 0
      examples/Java/Demo.java
  12. BIN
      examples/Lua/lua_demo.drn
  13. 63 0
      examples/Lua/lua_demo.lua
  14. BIN
      examples/Python/python_demo.drn
  15. 45 0
      examples/Python/python_demo.py
  16. BIN
      examples/Tcl/tcl_demo.drn
  17. 53 15
      examples/Tcl/tcl_demo.tcl
  18. 8 120
      generators/AutoHotkey_L.tcl
  19. 9 108
      generators/c.tcl
  20. 72 880
      generators/cpp.tcl
  21. BIN
      generators/cs.drn
  22. 22 249
      generators/cs.tcl
  23. 3 18
      generators/cycle_body.tcl
  24. 5 1
      generators/d.tcl
  25. BIN
      generators/java.drn
  26. 11 47
      generators/java.tcl
  27. BIN
      generators/lua.drn
  28. 24 228
      generators/lua.tcl
  29. 17 201
      generators/machine.tcl
  30. 4 60
      generators/node_sorter.tcl
  31. 49 236
      generators/nogoto.tcl
  32. 21 91
      generators/python.tcl
  33. 6 0
      generators/tcl.tcl
  34. 29 435
      generators/verilog.tcl
  35. 6 90
      scripts/alt_edit.tcl
  36. 112 17
      scripts/generators.tcl
  37. BIN
      scripts/graph2.drn
  38. 32 427
      scripts/graph2.tcl
  39. 4 60
      scripts/hie_engine.tcl
  40. 39 585
      structure/struct.tcl
  41. 125 1088
      structure/tables.tcl
  42. 58 484
      structure/tables_c.tcl
  43. 45 343
      structure/tables_cs.tcl
  44. 22 330
      structure/tables_tcl.tcl
  45. 1 15
      unittest/algo2.tcl
  46. 2 30
      unittest/nogoto_src.tcl

+ 3 - 2
examples/AutoHotkey/Fibonacci sequence.ahk

@@ -1,5 +1,5 @@
-; Autogenerated with DRAKON Editor 1.23
-; AutoHotkey_L beta v1.7 code generator used
+; Autogenerated with DRAKON Editor 1.27
+; AutoHotkey_L beta v1.8 code generator used
 
 
 ;Header starts here.
@@ -43,6 +43,7 @@ Fibonacci(SeqLength) {
         SeqLength := SeqLength - 1
         ; item 35
         if (SeqLength = 0) {
+            normal_ := 0
             break
         } else {
             

BIN
examples/AutoHotkey/Fibonacci sequence.drn


+ 2 - 2
examples/AutoHotkey/Get position and color of pixel.ahk

@@ -1,5 +1,5 @@
-; Autogenerated with DRAKON Editor 1.23
-; AutoHotkey_L beta v1.7 code generator used
+; Autogenerated with DRAKON Editor 1.27
+; AutoHotkey_L beta v1.8 code generator used
 
 
 ;Header starts here.

BIN
examples/AutoHotkey/Get position and color of pixel.drn


+ 53 - 0
examples/C#/Demo.cs

@@ -71,6 +71,47 @@ public class Demo {
         PrintListForeach(sequence);
         // item 156
         Console.WriteLine();
+        // item 291
+        TestEarly(20, 60);
+        // item 292
+        TestEarly(35, 70);
+        // item 293
+        TestEarly(4, 0);
+    }
+
+    private static int ForeachEarlyExit(int value) {
+        // item 279
+        int found = -1;
+        int normal_262;
+        normal_262 = 1;
+        foreach (int x in new int[] {10, 20, 30}) {
+            // item 266
+            if (x == value) {
+                // item 270
+                found = x;
+                normal_262 = 0;
+                break;
+            } else {
+                
+            }
+        }
+        if (normal_262 == 1) {
+            // item 269
+            found = 0;
+        }
+        foreach (int x in new int[] {40, 20, 70}) {
+            // item 278
+            int m = x / 2;
+            // item 273
+            if (m == value) {
+                // item 277
+                return x + found;
+            } else {
+                
+            }
+        }
+        // item 276
+        return 0;
     }
 
     private static void Print(Object[] collection) {
@@ -262,6 +303,18 @@ public class Demo {
         }
     }
 
+    private static void TestEarly(int value, int expected) {
+        // item 285
+        int actual = ForeachEarlyExit(value);
+        // item 286
+        if (actual == expected) {
+            
+        } else {
+            // item 289
+            throw new Exception("foreach_early_exit failed: " + actual + " " + expected);
+        }
+    }
+
     private static void Write(Object item) {
         // item 180
         Console.Write(item);

BIN
examples/C#/Demo.drn


+ 2 - 2
examples/C/c_demo.h

@@ -1,6 +1,6 @@
 /* Autogenerated with DRAKON Editor 1.27 */
-#ifndef C_DEMO_H14075
-#define C_DEMO_H14075
+#ifndef C_DEMO_H32503
+#define C_DEMO_H32503
 
 /* Since C does not come with a decent standard library,
    we must provide our own primitives.

+ 53 - 0
examples/D/test.d

@@ -148,6 +148,41 @@ static pure int[] fibonacci(int n) {
     return result;
 }
 
+int foreachEarlyExit(int value) {
+    // item 192
+    int found = -1;
+    int normal_176;
+    normal_176 = 1;
+    foreach (int x; [10, 20, 30]) {
+        // item 180
+        if (x == value) {
+            // item 184
+            found = x;
+            normal_176 = 0;
+            break;
+        } else {
+            
+        }
+    }
+    if (normal_176 == 1) {
+        // item 183
+        found = 0;
+    }
+    foreach (int x; [40, 20, 70]) {
+        // item 191
+        int m = x / 2;
+        // item 186
+        if (m == value) {
+            // item 190
+            return x + found;
+        } else {
+            
+        }
+    }
+    // item 189
+    return 0;
+}
+
 static void iterate_arrow(const(int)[] numbers) {
     // item 86
     int i = 0;
@@ -203,6 +238,12 @@ void run() {
     iterate_arrow2(numbers);
     // item 154
     alt_select_test();
+    // item 204
+    testEarly(20, 60);
+    // item 205
+    testEarly(35, 70);
+    // item 206
+    testEarly(4, 0);
     foreach (int i, int n; numbers) {
         // item 159
         writefln("%d:%d ", i, n);
@@ -220,6 +261,18 @@ void run() {
     writeln();
 }
 
+void testEarly(int value, int expected) {
+    // item 199
+    int actual = foreachEarlyExit(value);
+    // item 200
+    if (actual == expected) {
+        
+    } else {
+        // item 203
+        throw new Exception("foreach_early_exit failed");
+    }
+}
+
 // This part goes to the end of the file.
 
 

BIN
examples/D/test.drn


BIN
examples/Java/Demo.drn


+ 53 - 0
examples/Java/Demo.java

@@ -159,6 +159,47 @@ public class Demo {
         printListForeach(sequence);
         // item 156
         System.out.println();
+        // item 284
+        testEarly(20, 60);
+        // item 285
+        testEarly(35, 70);
+        // item 286
+        testEarly(4, 0);
+    }
+
+    private static int foreachEarlyExit(int value) {
+        // item 272
+        int found = -1;
+        int normal_256;
+        normal_256 = 1;
+        for (int x : new int[] {10, 20, 30}) {
+            // item 260
+            if (x == value) {
+                // item 264
+                found = x;
+                normal_256 = 0;
+                break;
+            } else {
+                
+            }
+        }
+        if (normal_256 == 1) {
+            // item 263
+            found = 0;
+        }
+        for (int x : new int[] {40, 20, 70}) {
+            // item 271
+            int m = x / 2;
+            // item 266
+            if (m == value) {
+                // item 270
+                return x + found;
+            } else {
+                
+            }
+        }
+        // item 269
+        return 0;
     }
 
     private static void print(List<Object> collection) {
@@ -318,6 +359,18 @@ public class Demo {
         }
     }
 
+    private static void testEarly(int value, int expected) {
+        // item 279
+        int actual = foreachEarlyExit(value);
+        // item 280
+        if (actual == expected) {
+            
+        } else {
+            // item 283
+            throw new IllegalStateException("foreach_early_exit failed: " + actual + " " + expected);
+        }
+    }
+
     private static void write(Object item) {
         // item 180
         System.out.print(item);

BIN
examples/Lua/lua_demo.drn


+ 63 - 0
examples/Lua/lua_demo.lua

@@ -80,6 +80,7 @@ function alternative_select(value, expected)
 end
 
 function arrayToString(array)
+    local i
     -- item 267
     local result = ""
     local current
@@ -90,6 +91,7 @@ function arrayToString(array)
         if i <= #array then
             
         else
+            normal_ = 0
             break
         end
         -- item 269
@@ -152,6 +154,7 @@ function descComparer(left, right)
 end
 
 function fibonacci(n)
+    local i
     -- item 185
     local result = {0}
     -- item 1610001
@@ -172,6 +175,7 @@ function fibonacci(n)
                 if i <= n then
                     
                 else
+                    normal_ = 0
                     break
                 end
                 -- item 172
@@ -202,6 +206,47 @@ function foreachDemo()
     printListForeach(sequence)
     -- item 156
     print()
+    -- item 437
+    test_early(20, 60)
+    -- item 438
+    test_early(35, 70)
+    -- item 439
+    test_early(4, 0)
+end
+
+function foreach_early_exit(value)
+    -- item 436
+    local found
+    local normal_419
+    normal_419 = 1
+    for _, x in pairs({10, 20, 30}) do
+        -- item 423
+        if x == value then
+            -- item 427
+            found = x
+            normal_419 = 0
+            break
+        else
+            
+        end
+    end
+    if normal_419 == 1 then
+        -- item 426
+        found = 0
+    end
+    for _, x in pairs({40, 20, 70}) do
+        -- item 435
+        local m = x / 2
+        -- item 430
+        if m == value then
+            -- item 434
+            return x + found
+        else
+            
+        end
+    end
+    -- item 433
+    return 0
 end
 
 function output(text)
@@ -219,6 +264,7 @@ function printListArrow(collection)
         if i <= #collection then
             
         else
+            normal_ = 0
             break
         end
         -- item 125
@@ -239,6 +285,7 @@ function printListBackward(collection)
         if n > 0 then
             
         else
+            normal_ = 0
             break
         end
         -- item 312
@@ -252,6 +299,7 @@ function printListBackward(collection)
 end
 
 function printListFor(collection)
+    local j
     -- item 348
     local i
     -- item 142
@@ -263,6 +311,7 @@ function printListFor(collection)
         if j <= #collection then
             
         else
+            normal_ = 0
             break
         end
         -- item 353
@@ -280,6 +329,7 @@ function printListFor(collection)
         if i <= #collection then
             
         else
+            normal_ = 0
             break
         end
         -- item 183
@@ -342,6 +392,7 @@ function quicksort(comparer, collection, first, last)
                 if i < last then
                     
                 else
+                    normal_ = 0
                     break
                 end
                 -- item 232
@@ -489,5 +540,17 @@ function swap(array, leftIndex, rightIndex)
     array[rightIndex ] = left
 end
 
+function test_early(value, expected)
+    -- item 445
+    local actual = foreach_early_exit(value)
+    -- item 446
+    if actual == expected then
+        
+    else
+        -- item 449
+        error ("foreach_early_exit failed")
+    end
+end
+
 
 Main()

BIN
examples/Python/python_demo.drn


+ 45 - 0
examples/Python/python_demo.py

@@ -100,6 +100,40 @@ def foreach_demo():
     print_list_foreach(sequence)
     #item 179
     print("")
+    #item 283
+    test_early(20, 60)
+    #item 284
+    test_early(35, 70)
+    #item 285
+    test_early(4, 0)
+
+
+def foreach_early_exit(value):
+    
+    normal_255 = 1
+    for x in [10, 20, 30]:
+        #item 259
+        if x == value:
+            #item 263
+            found = x
+            normal_255 = 0
+            break
+        else:
+            pass
+    if normal_255 == 1:
+        #item 262
+        found = 0
+    for x in [40, 20, 70]:
+        #item 271
+        m = x / 2
+        #item 266
+        if m == value:
+            #item 270
+            return x + found
+        else:
+            pass
+    #item 269
+    return 0
 
 
 def main():
@@ -297,6 +331,17 @@ def strings_are_sorted(array):
     
 
 
+def test_early(value, expected):
+    #item 278
+    actual = foreach_early_exit(value)
+    #item 279
+    if actual == expected:
+        pass
+    else:
+        #item 282
+        raise Exception("foreach_early_exit failed")
+
+
 def write(item):
     #item 142
     sys.stdout.write(str(item))

BIN
examples/Tcl/tcl_demo.drn


+ 53 - 15
examples/Tcl/tcl_demo.tcl

@@ -113,6 +113,45 @@ proc foreach_demo { } {
     print_list_foreach $sequence
     #item 183
     puts ""
+    #item 379
+    test_early 20 60
+    #item 381
+    test_early 35 70
+    #item 382
+    test_early 4 0
+}
+
+proc foreach_early_exit { value } {
+    
+    set normal_351 1
+    foreach x {10 20 30} {
+        #item 357
+        if {$x == $value} {
+            #item 361
+            set found $x
+            set normal_351 0
+            break
+        } else {
+            
+        }
+    }
+    if {$normal_351 == 1} {
+        #item 360
+        set found 0
+    }
+    foreach x {40 20 70} {
+        #item 380
+        set m [ expr { $x / 2 } ]
+        #item 364
+        if {$m == $value} {
+            #item 368
+            return [expr {$x + $found}]
+        } else {
+            
+        }
+    }
+    #item 367
+    return 0
 }
 
 proc main { } {
@@ -177,23 +216,9 @@ proc print_list_for { collection } {
 proc print_list_foreach { collection } {
     #item 137
     puts "using foreach:"
-    #item 1110001
-    set _col111 $collection
-    set _len111 [ llength $_col111 ]
-    set _ind111 0
-    while { 1 } {
-        #item 1110002
-        if {$_ind111 < $_len111} {
-            
-        } else {
-            break
-        }
-        #item 1110004
-        set item [ lindex $_col111 $_ind111 ]
+    foreach item $collection {
         #item 112
         write $item
-        #item 1110003
-        incr _ind111
     }
     #item 136
     puts ""
@@ -376,6 +401,19 @@ proc strings_are_sorted { array } {
     }
 }
 
+proc test_early { value expected } {
+    #item 374
+    set actual \
+    [foreach_early_exit $value]
+    #item 375
+    if {$actual == $expected} {
+        
+    } else {
+        #item 378
+        error "foreach_early_exit failed $actual $expected"
+    }
+}
+
 proc write { item } {
     #item 142
     puts -nonewline "$item "

+ 8 - 120
generators/AutoHotkey_L.tcl

@@ -149,23 +149,9 @@ proc generate { db gdb filename } {
     	from vertices
     	group by diagram_id
     } ]
-    #item 17680001
-    set _col1768 $diagrams
-    set _len1768 [ llength $_col1768 ]
-    set _ind1768 0
-    while { 1 } {
-        #item 17680002
-        if {$_ind1768 < $_len1768} {
-            
-        } else {
-            break
-        }
-        #item 17680004
-        set diagram_id [ lindex $_col1768 $_ind1768 ]
+    foreach diagram_id $diagrams {
         #item 1766
         rewire_AutoHotkey_L_for $gdb $diagram_id
-        #item 17680003
-        incr _ind1768
     }
     #item 1284
     set callbacks [ make_callbacks ]
@@ -242,19 +228,7 @@ proc highlight { tokens } {
     set state "idle"
     #item 1930
     variable keywords
-    #item 18960001
-    set _col1896 $tokens
-    set _len1896 [ llength $_col1896 ]
-    set _ind1896 0
-    while { 1 } {
-        #item 18960002
-        if {$_ind1896 < $_len1896} {
-            
-        } else {
-            break
-        }
-        #item 18960004
-        set token [ lindex $_col1896 $_ind1896 ]
+    foreach token $tokens {
         #item 1978
         lassign $token type text
         #item 18910001
@@ -368,8 +342,6 @@ proc highlight { tokens } {
                 }
             }
         }
-        #item 18960003
-        incr _ind1896
     }
     #item 1888
     return $result
@@ -628,23 +600,9 @@ proc print_function { fhandle function } {
             }
             #item 552
             lappend result $line
-            #item 5830001
-            set _col583 $body
-            set _len583 [ llength $_col583 ]
-            set _ind583 0
-            while { 1 } {
-                #item 5830002
-                if {$_ind583 < $_len583} {
-                    
-                } else {
-                    break
-                }
-                #item 5830004
-                set line [ lindex $_col583 $_ind583 ]
+            foreach line $body {
                 #item 582
                 lappend result "    $line"
-                #item 5830003
-                incr _ind583
             }
             #item 1835
             if {($ahk_diagramtype == "free") || ($ahk_diagramtype == "hotkey")} {
@@ -656,23 +614,9 @@ proc print_function { fhandle function } {
                 #item 585
                 lappend result "\}"
             }
-            #item 10200001
-            set _col1020 $result
-            set _len1020 [ llength $_col1020 ]
-            set _ind1020 0
-            while { 1 } {
-                #item 10200002
-                if {$_ind1020 < $_len1020} {
-                    
-                } else {
-                    break
-                }
-                #item 10200004
-                set line [ lindex $_col1020 $_ind1020 ]
+            foreach line $result {
                 #item 1022
                 puts $fhandle $line
-                #item 10200003
-                incr _ind1020
             }
             #item 1023
             puts $fhandle ""
@@ -685,23 +629,9 @@ proc print_to_file { fhandle functions header footer } {
     put_credits $fhandle
     #item 1559
     puts $fhandle $header
-    #item 15680001
-    set _col1568 $functions
-    set _len1568 [ llength $_col1568 ]
-    set _ind1568 0
-    while { 1 } {
-        #item 15680002
-        if {$_ind1568 < $_len1568} {
-            
-        } else {
-            break
-        }
-        #item 15680004
-        set function [ lindex $_col1568 $_ind1568 ]
+    foreach function $functions {
         #item 1570
         print_function $fhandle $function
-        #item 15680003
-        incr _ind1568
     }
     #item 1560
     puts $fhandle $footer
@@ -730,19 +660,7 @@ proc rewire_AutoHotkey_L_for { gdb diagram_id } {
     } ]
     #item 1733
     set loop_vars {}
-    #item 17340001
-    set _col1734 $starts
-    set _len1734 [ llength $_col1734 ]
-    set _ind1734 0
-    while { 1 } {
-        #item 17340002
-        if {$_ind1734 < $_len1734} {
-            
-        } else {
-            break
-        }
-        #item 17340004
-        set vertex_id [ lindex $_col1734 $_ind1734 ]
+    foreach vertex_id $starts {
         #item 1736
         unpack [ $gdb eval { 
         	select text, item_id
@@ -761,8 +679,6 @@ proc rewire_AutoHotkey_L_for { gdb diagram_id } {
         }
         #item 1740
         lappend loop_vars $var
-        #item 17340003
-        incr _ind1734
     }
     #item 1753
     set var_list [ lsort -unique $loop_vars ]
@@ -789,19 +705,7 @@ proc split_vars { $item_id var_list } {
     set raw [ split $var_list "," ]
     #item 1653
     set result {}
-    #item 16550001
-    set _col1655 $raw
-    set _len1655 [ llength $_col1655 ]
-    set _ind1655 0
-    while { 1 } {
-        #item 16550002
-        if {$_ind1655 < $_len1655} {
-            
-        } else {
-            break
-        }
-        #item 16550004
-        set part [ lindex $_col1655 $_ind1655 ]
+    foreach part $raw {
         #item 1657
         set stripped [ string trim $part ]
         #item 1658
@@ -811,8 +715,6 @@ proc split_vars { $item_id var_list } {
             #item 1661
             lappend result $stripped
         }
-        #item 16550003
-        incr _ind1655
     }
     #item 1663
     if {$result == {}} {
@@ -835,19 +737,7 @@ proc to_tokens { text } {
     set tokens [ search::to_tokens $text ]
     #item 1701
     set result {}
-    #item 17030001
-    set _col1703 $tokens
-    set _len1703 [ llength $_col1703 ]
-    set _ind1703 0
-    while { 1 } {
-        #item 17030002
-        if {$_ind1703 < $_len1703} {
-            
-        } else {
-            break
-        }
-        #item 17030004
-        set token [ lindex $_col1703 $_ind1703 ]
+    foreach token $tokens {
         #item 1705
         set text [ lindex $token 0 ]
         #item 1706
@@ -859,8 +749,6 @@ proc to_tokens { text } {
             #item 1707
             lappend result $text
         }
-        #item 17030003
-        incr _ind1703
     }
     #item 1702
     return $result

+ 9 - 108
generators/c.tcl

@@ -73,34 +73,19 @@ proc compare { variable constant } {
 }
 
 proc contains_exit { links item_id } {
-    #item 5330001
-    set _col533 $links
-    set _len533 [ llength $_col533 ]
-    set _ind533 0
-    while { 1 } {
-        #item 5330002
-        if {$_ind533 < $_len533} {
-            
-        } else {
-            #item 546
-            return 0
-            break
-        }
-        #item 5330004
-        set link [ lindex $_col533 $_ind533 ]
+    foreach link $links {
         #item 532
         set linked_item [ lindex $link 0 ]
         #item 550
         if {$linked_item == $item_id} {
             #item 548
             return 1
-            break
         } else {
             
         }
-        #item 5330003
-        incr _ind533
     }
+    #item 546
+    return 0
 }
 
 proc declare { type name value } {
@@ -395,59 +380,17 @@ proc print_c { header_filename fhandle public static header footer } {
     #item 206
     puts $fhandle ""
     puts $fhandle $header
-    #item 2150001
-    set _col215 $static
-    set _len215 [ llength $_col215 ]
-    set _ind215 0
-    while { 1 } {
-        #item 2150002
-        if {$_ind215 < $_len215} {
-            
-        } else {
-            break
-        }
-        #item 2150004
-        set function [ lindex $_col215 $_ind215 ]
+    foreach function $static {
         #item 217
         print_function $fhandle $function 1
-        #item 2150003
-        incr _ind215
     }
-    #item 2070001
-    set _col207 $static
-    set _len207 [ llength $_col207 ]
-    set _ind207 0
-    while { 1 } {
-        #item 2070002
-        if {$_ind207 < $_len207} {
-            
-        } else {
-            break
-        }
-        #item 2070004
-        set function [ lindex $_col207 $_ind207 ]
+    foreach function $static {
         #item 209
         print_function $fhandle $function 0
-        #item 2070003
-        incr _ind207
     }
-    #item 2190001
-    set _col219 $public
-    set _len219 [ llength $_col219 ]
-    set _ind219 0
-    while { 1 } {
-        #item 2190002
-        if {$_ind219 < $_len219} {
-            
-        } else {
-            break
-        }
-        #item 2190004
-        set function [ lindex $_col219 $_ind219 ]
+    foreach function $public {
         #item 221
         print_function $fhandle $function 0
-        #item 2190003
-        incr _ind219
     }
     #item 210
     puts $fhandle $footer
@@ -461,24 +404,10 @@ proc print_function { fhandle function declaration } {
     #item 228
     unpack $signature type access parameters returns
     set param_names {}
-    #item 2360001
-    set _col236 $parameters
-    set _len236 [ llength $_col236 ]
-    set _ind236 0
-    while { 1 } {
-        #item 2360002
-        if {$_ind236 < $_len236} {
-            
-        } else {
-            break
-        }
-        #item 2360004
-        set parameter [ lindex $_col236 $_ind236 ]
+    foreach parameter $parameters {
         #item 235
         set pname [ lindex $parameter 0 ]
         lappend param_names $pname
-        #item 2360003
-        incr _ind236
     }
     #item 503
     set param_count [ llength $param_names ]
@@ -547,23 +476,9 @@ proc print_header { filename fhandle functions header footer } {
     #item 183
     puts $fhandle ""
     puts $fhandle $header
-    #item 1840001
-    set _col184 $functions
-    set _len184 [ llength $_col184 ]
-    set _ind184 0
-    while { 1 } {
-        #item 1840002
-        if {$_ind184 < $_len184} {
-            
-        } else {
-            break
-        }
-        #item 1840004
-        set function [ lindex $_col184 $_ind184 ]
+    foreach function $functions {
         #item 186
         print_function $fhandle $function 1
-        #item 1840003
-        incr _ind184
     }
     #item 187
     puts $fhandle $footer
@@ -576,19 +491,7 @@ proc print_switches { output node_list } {
     #item 558
     upvar 1 $output result
     array set nodes $node_list
-    #item 5590001
-    set _col559 [ array names nodes ]
-    set _len559 [ llength $_col559 ]
-    set _ind559 0
-    while { 1 } {
-        #item 5590002
-        if {$_ind559 < $_len559} {
-            
-        } else {
-            break
-        }
-        #item 5590004
-        set item_id [ lindex $_col559 $_ind559 ]
+    foreach item_id [ array names nodes ] {
         #item 561
         set node $nodes($item_id)	
         unpack $node body links
@@ -601,8 +504,6 @@ proc print_switches { output node_list } {
         } else {
             
         }
-        #item 5590003
-        incr _ind559
     }
 }
 

File diff suppressed because it is too large
+ 72 - 880
generators/cpp.tcl


BIN
generators/cs.drn


+ 22 - 249
generators/cs.tcl

@@ -117,19 +117,7 @@ yield
 proc add_handlers { gdb machines functions } {
     #item 1580
     set result {}
-    #item 15770001
-    set _col1577 $machines
-    set _len1577 [ llength $_col1577 ]
-    set _ind1577 0
-    while { 1 } {
-        #item 15770002
-        if {$_ind1577 < $_len1577} {
-            
-        } else {
-            break
-        }
-        #item 15770004
-        set machine [ lindex $_col1577 $_ind1577 ]
+    foreach machine $machines {
         #item 1579
         set name [ dict get $machine "name" ]
         #item 1583
@@ -140,30 +128,14 @@ proc add_handlers { gdb machines functions } {
         } ]
         #item 1611
         set handlers {}
-        #item 16090001
-        set _col1609 $handler_ids
-        set _len1609 [ llength $_col1609 ]
-        set _ind1609 0
-        while { 1 } {
-            #item 16090002
-            if {$_ind1609 < $_len1609} {
-                
-            } else {
-                break
-            }
-            #item 16090004
-            set id [ lindex $_col1609 $_ind1609 ]
+        foreach id $handler_ids {
             #item 1588
             lappend handlers [ find_function $functions $id ]
-            #item 16090003
-            incr _ind1609
         }
         #item 1589
         lappend machine "handlers" $handlers
         #item 1582
         lappend result $machine
-        #item 15770003
-        incr _ind1577
     }
     #item 1581
     return $result
@@ -277,21 +249,7 @@ proc classify_keywords { keywords name } {
 }
 
 proc extract_body { comments } {
-    #item 16670001
-    set _col1667 $comments
-    set _len1667 [ llength $_col1667 ]
-    set _ind1667 0
-    while { 1 } {
-        #item 16670002
-        if {$_ind1667 < $_len1667} {
-            
-        } else {
-            #item 1673
-            return ""
-            break
-        }
-        #item 16670004
-        set comment [ lindex $_col1667 $_ind1667 ]
+    foreach comment $comments {
         #item 1669
         set trimmed [ string trim $comment ]
         set lines [ split $trimmed "\n" ]
@@ -304,13 +262,12 @@ proc extract_body { comments } {
             set new_text [ join $rest "\n        " ]
             #item 1675
             return $new_text
-            break
         } else {
             
         }
-        #item 16670003
-        incr _ind1667
     }
+    #item 1673
+    return ""
 }
 
 proc extract_class_name { section } {
@@ -370,19 +327,7 @@ proc extract_many_cs_machines { gdb callbacks } {
     #item 1751
     set diagrams [ $gdb eval {
     	select diagram_id from diagrams } ]
-    #item 17520001
-    set _col1752 $diagrams
-    set _len1752 [ llength $_col1752 ]
-    set _ind1752 0
-    while { 1 } {
-        #item 17520002
-        if {$_ind1752 < $_len1752} {
-            
-        } else {
-            break
-        }
-        #item 17520004
-        set diagram_id [ lindex $_col1752 $_ind1752 ]
+    foreach diagram_id $diagrams {
         #item 1754
         if {[graph::is_machine $diagram_id]} {
             #item 1767
@@ -406,8 +351,6 @@ proc extract_many_cs_machines { gdb callbacks } {
         } else {
             
         }
-        #item 17520003
-        incr _ind1752
     }
     #item 1761
     return $result
@@ -556,65 +499,35 @@ proc extract_signature { text name } {
 }
 
 proc find_function { functions id } {
-    #item 16000001
-    set _col1600 $functions
-    set _len1600 [ llength $_col1600 ]
-    set _ind1600 0
-    while { 1 } {
-        #item 16000002
-        if {$_ind1600 < $_len1600} {
-            
-        } else {
-            #item 1608
-            error "procedure $id not found"
-            break
-        }
-        #item 16000004
-        set function [ lindex $_col1600 $_ind1600 ]
+    foreach function $functions {
         #item 1606
         unpack $function diagram_id name
         #item 1602
         if {$diagram_id == $id} {
             #item 1607
             return $function
-            break
         } else {
             
         }
-        #item 16000003
-        incr _ind1600
     }
+    #item 1608
+    error "procedure $id not found"
 }
 
 proc find_function_by_name { functions name } {
-    #item 16460001
-    set _col1646 $functions
-    set _len1646 [ llength $_col1646 ]
-    set _ind1646 0
-    while { 1 } {
-        #item 16460002
-        if {$_ind1646 < $_len1646} {
-            
-        } else {
-            #item 1653
-            return {}
-            break
-        }
-        #item 16460004
-        set function [ lindex $_col1646 $_ind1646 ]
+    foreach function $functions {
         #item 1651
         unpack $function diagram_id fname
         #item 1648
         if {$fname == $name} {
             #item 1652
             return $function
-            break
         } else {
             
         }
-        #item 16460003
-        incr _ind1646
     }
+    #item 1653
+    return {}
 }
 
 proc foreach_check { item_id first second } {
@@ -673,19 +586,7 @@ proc generate { db gdb filename } {
     #item 1089
     set diagrams [ $gdb eval {
     	select diagram_id from diagrams } ]
-    #item 10870001
-    set _col1087 $diagrams
-    set _len1087 [ llength $_col1087 ]
-    set _ind1087 0
-    while { 1 } {
-        #item 10870002
-        if {$_ind1087 < $_len1087} {
-            
-        } else {
-            break
-        }
-        #item 10870004
-        set diagram_id [ lindex $_col1087 $_ind1087 ]
+    foreach diagram_id $diagrams {
         #item 1248
         if {[mwc::is_drakon $diagram_id]} {
             #item 1086
@@ -693,8 +594,6 @@ proc generate { db gdb filename } {
         } else {
             
         }
-        #item 10870003
-        incr _ind1087
     }
     #item 1243
     tab::generate_tables $gdb $callbacks 0
@@ -766,19 +665,7 @@ proc generate_body { gdb diagram_id start_item node_list items incoming } {
 proc handle_message { fhandle ind states message names handlers } {
     #item 1727
     puts $fhandle "$ind            switch \(CurrentState\) \{"
-    #item 17240001
-    set _col1724 $states
-    set _len1724 [ llength $_col1724 ]
-    set _ind1724 0
-    while { 1 } {
-        #item 17240002
-        if {$_ind1724 < $_len1724} {
-            
-        } else {
-            break
-        }
-        #item 17240004
-        set state [ lindex $_col1724 $_ind1724 ]
+    foreach state $states {
         #item 1742
         set message2 [ string map { - _ . _ } $message ]
         #item 1729
@@ -794,8 +681,6 @@ proc handle_message { fhandle ind states message names handlers } {
         }
         #item 1734
         puts $fhandle "$ind                    break;"
-        #item 17240003
-        incr _ind1724
     }
     #item 1726
     puts $fhandle "$ind                default:"
@@ -815,19 +700,7 @@ proc highlight_generic { keywords tokens } {
     set result {}
     #item 1361
     set state "idle"
-    #item 13260001
-    set _col1326 $tokens
-    set _len1326 [ llength $_col1326 ]
-    set _ind1326 0
-    while { 1 } {
-        #item 13260002
-        if {$_ind1326 < $_len1326} {
-            
-        } else {
-            break
-        }
-        #item 13260004
-        set token [ lindex $_col1326 $_ind1326 ]
+    foreach token $tokens {
         #item 1328
         lassign $token type text
         #item 13290001
@@ -1027,8 +900,6 @@ proc highlight_generic { keywords tokens } {
                 }
             }
         }
-        #item 13260003
-        incr _ind1326
     }
     #item 15130001
     if {($state == "comment start") || ($state == "verbatim start")} {
@@ -1418,19 +1289,7 @@ proc print_machine { fhandle machine } {
             #item 1738
             puts $fhandle "        public void OnMessage\($params\) \{"
             puts $fhandle "            switch \(message.Code\) \{"
-            #item 15440001
-            set _col1544 $messages
-            set _len1544 [ llength $_col1544 ]
-            set _ind1544 0
-            while { 1 } {
-                #item 15440002
-                if {$_ind1544 < $_len1544} {
-                    
-                } else {
-                    break
-                }
-                #item 15440004
-                set message [ lindex $_col1544 $_ind1544 ]
+            foreach message $messages {
                 #item 1740
                 puts $fhandle "                case $message:"
                 #item 1737
@@ -1438,8 +1297,6 @@ proc print_machine { fhandle machine } {
                  $message $pnames $handlers
                 #item 1741
                 puts $fhandle "                    break;"
-                #item 15440003
-                incr _ind1544
             }
             #item 1739
             puts $fhandle "                default:"
@@ -1454,91 +1311,35 @@ proc print_machine { fhandle machine } {
             set pnames [ lrange $param_names 1 end ]
             #item 1697
             set arg_name_list [ join $pnames ", " ]
-            #item 16990001
-            set _col1699 $messages
-            set _len1699 [ llength $_col1699 ]
-            set _ind1699 0
-            while { 1 } {
-                #item 16990002
-                if {$_ind1699 < $_len1699} {
-                    
-                } else {
-                    break
-                }
-                #item 16990004
-                set message [ lindex $_col1699 $_ind1699 ]
+            foreach message $messages {
                 #item 1698
                 print_handler $fhandle \
                   $states $message $params $arg_name_list \
                   $handlers
-                #item 16990003
-                incr _ind1699
             }
         }
     }
-    #item 17820001
-    set _col1782 $handlers
-    set _len1782 [ llength $_col1782 ]
-    set _ind1782 0
-    while { 1 } {
-        #item 17820002
-        if {$_ind1782 < $_len1782} {
-            
-        } else {
-            break
-        }
-        #item 17820004
-        set procedure [ lindex $_col1782 $_ind1782 ]
+    foreach procedure $handlers {
         #item 1791
         unpack $procedure _ proc_name
         #item 1784
         p.print_proc $weak $fhandle $procedure "" 2
-        #item 17820003
-        incr _ind1782
     }
     #item 1542
     puts $fhandle "    \}"
 }
 
 proc print_machines { fhandle machines } {
-    #item 15380001
-    set _col1538 $machines
-    set _len1538 [ llength $_col1538 ]
-    set _ind1538 0
-    while { 1 } {
-        #item 15380002
-        if {$_ind1538 < $_len1538} {
-            
-        } else {
-            break
-        }
-        #item 15380004
-        set machine [ lindex $_col1538 $_ind1538 ]
+    foreach machine $machines {
         #item 1540
         print_machine $fhandle $machine
-        #item 15380003
-        incr _ind1538
     }
 }
 
 proc print_procs { weak_signature fhandle procedures class_name depth } {
-    #item 9630001
-    set _col963 $procedures
-    set _len963 [ llength $_col963 ]
-    set _ind963 0
-    while { 1 } {
-        #item 9630002
-        if {$_ind963 < $_len963} {
-            
-        } else {
-            break
-        }
-        #item 9630004
-        set procedure [ lindex $_col963 $_ind963 ]
+    foreach procedure $procedures {
         #item 965
         p.print_proc $weak_signature $fhandle $procedure $class_name $depth
-        #item 9630003
-        incr _ind963
     }
 }
 
@@ -1571,19 +1372,7 @@ proc print_state_class { fhandle messages iface name parameters lines } {
     puts $fhandle "        public string Name \{ get \{ return \"$name\"; \} \}"
     #item 1221
     set i 0
-    #item 12040001
-    set _col1204 $messages
-    set _len1204 [ llength $_col1204 ]
-    set _ind1204 0
-    while { 1 } {
-        #item 12040002
-        if {$_ind1204 < $_len1204} {
-            
-        } else {
-            break
-        }
-        #item 12040004
-        set message [ lindex $_col1204 $_ind1204 ]
+    foreach message $messages {
         #item 1206
         puts $fhandle "        public void $message\($parameters\) \{"
         #item 1223
@@ -1593,8 +1382,6 @@ proc print_state_class { fhandle messages iface name parameters lines } {
         puts $fhandle "        \}"
         #item 1222
         incr i
-        #item 12040003
-        incr _ind1204
     }
     #item 1203
     puts $fhandle "    \}"
@@ -1620,19 +1407,7 @@ proc separate_methods { gdb all_functions functions_name methods_name } {
     #item 1275
     array set methods_by_class {}
     set functions {}
-    #item 12710001
-    set _col1271 $all_functions
-    set _len1271 [ llength $_col1271 ]
-    set _ind1271 0
-    while { 1 } {
-        #item 12710002
-        if {$_ind1271 < $_len1271} {
-            
-        } else {
-            break
-        }
-        #item 12710004
-        set function [ lindex $_col1271 $_ind1271 ]
+    foreach function $all_functions {
         #item 1274
         lassign $function diagram_id name signature body
         #item 1568
@@ -1673,8 +1448,6 @@ proc separate_methods { gdb all_functions functions_name methods_name } {
                 lappend functions $function
             }
         }
-        #item 12710003
-        incr _ind1271
     }
     #item 1292
     set methods [ array get methods_by_class ]

+ 3 - 18
generators/cycle_body.tcl

@@ -292,21 +292,7 @@ proc p.jump { output item_id base depth next_item_id has_text items i } {
 }
 
 proc p.one_exit { links item_id } {
-    #item 1910001
-    set _col191 $links
-    set _len191 [ llength $_col191 ]
-    set _ind191 0
-    while { 1 } {
-        #item 1910002
-        if {$_ind191 < $_len191} {
-            
-        } else {
-            #item 204
-            return $found
-            break
-        }
-        #item 1910004
-        set link [ lindex $_col191 $_ind191 ]
+    foreach link $links {
         #item 190
         set linked_item [ lindex $link 0 ]
         #item 238
@@ -322,12 +308,11 @@ proc p.one_exit { links item_id } {
             } else {
                 #item 205
                 return 0
-                break
             }
         }
-        #item 1910003
-        incr _ind191
     }
+    #item 204
+    return $found
 }
 
 proc save_callbacks { callbacks } {

+ 5 - 1
generators/d.tcl

@@ -378,7 +378,11 @@ proc p.not { operand } {
 
 # Declares and inits a variable
 proc declare { type name value } {
-    return "$type $name = $value;"
+    if { $value == "" } {
+	return "$type $name;"
+    } else {
+	return "$type $name = $value;"
+    }
 }
 
 # Builds code for a __shelf__ icon.

BIN
generators/java.drn


+ 11 - 47
generators/java.tcl

@@ -542,24 +542,10 @@ proc p.build_declaration { name signature } {
     #item 103
     unpack $signature type access parameters returns
     set param_names {}
-    #item 1050001
-    set _col105 $parameters
-    set _len105 [ llength $_col105 ]
-    set _ind105 0
-    while { 1 } {
-        #item 1050002
-        if {$_ind105 < $_len105} {
-            
-        } else {
-            break
-        }
-        #item 1050004
-        set parameter [ lindex $_col105 $_ind105 ]
+    foreach parameter $parameters {
         #item 104
         set pname [ lindex $parameter 0 ]
         lappend param_names $pname
-        #item 1050003
-        incr _ind105
     }
     #item 107
     set param_string [ join $param_names ", " ]
@@ -572,8 +558,14 @@ proc p.continue { } {
 }
 
 proc p.declare { type name value } {
-    #item 656
-    return "$type $name = $value;"
+    #item 1099
+    if {$value == ""} {
+        #item 1102
+        return "$type $name;"
+    } else {
+        #item 656
+        return "$type $name = $value;"
+    }
 }
 
 proc p.not { operand } {
@@ -643,19 +635,7 @@ proc p.print_proc { fhandle procedure class_name } {
     append header "$name\("
     #item 1021
     set i 0
-    #item 10190001
-    set _col1019 $parameters
-    set _len1019 [ llength $_col1019 ]
-    set _ind1019 0
-    while { 1 } {
-        #item 10190002
-        if {$_ind1019 < $_len1019} {
-            
-        } else {
-            break
-        }
-        #item 10190004
-        set parameter [ lindex $_col1019 $_ind1019 ]
+    foreach parameter $parameters {
         #item 1024
         if {$i == 0} {
             
@@ -668,8 +648,6 @@ proc p.print_proc { fhandle procedure class_name } {
         append header $arg
         #item 1022
         incr i
-        #item 10190003
-        incr _ind1019
     }
     #item 1031
     append header "\)"
@@ -748,23 +726,9 @@ proc pass { } {
 }
 
 proc print_procs { fhandle procedures class_name } {
-    #item 9630001
-    set _col963 $procedures
-    set _len963 [ llength $_col963 ]
-    set _ind963 0
-    while { 1 } {
-        #item 9630002
-        if {$_ind963 < $_len963} {
-            
-        } else {
-            break
-        }
-        #item 9630004
-        set procedure [ lindex $_col963 $_ind963 ]
+    foreach procedure $procedures {
         #item 965
         p.print_proc $fhandle $procedure $class_name
-        #item 9630003
-        incr _ind963
     }
 }
 

BIN
generators/lua.drn


+ 24 - 228
generators/lua.tcl

@@ -82,8 +82,14 @@ proc compare { variable constant } {
 }
 
 proc declare { type name value } {
-    #item 1434
-    return "local $name = $value"
+    #item 2094
+    if {$value == ""} {
+        #item 2097
+        return "local $name"
+    } else {
+        #item 1434
+        return "local $name = $value"
+    }
 }
 
 proc else_start { } {
@@ -223,23 +229,9 @@ proc generate { db gdb filename } {
     	from vertices
     	group by diagram_id
     } ]
-    #item 17680001
-    set _col1768 $diagrams
-    set _len1768 [ llength $_col1768 ]
-    set _ind1768 0
-    while { 1 } {
-        #item 17680002
-        if {$_ind1768 < $_len1768} {
-            
-        } else {
-            break
-        }
-        #item 17680004
-        set diagram_id [ lindex $_col1768 $_ind1768 ]
+    foreach diagram_id $diagrams {
         #item 1766
         rewire_lua_for $gdb $diagram_id
-        #item 17680003
-        incr _ind1768
     }
     #item 1284
     set callbacks [ make_callbacks ]
@@ -256,23 +248,9 @@ proc generate { db gdb filename } {
     #item 1812
     set diagrams [ $gdb eval {
     	select diagram_id from diagrams } ]
-    #item 18100001
-    set _col1810 $diagrams
-    set _len1810 [ llength $_col1810 ]
-    set _ind1810 0
-    while { 1 } {
-        #item 18100002
-        if {$_ind1810 < $_len1810} {
-            
-        } else {
-            break
-        }
-        #item 18100004
-        set diagram_id [ lindex $_col1810 $_ind1810 ]
+    foreach diagram_id $diagrams {
         #item 1809
         gen::fix_graph_for_diagram $gdb $callbacks 0 $diagram_id
-        #item 18100003
-        incr _ind1810
     }
     #item 1279
     set sections { header footer }
@@ -327,19 +305,7 @@ proc highlight { tokens } {
     set state "idle"
     #item 1976
     variable keywords
-    #item 19420001
-    set _col1942 $tokens
-    set _len1942 [ llength $_col1942 ]
-    set _ind1942 0
-    while { 1 } {
-        #item 19420002
-        if {$_ind1942 < $_len1942} {
-            
-        } else {
-            break
-        }
-        #item 19420004
-        set token [ lindex $_col1942 $_ind1942 ]
+    foreach token $tokens {
         #item 2024
         lassign $token type text
         #item 19370001
@@ -474,8 +440,6 @@ proc highlight { tokens } {
                 }
             }
         }
-        #item 19420003
-        incr _ind1942
     }
     #item 2082
     if {$state == "comment start"} {
@@ -618,42 +582,14 @@ proc make_callbacks { } {
 proc make_machine_ctr { name states param_names messages } {
     #item 1890
     set lines {}
-    #item 18880001
-    set _col1888 $states
-    set _len1888 [ llength $_col1888 ]
-    set _ind1888 0
-    while { 1 } {
-        #item 18880002
-        if {$_ind1888 < $_len1888} {
-            
-        } else {
-            break
-        }
-        #item 18880004
-        set state [ lindex $_col1888 $_ind1888 ]
-        #item 18930001
-        set _col1893 $messages
-        set _len1893 [ llength $_col1893 ]
-        set _ind1893 0
-        while { 1 } {
-            #item 18930002
-            if {$_ind1893 < $_len1893} {
-                
-            } else {
-                break
-            }
-            #item 18930004
-            set message [ lindex $_col1893 $_ind1893 ]
+    foreach state $states {
+        foreach message $messages {
             #item 1895
             lappend lines \
              "${name}_state_${state}.$message = ${name}_${state}_${message}"
-            #item 18930003
-            incr _ind1893
         }
         #item 1896
         lappend lines "${name}_state_${state}.state_name = \"$state\""
-        #item 18880003
-        incr _ind1888
     }
     #item 1899
     set params [ lrange $param_names 1 end ]
@@ -669,19 +605,7 @@ proc make_machine_ctr { name states param_names messages } {
     #item 1903
     set first [ lindex $states 0 ]
     lappend lines "  obj.state = ${name}_state_${first}"
-    #item 19000001
-    set _col1900 $messages
-    set _len1900 [ llength $_col1900 ]
-    set _ind1900 0
-    while { 1 } {
-        #item 19000002
-        if {$_ind1900 < $_len1900} {
-            
-        } else {
-            break
-        }
-        #item 19000004
-        set message [ lindex $_col1900 $_ind1900 ]
+    foreach message $messages {
         #item 1904
         lappend lines \
          "  obj.$message = function\($params_str\)"
@@ -689,8 +613,6 @@ proc make_machine_ctr { name states param_names messages } {
          "    self.state.$message\($params_str\)"
         lappend lines \
          "  end"
-        #item 19000003
-        incr _ind1900
     }
     #item 1898
     lappend lines "  return obj"
@@ -702,19 +624,7 @@ proc make_machine_ctr { name states param_names messages } {
 proc make_machine_ctrs { machines } {
     #item 1869
     set result ""
-    #item 18670001
-    set _col1867 $machines
-    set _len1867 [ llength $_col1867 ]
-    set _ind1867 0
-    while { 1 } {
-        #item 18670002
-        if {$_ind1867 < $_len1867} {
-            
-        } else {
-            break
-        }
-        #item 18670004
-        set machine [ lindex $_col1867 $_ind1867 ]
+    foreach machine $machines {
         #item 1864
         set states [ dict get $machine "states"]
         set param_names [ dict get $machine "param_names" ]
@@ -725,8 +635,6 @@ proc make_machine_ctrs { machines } {
         [make_machine_ctr $name $states $param_names $messages]
         #item 1863
         append result $ctr
-        #item 18670003
-        incr _ind1867
     }
     #item 1843
     return $result
@@ -735,42 +643,14 @@ proc make_machine_ctrs { machines } {
 proc make_machine_declares { machines } {
     #item 1913
     set lines {}
-    #item 19110001
-    set _col1911 $machines
-    set _len1911 [ llength $_col1911 ]
-    set _ind1911 0
-    while { 1 } {
-        #item 19110002
-        if {$_ind1911 < $_len1911} {
-            
-        } else {
-            break
-        }
-        #item 19110004
-        set machine [ lindex $_col1911 $_ind1911 ]
+    foreach machine $machines {
         #item 1910
         set states [ dict get $machine "states"]
         set name [ dict get $machine "name" ]
-        #item 19180001
-        set _col1918 $states
-        set _len1918 [ llength $_col1918 ]
-        set _ind1918 0
-        while { 1 } {
-            #item 19180002
-            if {$_ind1918 < $_len1918} {
-                
-            } else {
-                break
-            }
-            #item 19180004
-            set state [ lindex $_col1918 $_ind1918 ]
+        foreach state $states {
             #item 1914
             lappend lines "${name}_state_${state} = \{\}"
-            #item 19180003
-            incr _ind1918
         }
-        #item 19110003
-        incr _ind1911
     }
     #item 1915
     return [ join $lines "\n" ]
@@ -903,43 +783,15 @@ proc print_function { fhandle function } {
         append line "\)"
         #item 552
         lappend result $line
-        #item 5830001
-        set _col583 $body
-        set _len583 [ llength $_col583 ]
-        set _ind583 0
-        while { 1 } {
-            #item 5830002
-            if {$_ind583 < $_len583} {
-                
-            } else {
-                break
-            }
-            #item 5830004
-            set line [ lindex $_col583 $_ind583 ]
+        foreach line $body {
             #item 582
             lappend result "    $line"
-            #item 5830003
-            incr _ind583
         }
         #item 585
         lappend result "end"
-        #item 10200001
-        set _col1020 $result
-        set _len1020 [ llength $_col1020 ]
-        set _ind1020 0
-        while { 1 } {
-            #item 10200002
-            if {$_ind1020 < $_len1020} {
-                
-            } else {
-                break
-            }
-            #item 10200004
-            set line [ lindex $_col1020 $_ind1020 ]
+        foreach line $result {
             #item 1022
             puts $fhandle $line
-            #item 10200003
-            incr _ind1020
         }
         #item 1023
         puts $fhandle ""
@@ -953,23 +805,9 @@ proc print_to_file { fhandle functions header footer machine_decl machine_ctrs }
     puts $fhandle $header
     #item 1917
     puts $fhandle $machine_decl
-    #item 15680001
-    set _col1568 $functions
-    set _len1568 [ llength $_col1568 ]
-    set _ind1568 0
-    while { 1 } {
-        #item 15680002
-        if {$_ind1568 < $_len1568} {
-            
-        } else {
-            break
-        }
-        #item 15680004
-        set function [ lindex $_col1568 $_ind1568 ]
+    foreach function $functions {
         #item 1570
         print_function $fhandle $function
-        #item 15680003
-        incr _ind1568
     }
     #item 1819
     puts $fhandle $machine_ctrs
@@ -1000,19 +838,7 @@ proc rewire_lua_for { gdb diagram_id } {
     } ]
     #item 1733
     set loop_vars {}
-    #item 17340001
-    set _col1734 $starts
-    set _len1734 [ llength $_col1734 ]
-    set _ind1734 0
-    while { 1 } {
-        #item 17340002
-        if {$_ind1734 < $_len1734} {
-            
-        } else {
-            break
-        }
-        #item 17340004
-        set vertex_id [ lindex $_col1734 $_ind1734 ]
+    foreach vertex_id $starts {
         #item 1736
         unpack [ $gdb eval { 
         	select text, item_id
@@ -1031,8 +857,6 @@ proc rewire_lua_for { gdb diagram_id } {
         }
         #item 1740
         lappend loop_vars $var
-        #item 17340003
-        incr _ind1734
     }
     #item 1753
     set var_list [ lsort -unique $loop_vars ]
@@ -1045,7 +869,7 @@ proc rewire_lua_for { gdb diagram_id } {
         #item 1756
         set declaration "local $vars_comma"
         #item 1757
-        gen::p.save_declare_kernel $gdb $diagram_id $declaration 1
+        gen::p.save_declare_kernel $gdb $diagram_id $declaration 0
     }
 }
 
@@ -1059,19 +883,7 @@ proc split_vars { $item_id var_list } {
     set raw [ split $var_list "," ]
     #item 1653
     set result {}
-    #item 16550001
-    set _col1655 $raw
-    set _len1655 [ llength $_col1655 ]
-    set _ind1655 0
-    while { 1 } {
-        #item 16550002
-        if {$_ind1655 < $_len1655} {
-            
-        } else {
-            break
-        }
-        #item 16550004
-        set part [ lindex $_col1655 $_ind1655 ]
+    foreach part $raw {
         #item 1657
         set stripped [ string trim $part ]
         #item 1658
@@ -1081,8 +893,6 @@ proc split_vars { $item_id var_list } {
             #item 1661
             lappend result $stripped
         }
-        #item 16550003
-        incr _ind1655
     }
     #item 1663
     if {$result == {}} {
@@ -1105,19 +915,7 @@ proc to_tokens { text } {
     set tokens [ search::to_tokens $text ]
     #item 1701
     set result {}
-    #item 17030001
-    set _col1703 $tokens
-    set _len1703 [ llength $_col1703 ]
-    set _ind1703 0
-    while { 1 } {
-        #item 17030002
-        if {$_ind1703 < $_len1703} {
-            
-        } else {
-            break
-        }
-        #item 17030004
-        set token [ lindex $_col1703 $_ind1703 ]
+    foreach token $tokens {
         #item 1705
         set text [ lindex $token 0 ]
         #item 1706
@@ -1129,8 +927,6 @@ proc to_tokens { text } {
             #item 1707
             lappend result $text
         }
-        #item 17030003
-        incr _ind1703
     }
     #item 1702
     return $result

+ 17 - 201
generators/machine.tcl

@@ -188,19 +188,7 @@ proc build_machine { gdb diagram_id callbacks } {
             set state_names {}
             #item 755
             set boiler {}
-            #item 3540001
-            set _col354 $state_headers
-            set _len354 [ llength $_col354 ]
-            set _ind354 0
-            while { 1 } {
-                #item 3540002
-                if {$_ind354 < $_len354} {
-                    
-                } else {
-                    break
-                }
-                #item 3540004
-                set header [ lindex $_col354 $_ind354 ]
+            foreach header $state_headers {
                 #item 754
                 lassign \
                 [create_sub_diagrams $gdb $diagram_id $header $message_types \
@@ -210,8 +198,6 @@ proc build_machine { gdb diagram_id callbacks } {
                 lappend boiler $state \
                  [ list "good" $good "bad" $bad ]
                 lappend state_names $state
-                #item 3540003
-                incr _ind354
             }
             #item 882
             set last_header [ lindex $headers end ]
@@ -348,19 +334,7 @@ proc copy_vertexes { gdb new_diagram vertex_id last end callbacks prev_new } {
             #item 553
             set next [ find_next $gdb $vertex_id ]
             set i 1
-            #item 5540001
-            set _col554 $next
-            set _len554 [ llength $_col554 ]
-            set _ind554 0
-            while { 1 } {
-                #item 5540002
-                if {$_ind554 < $_len554} {
-                    
-                } else {
-                    break
-                }
-                #item 5540004
-                set next_vertex [ lindex $_col554 $_ind554 ]
+            foreach next_vertex $next {
                 #item 558
                 set new_next \
                 [copy_vertexes $gdb $new_diagram $next_vertex \
@@ -369,8 +343,6 @@ proc copy_vertexes { gdb new_diagram vertex_id last end callbacks prev_new } {
                 connect $gdb $new_vertex $new_next $i
                 #item 556
                 incr i
-                #item 5540003
-                incr _ind554
             }
         }
     }
@@ -389,19 +361,7 @@ proc create_sub_diagrams { gdb diagram_id header message_types parameters last_b
     set has_default [ contains $types "" ]
     #item 494
     set redirected {}
-    #item 4870001
-    set _col487 $message_types
-    set _len487 [ llength $_col487 ]
-    set _ind487 0
-    while { 1 } {
-        #item 4870002
-        if {$_ind487 < $_len487} {
-            
-        } else {
-            break
-        }
-        #item 4870004
-        set common_type [ lindex $_col487 $_ind487 ]
+    foreach common_type $message_types {
         #item 490
         if {[contains $types $common_type]} {
             
@@ -409,32 +369,16 @@ proc create_sub_diagrams { gdb diagram_id header message_types parameters last_b
             #item 495
             lappend redirected $common_type
         }
-        #item 4870003
-        incr _ind487
     }
     #item 526
     set next [ find_next $gdb $select ]
     set i 0
-    #item 4990001
-    set _col499 $next
-    set _len499 [ llength $_col499 ]
-    set _ind499 0
-    while { 1 } {
-        #item 4990002
-        if {$_ind499 < $_len499} {
-            
-        } else {
-            break
-        }
-        #item 4990004
-        set case [ lindex $_col499 $_ind499 ]
+    foreach case $next {
         #item 502
         build_sub_diagram $gdb $diagram_id $state $case \
          $parameters $last_branch $callbacks $i
         #item 845
         incr i
-        #item 4990003
-        incr _ind499
     }
     #item 503
     if {$redirected == {}} {
@@ -497,21 +441,7 @@ proc extract_machine { gdb callbacks } {
     #item 132
     set diagrams [ $gdb eval {
     	select diagram_id from diagrams } ]
-    #item 1330001
-    set _col133 $diagrams
-    set _len133 [ llength $_col133 ]
-    set _ind133 0
-    while { 1 } {
-        #item 1330002
-        if {$_ind133 < $_len133} {
-            
-        } else {
-            #item 138
-            return {}
-            break
-        }
-        #item 1330004
-        set diagram_id [ lindex $_col133 $_ind133 ]
+    foreach diagram_id $diagrams {
         #item 135
         if {[graph::is_machine $diagram_id]} {
             #item 148
@@ -520,13 +450,12 @@ proc extract_machine { gdb callbacks } {
             delete_diagram $gdb $diagram_id
             #item 139
             return $info
-            break
         } else {
             
         }
-        #item 1330003
-        incr _ind133
     }
+    #item 138
+    return {}
 }
 
 proc extract_many_machines { gdb callbacks } {
@@ -535,19 +464,7 @@ proc extract_many_machines { gdb callbacks } {
     #item 857
     set diagrams [ $gdb eval {
     	select diagram_id from diagrams } ]
-    #item 8580001
-    set _col858 $diagrams
-    set _len858 [ llength $_col858 ]
-    set _ind858 0
-    while { 1 } {
-        #item 8580002
-        if {$_ind858 < $_len858} {
-            
-        } else {
-            break
-        }
-        #item 8580004
-        set diagram_id [ lindex $_col858 $_ind858 ]
+    foreach diagram_id $diagrams {
         #item 860
         if {[graph::is_machine $diagram_id]} {
             #item 866
@@ -559,8 +476,6 @@ proc extract_many_machines { gdb callbacks } {
         } else {
             
         }
-        #item 8580003
-        incr _ind858
     }
     #item 868
     return $result
@@ -584,19 +499,7 @@ proc find_end { gdb diagram_id } {
 proc find_message_types { gdb headers } {
     #item 465
     set all_types {}
-    #item 4620001
-    set _col462 $headers
-    set _len462 [ llength $_col462 ]
-    set _ind462 0
-    while { 1 } {
-        #item 4620002
-        if {$_ind462 < $_len462} {
-            
-        } else {
-            break
-        }
-        #item 4620004
-        set header [ lindex $_col462 $_ind462 ]
+    foreach header $headers {
         #item 467
         set select [ gen::p.get_next $gdb $header 1 ]
         #item 464
@@ -605,8 +508,6 @@ proc find_message_types { gdb headers } {
         set wo_default [ filter2 $types not_empty ]
         #item 466
         set all_types [ concat $all_types $wo_default ]
-        #item 4620003
-        incr _ind462
     }
     #item 468
     set result [ lsort -unique $all_types ]
@@ -677,26 +578,12 @@ proc get_new_vertex_id { vertex_id } {
 proc get_param_names { parameters } {
     #item 772
     set result {}
-    #item 7740001
-    set _col774 $parameters
-    set _len774 [ llength $_col774 ]
-    set _ind774 0
-    while { 1 } {
-        #item 7740002
-        if {$_ind774 < $_len774} {
-            
-        } else {
-            break
-        }
-        #item 7740004
-        set par [ lindex $_col774 $_ind774 ]
+    foreach par $parameters {
         #item 776
         set parts [ split $par " \t" ]
         set last [ lindex $parts end ]
         #item 777
         lappend result $last
-        #item 7740003
-        incr _ind774
     }
     #item 773
     return $result
@@ -722,19 +609,7 @@ proc get_params_text { gdb diagram_id } {
             set lines [ split $text "\n" ]
             #item 330
             set result {}
-            #item 3280001
-            set _col328 $lines
-            set _len328 [ llength $_col328 ]
-            set _ind328 0
-            while { 1 } {
-                #item 3280002
-                if {$_ind328 < $_len328} {
-                    
-                } else {
-                    break
-                }
-                #item 3280004
-                set line [ lindex $_col328 $_ind328 ]
+            foreach line $lines {
                 #item 334
                 set trimmed [ string trim $line ]
                 #item 335
@@ -744,8 +619,6 @@ proc get_params_text { gdb diagram_id } {
                     #item 340
                     lappend result $trimmed
                 }
-                #item 3280003
-                incr _ind328
             }
             #item 332
             return $result
@@ -769,19 +642,7 @@ proc get_receives { gdb diagram_id } {
     	where diagram_id = :diagram_id } ]
     #item 254
     set result {}
-    #item 2560001
-    set _col256 $vertexes
-    set _len256 [ llength $_col256 ]
-    set _ind256 0
-    while { 1 } {
-        #item 2560002
-        if {$_ind256 < $_len256} {
-            
-        } else {
-            break
-        }
-        #item 2560004
-        set vertex_id [ lindex $_col256 $_ind256 ]
+    foreach vertex_id $vertexes {
         #item 258
         if {[is_receive $gdb $vertex_id]} {
             #item 261
@@ -789,8 +650,6 @@ proc get_receives { gdb diagram_id } {
         } else {
             
         }
-        #item 2560003
-        incr _ind256
     }
     #item 255
     return $result
@@ -936,25 +795,11 @@ proc message_types_for_select { gdb select } {
     set next [ find_next $gdb $select ]
     #item 409
     set result {}
-    #item 4110001
-    set _col411 $next
-    set _len411 [ llength $_col411 ]
-    set _ind411 0
-    while { 1 } {
-        #item 4110002
-        if {$_ind411 < $_len411} {
-            
-        } else {
-            break
-        }
-        #item 4110004
-        set case [ lindex $_col411 $_ind411 ]
+    foreach case $next {
         #item 413
         set text [ get_text $gdb $case ]
         #item 417
         lappend result $text
-        #item 4110003
-        incr _ind411
     }
     #item 410
     return $result
@@ -1018,43 +863,15 @@ proc print_vertex { gdb vertex_id } {
         set next [ find_next $gdb $vertex_id ]
         #item 733
         puts "  $next"
-        #item 7390001
-        set _col739 $next
-        set _len739 [ llength $_col739 ]
-        set _ind739 0
-        while { 1 } {
-            #item 7390002
-            if {$_ind739 < $_len739} {
-                
-            } else {
-                break
-            }
-            #item 7390004
-            set next_id [ lindex $_col739 $_ind739 ]
+        foreach next_id $next {
             #item 741
             print_vertex $gdb $next_id
-            #item 7390003
-            incr _ind739
         }
     }
 }
 
 proc receives_are_first { gdb receives } {
-    #item 2320001
-    set _col232 $receives
-    set _len232 [ llength $_col232 ]
-    set _ind232 0
-    while { 1 } {
-        #item 2320002
-        if {$_ind232 < $_len232} {
-            
-        } else {
-            #item 307
-            return 1
-            break
-        }
-        #item 2320004
-        set receive [ lindex $_col232 $_ind232 ]
+    foreach receive $receives {
         #item 234
         if {[ previous_is_header $gdb $receive ]} {
             
@@ -1064,11 +881,10 @@ proc receives_are_first { gdb receives } {
              "A 'receive' icon must be first in the branch."
             #item 308
             return 0
-            break
         }
-        #item 2320003
-        incr _ind232
     }
+    #item 307
+    return 1
 }
 
 proc register_last { } {

+ 4 - 60
generators/node_sorter.tcl

@@ -106,24 +106,10 @@ proc complete_construction { } {
         #item 116
         set links [ $db eval {
         	select link_id from links } ]
-        #item 1180001
-        set _col118 $links
-        set _len118 [ llength $_col118 ]
-        set _ind118 0
-        while { 1 } {
-            #item 1180002
-            if {$_ind118 < $_len118} {
-                
-            } else {
-                break
-            }
-            #item 1180004
-            set link_id [ lindex $_col118 $_ind118 ]
+        foreach link_id $links {
             #item 119
             set dst [ get_link_dst $link_id ]
             add_incoming $dst
-            #item 1180003
-            incr _ind118
         }
     } else {
         #item 112
@@ -171,19 +157,7 @@ proc find_backward_recursive { node_id before } {
         set links [ get_node_links $node_id ]
         #item 238
         set new_before [ linsert $before end $node_id ]
-        #item 2340001
-        set _col234 $links
-        set _len234 [ llength $_col234 ]
-        set _ind234 0
-        while { 1 } {
-            #item 2340002
-            if {$_ind234 < $_len234} {
-                
-            } else {
-                break
-            }
-            #item 2340004
-            set link_id [ lindex $_col234 $_ind234 ]
+        foreach link_id $links {
             #item 235
             set dst [ get_link_dst $link_id ]
             #item 236
@@ -196,8 +170,6 @@ proc find_backward_recursive { node_id before } {
                 #item 239
                 find_backward_recursive $dst $new_before
             }
-            #item 2340003
-            incr _ind234
         }
     }
 }
@@ -362,25 +334,11 @@ proc remember_incoming { } {
     set nodes [ $db eval {
     	select node_id from nodes
     } ]
-    #item 3290001
-    set _col329 $nodes
-    set _len329 [ llength $_col329 ]
-    set _ind329 0
-    while { 1 } {
-        #item 3290002
-        if {$_ind329 < $_len329} {
-            
-        } else {
-            break
-        }
-        #item 3290004
-        set node_id [ lindex $_col329 $_ind329 ]
+    foreach node_id $nodes {
         #item 330
         set incoming_links [ get_unique_incoming $node_id ]
         #item 331
         lappend incoming $node_id $incoming_links
-        #item 3290003
-        incr _ind329
     }
 }
 
@@ -429,19 +387,7 @@ proc sort { } {
                 lappend result $current
                 #item 280
                 set links [ get_node_links $current ]
-                #item 2880001
-                set _col288 $links
-                set _len288 [ llength $_col288 ]
-                set _ind288 0
-                while { 1 } {
-                    #item 2880002
-                    if {$_ind288 < $_len288} {
-                        
-                    } else {
-                        break
-                    }
-                    #item 2880004
-                    set link_id [ lindex $_col288 $_ind288 ]
+                foreach link_id $links {
                     #item 296
                     if {[ is_link_backward $link_id ]} {
                         
@@ -450,8 +396,6 @@ proc sort { } {
                         set next [ get_link_dst $link_id ]
                         push stack $next
                     }
-                    #item 2880003
-                    incr _ind288
                 }
             } else {
                 

+ 49 - 236
generators/nogoto.tcl

@@ -9,21 +9,7 @@ variable g_stack {}
 # Autogenerated with DRAKON Editor 1.27
 
 proc after_others { order nodes current } {
-    #item 39730001
-    set _col3973 $nodes
-    set _len3973 [ llength $_col3973 ]
-    set _ind3973 0
-    while { 1 } {
-        #item 39730002
-        if {$_ind3973 < $_len3973} {
-            
-        } else {
-            #item 3983
-            return 1
-            break
-        }
-        #item 39730004
-        set node [ lindex $_col3973 $_ind3973 ]
+    foreach node $nodes {
         #item 3975
         if {$node == $current} {
             
@@ -36,12 +22,11 @@ proc after_others { order nodes current } {
             } else {
                 #item 3982
                 return 0
-                break
             }
         }
-        #item 39730003
-        incr _ind3973
     }
+    #item 3983
+    return 1
 }
 
 proc build_structures { } {
@@ -75,37 +60,22 @@ proc build_structures { } {
 }
 
 proc choose_latest { order nodes } {
-    #item 39600001
-    set _col3960 $nodes
-    set _len3960 [ llength $_col3960 ]
-    set _ind3960 0
-    while { 1 } {
-        #item 39600002
-        if {$_ind3960 < $_len3960} {
-            
-        } else {
-            #item 4103
-            complain [ list \
-             "choose_latest" \
-             "fail" \
-             "nodes=/$nodes/" ]
-            #item 3966
-            return {}
-            break
-        }
-        #item 39600004
-        set current [ lindex $_col3960 $_ind3960 ]
+    foreach current $nodes {
         #item 3963
         if {[ after_others $order $nodes $current ]} {
             #item 3967
             return $current
-            break
         } else {
             
         }
-        #item 39600003
-        incr _ind3960
     }
+    #item 4103
+    complain [ list \
+     "choose_latest" \
+     "fail" \
+     "nodes=/$nodes/" ]
+    #item 3966
+    return {}
 }
 
 proc clear_marked { db } {
@@ -151,23 +121,9 @@ proc ends_with { path node } {
 proc explain_fail { } {
     #item 4083
     variable g_fail_reason
-    #item 40860001
-    set _col4086 $g_fail_reason
-    set _len4086 [ llength $_col4086 ]
-    set _ind4086 0
-    while { 1 } {
-        #item 40860002
-        if {$_ind4086 < $_len4086} {
-            
-        } else {
-            break
-        }
-        #item 40860004
-        set line [ lindex $_col4086 $_ind4086 ]
+    foreach line $g_fail_reason {
         #item 4084
         puts $line
-        #item 40860003
-        incr _ind4086
     }
 }
 
@@ -199,54 +155,9 @@ proc find_block_ends { db start_item } {
          $loop_ifs nogoto::get_loop_id ]
         #item 4056
         set loops [ array names if_by_loop ]
-        #item 36830001
-        set _col3683 $loops
-        set _len3683 [ llength $_col3683 ]
-        set _ind3683 0
-        while { 1 } {
-            #item 36830002
-            if {$_ind3683 < $_len3683} {
-                
-            } else {
-                #item 3724
-                if {[ stray_loops $db ] > 0} {
-                    #item 4099
-                    set msg [ list \
-                     "find_block_ends" \
-                     "stray loops found" ]
-                    #item 4100
-                    complain $msg
-                    #item 3660
-                    set result 0
-                } else {
-                    #item 35190001
-                    set _col3519 $if_recs
-                    set _len3519 [ llength $_col3519 ]
-                    set _ind3519 0
-                    while { 1 } {
-                        #item 35190002
-                        if {$_ind3519 < $_len3519} {
-                            
-                        } else {
-                            break
-                        }
-                        #item 35190004
-                        set record [ lindex $_col3519 $_ind3519 ]
-                        #item 3750
-                        set item_id [ get_value $record "item_id" ]
-                        set if_stop [ get_value $record "if_stop" ]
-                        #item 3760
-                        set_node_if_stop $db $item_id $if_stop
-                        #item 35190003
-                        incr _ind3519
-                    }
-                    #item 3661
-                    set result 1
-                }
-                break
-            }
-            #item 36830004
-            set loop_id [ lindex $_col3683 $_ind3683 ]
+        
+        set normal_3683 1
+        foreach loop_id $loops {
             #item 3686
             set records $if_by_loop($loop_id)
             #item 3693
@@ -262,6 +173,7 @@ proc find_block_ends { db start_item } {
                 complain $msg
                 #item 3660
                 set result 0
+                set normal_3683 0
                 break
             } else {
                 
@@ -270,8 +182,29 @@ proc find_block_ends { db start_item } {
             set_node_loop_break $db $loop_id $break_id
             #item 3723
             set_if_breaks $db $records $break_id $loop_id
-            #item 36830003
-            incr _ind3683
+        }
+        if {$normal_3683 == 1} {
+            #item 3724
+            if {[ stray_loops $db ] > 0} {
+                #item 4099
+                set msg [ list \
+                 "find_block_ends" \
+                 "stray loops found" ]
+                #item 4100
+                complain $msg
+                #item 3660
+                set result 0
+            } else {
+                foreach record $if_recs {
+                    #item 3750
+                    set item_id [ get_value $record "item_id" ]
+                    set if_stop [ get_value $record "if_stop" ]
+                    #item 3760
+                    set_node_if_stop $db $item_id $if_stop
+                }
+                #item 3661
+                set result 1
+            }
         }
     }
     #item 3709
@@ -297,21 +230,7 @@ proc find_common_point { paths } {
     } else {
         #item 3613
         set other_paths [ lrange $paths 1 end ]
-        #item 36100001
-        set _col3610 $first_path
-        set _len3610 [ llength $_col3610 ]
-        set _ind3610 0
-        while { 1 } {
-            #item 36100002
-            if {$_ind3610 < $_len3610} {
-                
-            } else {
-                #item 3619
-                return {}
-                break
-            }
-            #item 36100004
-            set current [ lindex $_col3610 $_ind3610 ]
+        foreach current $first_path {
             #item 3617
             set found_in_all [ all_true_user \
              $other_paths contains $current ]
@@ -319,13 +238,12 @@ proc find_common_point { paths } {
             if {$found_in_all} {
                 #item 3618
                 return $current
-                break
             } else {
                 
             }
-            #item 36100003
-            incr _ind3610
         }
+        #item 3619
+        return {}
     }
 }
 
@@ -641,7 +559,6 @@ proc gen_loop { db item_id ignored } {
         if {[ is_link_up $db $current 0 ]} {
             #item 3886
             return [ list $result $loop_break ]
-            break
         } else {
             
         }
@@ -653,7 +570,6 @@ proc gen_loop { db item_id ignored } {
         if {$subtree == {}} {
             #item 4220
             return {}
-            break
         } else {
             
         }
@@ -709,7 +625,6 @@ proc generate3 { db start_item } {
         if {$current == ""} {
             #item 3770
             return $result
-            break
         } else {
             
         }
@@ -721,7 +636,6 @@ proc generate3 { db start_item } {
         if {$subtree == {}} {
             #item 4201
             return {}
-            break
         } else {
             
         }
@@ -745,7 +659,6 @@ proc generate_if_seq { db start_item if_stop break_loop parent_loop } {
             set current ""
             #item 3821
             return [ list $result $current ]
-            break
         } else {</