diff --git a/Grammar.y b/Grammar.y index 352da9b155a98033576afe61d9aaa45af9931885..ea6b8d51e273161c95e9feb146853e20e54571f9 100644 --- a/Grammar.y +++ b/Grammar.y @@ -3,7 +3,8 @@ module Grammar where import Tokens } -%name parseJulio +%name parse +Julio %tokentype { Token } %error { parseError } %token diff --git a/Julio.hs b/Julio.hs index 37ee4d50a295a3dc6e9c21b6c236070ba42ce36b..8ebb54e9b866f6a71e94d05f671959ad5662eb18 100644 --- a/Julio.hs +++ b/Julio.hs @@ -366,7 +366,11 @@ evaluateJoinH e1 e2 env = do return (TileValue joinedTile) _ -> error "Both operands of joinH should be a Tile" -joinTilesH t1 t2 = zipWith (++) t1 t2 +joinTilesH t1 t2 = do + let equal = length t1 == length t2 + case (equal) of + True -> zipWith (++) t1 t2 + False -> error "Tiles must have the same number of rows to be joined horizontally" --join tiles vertically evaluateJoinV e1 e2 env = do @@ -378,7 +382,12 @@ evaluateJoinV e1 e2 env = do return (TileValue joinedTile) _ -> error "Both operands of joinV should be a Tile" -joinTilesV t1 t2 = t1 ++ t2 +joinTilesV t1 t2 = do + let equal = length (head t1) == length (head t2) + case (equal) of + True -> t1 ++ t2 + False -> error "Tiles must have the same number of columns to be joined vertically" + --export tile