Commits

Bart van Strien committed 5e7372f

Enhance tests, fix bugs that showed up

Comments (0)

Files changed (3)

fplua/compiler.lua

 		for i, v in ipairs(ast) do
 			table.insert(subBlocks, compileItem(v))
 		end
+		local condition = table.remove(subBlocks, 1)
 		output = ("repeat\n%s\nuntil %s"):
-			format(table.remove(subBlocks, 1), table.concat(subBlocks, "\n"))
+			format(table.concat(subBlocks, "\n"), condition)
 	elseif command == "[]" then
 		output = ("(%s)[%s]"):format(ast[1], compileItem(ast[2]))
 	elseif command == "return" then
 			table.insert(word, c)
 		end
 	end
+	assert(#word == 0, "Parentheses don't match")
 	return tree
 end
 
   (print "Correct results have been found")
   (error (.. "It all went to shit, it was " result " but we wanted " 162)))
 
-(print (polynomial
-  {2 8 1 4} 9))
+(local= results {})
+(for= i (8 9)
+  (until (or (== i 8) (== i 9))
+    (table.insert results
+	  (polynomial
+        {2 8 1 4} i))))
 
+(for (i v) (ipairs results)
+  (print v))