Commits

Benoît Allard committed 874cd59

Small corrections

Comments (0)

Files changed (8)

+prog-c
+prog-c: prog.py
+	python ../pypy/pypy/translator/goal/translate.py $<

levels/1-easy/1-go-left-2.txt

+0
+4
+-
+>V<1234
+brg.#
+-
+
+rrr
+bbb
+ggg
+-
+rrr
+bbb
+ggg
+
+-
+1:[ V][.>][#<][ 1]

levels/1-easy/2-shuffle-sort.txt

+1
+3
+-
+>V<1234
+
+-
+
+bybyby
+
+-
+bbb
+
+yyy
+-
+1:
+  [ 2][ 3][ 3][ 2][ 1]
+2:
+  [ V][ >]
+3:
+  [ V][ <]

levels/1-easy/3-go-the-distance.txt

+0
+8
+-
+>V<1234
+ry.#
+-
+y
+y
+y
+y
+y
+y
+
+rrrr
+-
+y
+y
+y
+y
+y
+y
+rrrr
+
+-
+1:[ V][.>][r<][ 1]

levels/1-easy/4-color-sort.txt

+1
+3
+-
+>V<1234
+rg.#
+-
+
+ggrgrr
+
+-
+rrr
+
+ggg
+-
+1:[ V][ <][rV][ >][ >][gV][ <][ 1]

levels/1-easy/5-walking-piles.txt

+0
+7
+-
+>V<1234
+b.
+-
+bbbb
+bbbb
+bbbb
+
+
+
+
+-
+
+
+
+
+bbbb
+bbbb
+bbbb
+-
 
     def parse(self, program):
         """ move string to double dimension array """
-        self.code = [[None for i in range(8)] for i in range(4)]
+        self.code = [[Instruction() for i in range(8)] for i in range(4)]
         for line in program:
             fn = int(line[0])
             if fn == 4:
                 pc = frames.pop()
             else:
                 instruction = self.code[pc[0]][pc[1]]
-                if self.crane.matches(instruction.modifier):
+                if self.crane.matches(instruction.modifier) and instruction.code != ' ':
                     code = instruction.code
                     print code
                     if code == 'V':
                     elif code in ('1','2','3','4'):
                         frames.append(pc)
                         pc = [int(code) - 1, -1]
-            print self.asStr()
+                    print self.asStr()
             pc[1] += 1
         return True
 
     goal = lines[6+docklen+1:6+docklen+1+docklen]
     # line 3 + docklen + 1 + docklen + 1 should contains a '-' or such
     raw_code = lines[6+docklen+1+docklen+1:]
-    code = [raw_code[0]]
+    code = []
+    if len(raw_code) > 0:
+        code = [raw_code[0]]
     for line in raw_code[1:]:
         if line.startswith(' '):
             code[-1] += line.lstrip(' ')