From 3a62b164e7c6115a90a928e00c7383a614296bd7 Mon Sep 17 00:00:00 2001 From: Walter Bender Date: Sat, 07 Jul 2012 00:17:11 +0000 Subject: recommit lost commit 3ff08dcad6a5b25c170631646bef42da9aef2010 --- (limited to 'TurtleArt/talogo.py') diff --git a/TurtleArt/talogo.py b/TurtleArt/talogo.py index c422d29..844f9e3 100644 --- a/TurtleArt/talogo.py +++ b/TurtleArt/talogo.py @@ -195,7 +195,14 @@ class LogoCode: 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,10 +262,10 @@ class LogoCode: 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': -- cgit v0.9.1