Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/TurtleArt/talogo.py
diff options
context:
space:
mode:
Diffstat (limited to 'TurtleArt/talogo.py')
-rw-r--r--TurtleArt/talogo.py23
1 files changed, 14 insertions, 9 deletions
diff --git a/TurtleArt/talogo.py b/TurtleArt/talogo.py
index e935ea3..3037bb5 100644
--- a/TurtleArt/talogo.py
+++ b/TurtleArt/talogo.py
@@ -194,9 +194,15 @@ class LogoCode:
for b in blocks:
b.unhighlight()
+ # Hidden macro expansions
for b in blocks:
- # Hidden macro expansions
- if b.name in ['while', 'until', 'forever']:
+ if b.name in ['while', 'until']:
+ action_blk, new_blocks = self._expand_forever(b, blk, blocks)
+ blocks = new_blocks[:]
+ if b == blk:
+ blk = action_blk
+ for b in blocks:
+ if b.name in ['forever']:
action_blk, new_blocks = self._expand_forever(b, blk, blocks)
blocks = new_blocks[:]
if b == blk:
@@ -255,11 +261,10 @@ class LogoCode:
if len(dock) > 4: # There could be a '(', ')', '[' or ']'.
code.append(dock[4])
if blk.primitive is not None: # make a tuple (prim, blk)
- # special case: expand 'while' and 'until' primitives
- try:
+ if blk in self.tw.block_list.list:
code.append((blk.primitive,
self.tw.block_list.list.index(blk)))
- except ValueError:
+ else:
code.append(blk.primitive) # Hidden block
elif len(blk.values) > 0: # Extract the value from content blocks.
if blk.name == 'number':
@@ -850,11 +855,11 @@ class LogoCode:
inflow.connections[i] = action_blk
else:
i = None
+ j = None
if outflow is not None:
- j = outflow.connections.index(b)
- outflow.connections[j] = action_blk
- else:
- j = None
+ if b in outflow.connections:
+ j = outflow.connections.index(b)
+ outflow.connections[j] = action_blk
if until_blk and whileflow is not None:
action_first.connections.append(inflow)