packages feed

improve 0.0.10 → 0.0.11

raw patch · 4 files changed

+33/−9 lines, 4 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Language.ImProve: (|=-) :: Name -> Stmt a -> Stmt a
+ Language.ImProve: case_ :: [(E Bool, Stmt ())] -> Stmt ()

Files

Language/ImProve.hs view
@@ -40,7 +40,18 @@     d();                          f)     e();     f();-}                                 +}++switch (a) {              'case_' a+    case 1:                   [ (a ==. 1, do1)+        do1();                , (a ==. 2, do2)+        break;                , (true   , do3)+    case 2:                   ]+        do2();+        break;+    default:+        do3();+} @  /Assertion Statements/@@ -177,9 +188,10 @@   , linear   -- * Statements   , Stmt-  -- ** Statement Labeling and Hierarchical Scope+  -- ** Variable Hierarchical Scope and Statement Labeling    , (|=)   , (|-)+  , (|=-)   -- ** Variable Declarations   , bool   , bool'@@ -193,6 +205,7 @@   -- ** Conditional Execution   , ifelse   , if_+  , case_   -- ** Incrementing and decrementing.   , incr   , decr@@ -216,7 +229,7 @@ infixl 3 &&. infixl 2 ||. infixr 1 -->-infixr 0 <==, |-, |=+infixr 0 <==, |=, |-, |=-  -- | True term. true :: E Bool@@ -358,7 +371,7 @@   statement $ Label name stmt1   return a --- | Creates a new hierarcical scope for variable names.+-- | Creates a new hierarchical scope for variable names. (|=) :: Name -> Stmt a -> Stmt a name |= stmt = do   (path0, stmt0) <- get@@ -368,6 +381,9 @@   put (path0, stmt1)   return a +-- | Creates a new hierarchical scope and labels a statement with the same name.+(|=-) :: Name -> Stmt a -> Stmt a+name |=- stmt = name |= name |- stmt  get :: Stmt ([Name], Statement) get = Stmt $ \ a -> (a, a)@@ -477,6 +493,11 @@ -- | Conditional if without the else. if_ :: E Bool -> Stmt () -> Stmt() if_ cond stmt = ifelse cond stmt $ return ()++-- | Condition case statement.+case_ :: [(E Bool, Stmt ())] -> Stmt ()+case_ [] = return ()+case_ ((cond, action) : b) = ifelse cond action $ case_ b  -- | Verify a program. --
Language/ImProve/Code.hs view
@@ -22,7 +22,10 @@     ++ codeVariables False scope ++ "\n"     ++ "void " ++ name ++ "(void);\n\n"   where-  [scope] = tree (\ (_, path, _) -> path) $ stmtVars stmt+  scope = case tree (\ (_, path, _) -> path) $ stmtVars stmt of+    [] -> error "program contains no usefull statements"+    [a] -> a+    _ -> error "unexpected: muliple scope items"  codeStmt :: Statement -> String codeStmt a = case a of@@ -68,14 +71,14 @@   (a:b) -> a ++ "\n" ++ indent (unlines b)  codeVariables :: Bool -> (Tree Name (Bool, Path, Const)) -> String-codeVariables define a = (if define then "" else "extern ") ++ init (init (f1 a)) ++ (if define then " =\n  " ++ f2 a else "") ++ ";\n"+codeVariables define a = (if define then "" else "extern ") ++ init (init (f1 a)) ++ (if define then " =\n    " ++ f2 a else "") ++ ";\n"   where   f1 a = case a of     T.Branch name items -> "struct {  // " ++ name ++ "\n" ++ indent (concatMap f1 items) ++ "} " ++ name ++ ";\n"     Leaf name (input, _, init) -> printf "%-5s %-25s;%s\n" (showConstType init) name (if input then "  // input" else "")    f2 a = case a of-    T.Branch name items -> indent' $ "{ " ++ (intercalate ", " $ map f2 items) ++ "}  // " ++ name ++ "\n"+    T.Branch name items -> indent' $ "{   " ++ (intercalate ",   " $ map f2 items) ++ "}  // " ++ name ++ "\n"     Leaf name (_, _, init) -> printf "%-15s  // %s\n" (showConst init) name  showConst :: Const -> String
Language/ImProve/Verify.hs view
@@ -404,7 +404,7 @@       Just "true"  -> "ifelse true:\n"  ++ indent (concatMap f onTrue)       Just "false" -> "ifelse false:\n" ++ indent (concatMap f onFalse)       _ -> ""-    Label' name traces -> name ++ " -:\n" ++ indent (concatMap f traces)+    Label' name traces -> name ++ " |-\n" ++ indent (concatMap f traces)  indent :: String -> String indent = unlines . map ("    " ++) . lines
improve.cabal view
@@ -1,5 +1,5 @@ name:    improve-version: 0.0.10+version: 0.0.11  category: Language