packages feed

prefix-expression 1.1.0 → 1.2.0

raw patch · 3 files changed

+5/−4 lines, 3 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

prefix-expression.cabal view
@@ -1,5 +1,5 @@ name:                prefix-expression-version:             1.1.0+version:             1.2.0 -- synopsis: description:         convert infix to prefix expression homepage:            https://github.com/VonFry/prefix-expression
src/Text/Exp/Prefix.hs view
@@ -9,7 +9,7 @@  -- | a operators list which cantains a list in order with precedence. expOperators :: [[(String, Int)]]-expOperators   = [[("^", 2)], [("*", 2), ("/", 2), ("\\", 2)], [("+", 2), ("-", 2)], [("=~", 2)], [("&&", 2)], [("||", 2)], [("!", 1)], [("(", 0), (")", 0)]]+expOperators   = [[("^", 2)], [("*", 2), ("/", 2), ("\\", 2), ("%", 2)], [("+", 2), ("-", 2)], [("=~", 2)], [("&&", 2)], [("||", 2)], [("!", 1)], [("<", 2), ("<=", 2), (">", 2), (">=", 2), ("==", 2)], [("(", 0), (")", 0)]] expOperators'  = foldr (++) [] expOperators expOperators'' = unzip expOperators' @@ -60,7 +60,7 @@             = (opStack'', popedStack)  checkInfixExp :: String -> Bool-checkInfixExp exp = not $ exp =~ "((&&|\\|\\||\\^|=~|\\+|-|\\*|/|\\\\) *(&&|\\|\\||\\^|=~|\\+|-|\\*|/|\\\\))|([0-9A-Za-z]+ +[0-9A-Za-z]+)"+checkInfixExp exp = not $ exp =~ "((&&|\\|\\||[><=]=|\\^|=~|\\+|-|\\*|/|%|\\\\) *(&&|\\|\\||[><=]=|\\^|=~|\\+|-|\\*|/|%|\\\\))|([0-9A-Za-z]+ +[0-9A-Za-z]+)"  checkOpArgs :: [String] -> Bool checkOpArgs stack = checkOpArgs' stack "" 0 0 0 == length stack@@ -113,7 +113,7 @@     splitExp' sp exp       | "" <- exp = filter (\x -> x /= "") sp       | otherwise-      = let match = exp =~ " +|'.*'|\".*\"|\\( *[\\+-][0-9A-Za-z]+ *\\)|&&|\\^|\\|\\||=~|!|\\(|\\)|\\+|-|\\*|/|\\\\" :: String+      = let match = exp =~ " +|'.*'|\".*\"|\\( *[\\+-][0-9A-Za-z]+ *\\)|&&|\\^|\\|\\||=~|!|[><=]=|\\(|\\)|\\+|-|\\*|/|%|\\\\" :: String         in if match /= ""            then let Just (idx, _) = elemSubIndex match exp                     (arg, exp')   = splitAt idx exp
test/Text/Exp/PrefixSpec.hs view
@@ -16,6 +16,7 @@       fromInfix "+2 * (-1) + 3" `shouldBe` Right "+ * +2 -1 3"       fromInfix "a + b + c" `shouldBe` Right "+ + a b c"       fromInfix "\"a\" + b + 'c'" `shouldBe` Right "+ + \"a\" b 'c'"+      fromInfix "a >= b" `shouldBe` Right ">= a b"     it "failed" $ do       (isLeft $ fromInfix "!((1 + 3) * 3 - 4 ^ 5") `shouldBe` True       (isLeft $ fromInfix "1 + + 2") `shouldBe` True