packages feed

CSPM-Interpreter 0.1.0.1 → 0.2.0.0

raw patch · 4 files changed

+20/−58 lines, 4 filesdep ~CSPM-CoreLanguagedep ~basePVP ok

version bump matches the API change (PVP)

Dependency ranges changed: CSPM-CoreLanguage, base

API changes (from Hackage documentation)

+ CSPM.Interpreter.Test.CLI: evalEnv :: Bool -> Maybe FilePath -> String -> IO (Value, Env)

Files

CSPM-Interpreter.cabal view
@@ -1,17 +1,17 @@ Name:                CSPM-Interpreter-Version:             0.1.0.1+Version:             0.2.0.0  Synopsis:            An interpreter for CSPM Description:-  This module contains an interpreter for CSPM-  and instance declarations than implement the interface defined in+  This package contains an interpreter for CSPM+  and instance declarations that implement the interface defined in   the package CSPM-CoreLanguage.   All type family instances that belong to this implementation   are indexed with the phantom-type 'INT' ('INT' == interpreter).-  The operational semantics of core-CSP is defined in a separate package.+  The operational semantics of core-CSP is defined in the CSPM-FiringRules package.  License:             BSD3-category:            Language+category:            Language,Formal Methods,Concurrency License-File:        License Author:              2010 Marc Fontaine Maintainer:          Marc Fontaine <fontaine@cs.uni-duesseldorf.de>@@ -22,7 +22,7 @@ Library   Build-Depends:     CSPM-Frontend >= 0.3.0.0-    ,CSPM-CoreLanguage >= 0.1 && <= 0.2+    ,CSPM-CoreLanguage >= 0.1 && < 0.2     ,base >= 4.0 && < 5.0     ,containers >= 0.3 && < 0.4     ,mtl >= 1.1 && < 1.2@@ -50,14 +50,3 @@     CSPM.Interpreter.SSet     Data.Digest.Pure.MD5     Data.Digest.Pure.HashMD5--Executable cspmEval-  Build-Depends:-    CSPM-Frontend >= 0.3.0.0-    ,CSPM-CoreLanguage >= 0.1 && <= 0.2-    ,base >= 4.0- -  GHC-Options: -funbox-strict-fields -O2 -Wall-  Extensions: DeriveDataTypeable, GeneralizedNewtypeDeriving-  Hs-Source-Dirs:      src-  Main-is:             Main.hs
src/CSPM/Interpreter/CoreInstances.hs view
@@ -37,11 +37,6 @@ import Data.List as List import Data.Maybe ---instance EqOrd INT---instance CSP1 INT---instance CSP2 INT---instance FShow INT- deriving instance Show (Core.TTE INT)  noInstance :: String -> a
src/CSPM/Interpreter/Test/CLI.hs view
@@ -30,6 +30,7 @@ (    evalTest   ,runFile+  ,evalEnv )  where@@ -46,7 +47,7 @@  import System.Exit import System.CPUTime-+import Control.Exception (evaluate) import Control.Monad import qualified Data.IntMap as IntMap import qualified Data.Map as Map@@ -66,14 +67,17 @@  -- | Load a specification from a file and evaluate an expression in the context. evalTest :: FilePath -> String -> IO Value-evalTest fileName expr = liftM fst $ evalEnv fileName expr+evalTest fileName expr = liftM fst $ evalEnv False (Just fileName) expr  {- Todo: clean up the mess below -} --evalEnv :: FilePath -> String -> IO (Value,Types.Env)-evalEnv fileName expr = do-  srcPlain <- readFile fileName+-- | Evaluate an expression in an optional context.+evalEnv :: Bool -> Maybe FilePath -> String -> IO (Value,Types.Env)+evalEnv verbose context expr = do+  srcPlain <- case context of+    Just path -> readFile path+    Nothing -> return ""+  let fileName = maybe "expression" id context {- this is a hack: we simply append the expression to be evaluated at the end of the sourcefile and parse both together in one go@@ -111,10 +115,10 @@           $ AST.moduleDecls $ unLabel astP     val :: Value     val = (IntMap.!) (getLetBindings env) $ AST.uniqueIdentId entry---  forM_ (IntMap.elems $ getLetBindings env)  $ \p -> putStrLn $ show p-  putStrLn $ show val-  time_finish_execute <- getCPUTime-  putStrLn $ "execution time : " ++ showTime(time_finish_execute - time_start_execute)+  when verbose $ do+     putStrLn $ "eval result         : " ++ show val+     time_finish_execute <- getCPUTime+     putStrLn $ "eval execution time : " ++ showTime (time_finish_execute - time_start_execute)   return (val,env)  showTime :: Integer -> String
− src/Main.hs
@@ -1,26 +0,0 @@-------------------------------------------------------------------------------- |--- Module      :  CSPM.Interpreter.Test.Main--- Copyright   :  (c) Fontaine 2010--- License     :  BSD--- --- Maintainer  :  Fontaine@cs.uni-duesseldorf.de--- Stability   :  experimental--- Portability :  GHC-only------ Very rudimentary comand line interface to the interpreter.-------------------------------------------------------------------------------module Main-where--import CSPM.Interpreter.Test.CLI-import System.Environment (getArgs)--- | main-funtion for the command line.--- (no help and no nothing)-main :: IO ()-main = do-  l <- getArgs-  case l of-    [filePath, expression] -> runFile filePath expression-    _ -> putStrLn "please start with two arguments: filename + expression"