-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPetrifyBridge.hs
More file actions
50 lines (42 loc) · 1.49 KB
/
PetrifyBridge.hs
File metadata and controls
50 lines (42 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
--
-- Authors: Julien Lange <j.lange@ic.ac.uk> and
-- Emilio Tuosto <emilio.tuosto@gssi.it>
--
module PetrifyBridge where
import Data.Set as S
import CFSM
import TS
import Misc
--
-- This modules contains function to output files compatible with Petrify
--
state2petrify :: State -> String
state2petrify s = rmChar '*' $ rmChar '\"' (show s)
event2petrify :: (Show a1, Show a) => (State, State, a, a1, Dir, Message) -> String
event2petrify (q1,q2,m1,m2,_,msg) =
let st_arrow = "AAA"
st_comma = "CCC"
st_colon = "COCO"
st_del = "delPTP" -- This odd delimiter is to avoid problems with the odd restrictions required by petrify
in rmChars "_\"" (
(state2petrify q1) ++ st_comma ++
(state2petrify q2) ++ st_comma ++
(show m1) ++ st_del ++ st_arrow ++
(show m2) ++ st_del ++ st_colon ++
(tokenifymsg msg) )
ts2petrify :: TSb -> String -> String
ts2petrify (_, (initconf,_), events, trans) qsep =
let st_nodes = ".outputs "++(S.fold (++) "" (S.map (\x -> (event2petrify x)++" ") events))++"\n"
st_init = ".marking {q"++(nodelabel initconf qsep)++"}\n"
st_trans = S.fold (++) "" (
S.map (
\(x,y,z) -> "q" ++ (nodelabel (fst x) qsep)
++" "++
(event2petrify y)
++" "++
"q" ++ (nodelabel (fst z) qsep)
++"\n"
)
trans
)
in st_nodes ++ ".state graph \n" ++ st_trans ++ st_init ++ ".end\n"