Changeset 11217
- Timestamp:
- 06.01.2009 17:15:36 (11 months ago)
- Location:
- trunk/CspCASL
- Files:
-
- 3 modified
-
CspProver_Consts.hs (modified) (1 diff)
-
SignCSP.hs (modified) (1 diff)
-
StatAnaCSP.hs (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/CspCASL/CspProver_Consts.hs
r10436 r11217 182 182 -- Conditional operator symbols 183 183 cspProver_conditionalS :: String 184 cspProver_conditionalS = " CONDITIONAL"184 cspProver_conditionalS = "IF" 185 185 cspProver_conditionalAltS :: String 186 cspProver_conditionalAltS = "( CONDITIONAL_ THEN _ ELSE _)"186 cspProver_conditionalAltS = "(IF _ THEN _ ELSE _)" 187 187 cspProver_conditionalAltArgPrios :: [Int] 188 188 cspProver_conditionalAltArgPrios = [900,88,88] -
trunk/CspCASL/SignCSP.hs
r11215 r11217 179 179 -- Sentences 180 180 181 -- A CspCASl senetence is either a CASL formula or a Procsses182 -- equation. A process equation has on the LHS a process name, a list183 -- of parameters which are qualified variables (which are terms), a184 -- constituent communication alphabet and finally on the RHS a fully185 -- qualified process.181 -- | A CspCASl senetence is either a CASL formula or a Procsses 182 -- equation. A process equation has on the LHS a process name, a 183 -- list of parameters which are qualified variables (which are 184 -- terms), a constituent( or is it permitted ?) communication alphabet and 185 -- finally on the RHS a fully qualified process. 186 186 data CspCASLSen = CASLSen (FORMULA ()) 187 187 | ProcessEq PROCESS_NAME ProcVarList CommAlpha PROCESS -
trunk/CspCASL/StatAnaCSP.hs
r11216 r11217 19 19 import qualified Control.Monad as Monad 20 20 import qualified Data.Map as Map 21 import qualified Data.Maybe as Maybe22 21 import qualified Data.Set as S 23 22 -- liam added the following, they should be deleted from imports when … … 37 36 import Common.ConvertGlobalAnnos 38 37 import qualified Common.Lib.Rel as Rel 39 import Common.Id (getRange, Id, simpleIdToId , nullRange)38 import Common.Id (getRange, Id, simpleIdToId) 40 39 import Common.Lib.State 41 40 import Common.ExtSign … … 257 256 PrefixProcess e p range -> 258 257 do addDiags [mkDiag Debug "Prefix" proc] 259 (evComms, rcvMap ) <- anaEvent e (lVars `Map.union` gVars)258 (evComms, rcvMap, fqEvent) <- anaEvent e (lVars `Map.union` gVars) 260 259 (comms, pFQTerm) <- anaProcTerm p gVars (rcvMap `Map.union` lVars) 261 260 return (comms `S.union` evComms, 262 FQProcess (PrefixProcess epFQTerm range) (comms `S.union` evComms) range)261 FQProcess (PrefixProcess fqEvent pFQTerm range) (comms `S.union` evComms) range) 263 262 InternalPrefixProcess v s p range -> 264 263 do addDiags [mkDiag Debug "Internal prefix" proc] … … 340 339 -- mfs is the fully qualified formula version of f 341 340 mfs <- anaFormulaCspCASL (gVars `Map.union` lVars) f 342 addDiags [mkDiag Debug "Formula" f] 343 addDiags [mkDiag Debug "FQFormula" (Maybe.fromJust mfs)] 341 let fFQ = case mfs of 342 Nothing -> f -- use olf formula as the fully qualified version 343 Just fs -> fs -- use the real fully qualified formula 344 344 let fComms = case mfs of 345 345 Nothing -> S.empty 346 346 Just fs -> formulaComms fs 347 return (S.unions [pComms, qComms, fComms], 348 FQProcess (ConditionalProcess (Maybe.fromJust mfs) pFQTerm qFQTerm range) 349 (S.unions [pComms, qComms, fComms]) range) 347 let newAlpha = S.unions [pComms, qComms, fComms] 348 let fqProc = FQProcess (ConditionalProcess 349 (fFQ) pFQTerm qFQTerm range) 350 newAlpha range 351 return (newAlpha, fqProc) 350 352 351 353 -- | Statically analyse a CspCASL "named process" term. … … 409 411 -- Static analysis of events 410 412 411 -- | Statically analyse a CspCASL event. 412 anaEvent :: EVENT -> ProcVarMap -> State CspCASLSign (CommAlpha, ProcVarMap) 413 -- | Statically analyse a CspCASL event. Returns a constituent 414 -- communication alphabet of the event, mapping for any new 415 -- locally bound variables and a fully qualified version of the event. 416 anaEvent :: EVENT -> ProcVarMap -> State CspCASLSign (CommAlpha, ProcVarMap, EVENT) 413 417 anaEvent e vars = case e of 414 TermEvent t _ -> anaTermEvent t vars 415 ChanSend c t _ -> anaChanSend c t vars 416 ChanNonDetSend c v s _ -> anaChanBinding c v s 417 ChanRecv c v s _ -> anaChanBinding c v s 418 419 -- | Statically analyse a CspCASL term event. 418 TermEvent t r -> 419 do (alpha, newVars, fqTerm) <- anaTermEvent t vars 420 return (alpha, newVars, TermEvent fqTerm r) 421 ChanSend c t r -> 422 -- BUG - not returning a fully qualified event 423 do (alpha, newVars, fqTerm) <- anaChanSend c t vars 424 return (alpha, newVars, ChanSend c fqTerm r) 425 ChanNonDetSend c v s r -> 426 -- BUG - not returning a fully qualified event 427 do (alpha, newVars) <- anaChanBinding c v s 428 return (alpha, newVars, ChanNonDetSend c v s r) 429 ChanRecv c v s r -> 430 -- BUG - not returning a fully qualified event 431 do (alpha, newVars) <- anaChanBinding c v s 432 return (alpha, newVars, ChanRecv c v s r) 433 434 -- | Statically analyse a CspCASL term event. Returns a constituent 435 -- communication alphabet of the event and a mapping for any new 436 -- locally bound variables and the fully qualified version of the 437 -- term. 420 438 anaTermEvent :: (TERM ()) -> ProcVarMap -> 421 State CspCASLSign (CommAlpha, ProcVarMap )439 State CspCASLSign (CommAlpha, ProcVarMap, TERM ()) 422 440 anaTermEvent t vars = do 423 441 mt <- anaTermCspCASL vars t 424 let alpha = case mt of 425 Just at -> [(CommTypeSort (sortOfTerm at))] 426 Nothing -> [] 427 return (S.fromList alpha, Map.empty) 428 429 -- | Statically analyse a CspCASL channel send event. 442 let (alpha, t') = case mt of 443 -- return the alphabet and the fully qualified term 444 Just at -> ([(CommTypeSort (sortOfTerm at))], at) 445 -- return the empty alphabet and the original term 446 Nothing -> ([], t) 447 return (S.fromList alpha, Map.empty, t') 448 449 -- | Statically analyse a CspCASL channel send event. Returns a constituent 450 -- communication alphabet of the event and a mapping for any new 451 -- locally bound variables and the fully qualified version of the 452 -- term. 430 453 anaChanSend :: CHANNEL_NAME -> (TERM ()) -> ProcVarMap -> 431 State CspCASLSign (CommAlpha, ProcVarMap )454 State CspCASLSign (CommAlpha, ProcVarMap, TERM ()) 432 455 anaChanSend c t vars = do 433 456 sig <- get … … 436 459 Nothing -> do 437 460 addDiags [mkDiag Error "unknown channel" c] 438 return (S.empty, Map.empty )461 return (S.empty, Map.empty, t) 439 462 Just chanSort -> do 440 463 mt <- anaTermCspCASL vars t 441 464 case mt of 442 465 Nothing -> -- CASL analysis failed 443 return (S.empty, Map.empty) 466 -- Use old term as the fully qualified term 467 return (S.empty, Map.empty, t) 444 468 (Just at) -> 445 469 do mc <- ccTermCast at chanSort 446 470 case mc of 447 471 Nothing -> -- cast failed 448 return (S.empty, Map.empty) 472 -- Use old term as the fully qualified term 473 return (S.empty, Map.empty, t) 449 474 (Just ct) -> 450 475 do let castSort = sortOfTerm ct … … 452 477 ,CommTypeChan $ TypedChanName c castSort 453 478 ] 454 return (S.fromList alpha, Map.empty) 479 -- Use the real fully qualified term 480 return (S.fromList alpha, Map.empty, ct) 455 481 456 482 -- | Statically analyse a CspCASL "binding" channel event (which is … … 599 625 State CspCASLSign (Maybe (FORMULA ())) 600 626 anaFormulaCspCASL pm f = do 601 addDiags [mkDiag Debug "anaFormulaCspCASL" ()]627 addDiags [mkDiag Debug "anaFormulaCspCASL" f] 602 628 sig <- get 603 629 let newVars = Map.union pm (varMap sig)