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, 9 insertions, 14 deletions
diff --git a/TurtleArt/talogo.py b/TurtleArt/talogo.py
index 3037bb5..e935ea3 100644
--- a/TurtleArt/talogo.py
+++ b/TurtleArt/talogo.py
@@ -194,15 +194,9 @@ class LogoCode:
for b in blocks:
b.unhighlight()
- # Hidden macro expansions
for b in blocks:
- 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']:
+ # Hidden macro expansions
+ if b.name in ['while', 'until', 'forever']:
action_blk, new_blocks = self._expand_forever(b, blk, blocks)
blocks = new_blocks[:]
if b == blk:
@@ -261,10 +255,11 @@ 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)
- if blk in self.tw.block_list.list:
+ # special case: expand 'while' and 'until' primitives
+ try:
code.append((blk.primitive,
self.tw.block_list.list.index(blk)))
- else:
+ except ValueError:
code.append(blk.primitive) # Hidden block
elif len(blk.values) > 0: # Extract the value from content blocks.
if blk.name == 'number':
@@ -855,11 +850,11 @@ class LogoCode:
inflow.connections[i] = action_blk
else:
i = None
- j = None
if outflow is not None:
- if b in outflow.connections:
- j = outflow.connections.index(b)
- outflow.connections[j] = action_blk
+ j = outflow.connections.index(b)
+ outflow.connections[j] = action_blk
+ else:
+ j = None
if until_blk and whileflow is not None:
action_first.connections.append(inflow)