From 18b7e778a2a2afc120ded720e90ccb788f24f31a Mon Sep 17 00:00:00 2001 From: Radu Macocian Date: Wed, 27 Jul 2022 17:51:08 +0300 Subject: [PATCH] small changes --- src/PrettyPrinter/Enum.hs | 4 +--- src/Semantic/ExpressionChecker.hs | 2 +- test/Parser/ExpressionSpec.hs | 14 +++++++------- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/PrettyPrinter/Enum.hs b/src/PrettyPrinter/Enum.hs index 8b30d39..87c4300 100644 --- a/src/PrettyPrinter/Enum.hs +++ b/src/PrettyPrinter/Enum.hs @@ -40,6 +40,4 @@ printDisplayName :: String -> EnumValue -> Doc a printDisplayName enumName (MakeEnumValue name _ (Just display)) = "show" <+> pretty enumName <> pretty name <+> "= \"" <> pretty display <> "\"" printDisplayName enumName (MakeEnumValue name _ Nothing) = - "show" <+> pretty enumName <> pretty name <+> "= \"" <> pretty name <> "\"" - - + "show" <+> pretty enumName <> pretty name <+> "= \"" <> pretty name <> "\"" \ No newline at end of file diff --git a/src/Semantic/ExpressionChecker.hs b/src/Semantic/ExpressionChecker.hs index 8256a10..303c496 100644 --- a/src/Semantic/ExpressionChecker.hs +++ b/src/Semantic/ExpressionChecker.hs @@ -266,7 +266,7 @@ checkFunctionCall [] fun args = Left $ UndefinedFunction $ "Undefined function: checkFunctionCall ((Func n a r):symbolMap) name args | not $ null $ lefts args = Left $ ErrorInsideFunction (name ++ ": " ++ show (lefts args)) | name == n = if all isRight coerce then Right $ ExplicitFunction name (zip (rights args) (rights coerce)) (MakeCoercion [MakeIdCoercion (fst r)] (MakeCardinalityIdCoercion (snd r))) - else checkFunctionCall symbolMap name args--Left $ UndefinedFunction $ "Undefined function: " ++ name ++ " [" ++ show (rights args) ++ "]" + else checkFunctionCall symbolMap name args | otherwise = checkFunctionCall symbolMap name args where argCoerce = map returnCoercion (rights args) diff --git a/test/Parser/ExpressionSpec.hs b/test/Parser/ExpressionSpec.hs index 105284c..590774d 100644 --- a/test/Parser/ExpressionSpec.hs +++ b/test/Parser/ExpressionSpec.hs @@ -42,23 +42,23 @@ spec = do exps :: [Expression] exps = [ -- 1 - InfixExp "+" (Int "1") (Parens (InfixExp "-" (Int "2") (Int "3"))), + InfixExp "+" (Int "1") (Parens (InfixExp "- " (Int "2") (Int "3"))), -- 2 InfixExp "=" - (InfixExp "-" - (InfixExp "-" + (InfixExp "- " + (InfixExp "- " (InfixExp "*" (Variable "a") (Variable "b")) (InfixExp "*" (Variable "c") (Variable "d"))) (InfixExp "*" (Variable "e") (Variable "f"))) - (InfixExp "-" - (InfixExp "-" + (InfixExp "- " + (InfixExp "- " (InfixExp "*" (Variable "g") (Variable "h")) (InfixExp "*" (Variable "i") (Variable "j"))) (InfixExp "*" (Variable "k") (Variable "l"))), -- 3 InfixExp "-" (InfixExp "+" (Variable "a") (Variable "b")) (InfixExp "*" (Variable "c") (InfixExp "^" (Variable "d") (Variable "e"))), -- 4 - InfixExp "-" (InfixExp "-" (InfixExp "-" (InfixExp "-" (InfixExp "-" (Int "1") (Int "2")) (Int "3")) (Int "4")) (Int "5")) (Int "6"), + InfixExp "-" (InfixExp "- " (InfixExp "- " (InfixExp "- " (InfixExp "- " (Int "1") (Int "2")) (Int "3")) (Int "4")) (Int "5")) (Int "6"), -- 5 List [Int "1", Int "2", Int "3"], -- 6 @@ -74,7 +74,7 @@ exps = [ (InfixExp "-" (InfixExp "+" (Variable "a") (Variable "b")) (InfixExp "*" (Variable "c") (InfixExp "^" (Variable "d") (PathExpression (Variable "e") (Variable "x"))))) (PrefixExp "not" (PostfixExp "exists" (Variable "a"))), -- 11 - IfSimple (List [Int "1", Function "Function" [Int "3"]]) (InfixExp "-" (InfixExp "-" (Int "1") (Int "2")) (InfixExp "*" (Int "3") (InfixExp "^" (PathExpression (Variable "a") (Variable "b")) (Variable "c")))), + IfSimple (List [Int "1", Function "Function" [Int "3"]]) (InfixExp "- " (InfixExp "- " (Int "1") (Int "2")) (InfixExp "*" (Int "3") (InfixExp "^" (PathExpression (Variable "a") (Variable "b")) (Variable "c")))), -- 12 InfixExp "or" (Variable "a") (Variable "b") ]