Generation of Textual Descriptions
Wed May 23 17:37:45 WEST 2007 Miguel Vilaca <jmvilaca@di.uminho.pt>
* Generation of Textual Descriptions
Now the user as the choice of generate the
textual representation of the IN system to:
- AMIN
- PIN
{
hunk ./Makefile 371
+src/INTextualUI.o : src/PersistentDocument.hi
hunk ./src/Common.hs 186
+spaces2underscores :: String -> String
+spaces2underscores = map f [_$_]
+ where f ' ' = '_'
+ f c = c
+
hunk ./src/INTextual.hs 11
+
+ , Representation (..)
+ , showRepresentation
hunk ./src/INTextual.hs 49
-type Rule = (NodeApl, NodeApl)
+type Rule = (Maybe String, NodeApl, NodeApl)
hunk ./src/INTextual.hs 53
- show = jspRepresentation
+ show = showRepresentation PIN
hunk ./src/INTextual.hs 70
+data Representation = AMIN | PIN deriving Show
+
+repFold amin pin rep = case rep of [_$_]
+ AMIN -> amin
+ PIN -> pin [_$_]
+
hunk ./src/INTextual.hs 77
--- in the format of JSP IN transformation tool
-jspRepresentation :: Net -> String
-jspRepresentation net =
+-- in the format of IN transformation tools:
+-- * AMIN
+-- * PIN
+showRepresentation :: Representation -> Net -> String
+showRepresentation rep net =
hunk ./src/INTextual.hs 83
- [ "/* Automatically generated by " ++ toolName ++ " */"
+ [ "/* Automatically generated by " ++ toolName ++ " for " ++ show rep ++ " */"
hunk ./src/INTextual.hs 85
- , "agents"
+ , repFold "agents" "" rep
hunk ./src/INTextual.hs 89
- , "rules"
+ , repFold "rules" "" rep
hunk ./src/INTextual.hs 93
- , "net"
+ , repFold "net" "//test net\nstart :" rep
hunk ./src/INTextual.hs 96
- [ ""
- , "interface"
- , ""
- ] ++ map showEdge2 (interface net) ++ [_$_]
- [ ""
- , ""
- , "end"
- ])
+ case rep of [_$_]
+ AMIN -> [ ""
+ , "interface"
+ , ""
+ ] ++ map showEdge2 (interface net) ++ [_$_]
+ [ ""
+ , ""
+ , "end"
+ ]
+ PIN -> []
+ )
hunk ./src/INTextual.hs 108
- showAgent (name, arity) = sl name "\t" $ show arity
+ showAgent (name, arity) = sl (spaces2underscores name) (repFold "\t" ":" rep) $ show arity
hunk ./src/INTextual.hs 111
- showEquation (lhs, rhs) = sl (showTerm lhs) " = " $ showTerm rhs
+ showEquation (lhs, rhs) = sl (showTerm lhs) (repFold " = " " - " rep) $ showTerm rhs
hunk ./src/INTextual.hs 122
- showNode node = filter (not . isSpace) node
+ showNode node = spaces2underscores node
hunk ./src/INTextual.hs 130
- sl arg1 sep arg2 = '\t' : arg1 ++ sep ++ arg2 ++ [';']
+ sl arg1 sep arg2 = '\t' : arg1 ++ sep ++ arg2 ++ repFold ";" [] rep
hunk ./src/INTextual.hs 132
- showRule (lhs, rhs) = sl (showNodeApl lhs) " >< " (showNodeApl rhs)
+ showRule (mStr, lhs, rhs) = repFold [] (maybe [] ((++ ":\n") . spaces2underscores) mStr) rep
+ ++ sl (showNodeApl lhs) " >< " (showNodeApl rhs) ++ "\n"
hunk ./src/INTextual.hs 245
- [(Compound x, Compound y)] -> net {equations = [], rules = [(x,y)]}
+ [(Compound x, Compound y)] -> net {equations = [], rules = [(Just ruleName,x,y)]}
hunk ./src/INTextual.hs 288
- -- | It´s known that exactly one occurency of the edge will be found [_$_]
+ -- | It's known that exactly one occurency of the edge will be found [_$_]
hunk ./src/INTextualUI.hs 10
+import qualified PersistentDocument as PD
hunk ./src/INTextualUI.hs 15
+import Data.Maybe
hunk ./src/INTextualUI.hs 23
+ pDoc <- getDocument state
+ inName <- PD.getFileName pDoc
hunk ./src/INTextualUI.hs 27
- Just (what, simp, wher) -> [_$_]
+ Just (what, simp, wher, tool) -> [_$_]
hunk ./src/INTextualUI.hs 40
+ let filename = aux tool . span (/= '.') $ fromMaybe "" inName [_$_]
hunk ./src/INTextualUI.hs 44
- [("Any file", ["*"])] [_$_]
+ [("Net Files", ["*.net"])] [_$_]
hunk ./src/INTextualUI.hs 48
- Just fn -> writeFile fn . show $ net
+ Just fn -> writeFile fn . showRepresentation tool $ net
hunk ./src/INTextualUI.hs 52
- logMessage (show net)
- print net
+ logMessage (showRepresentation tool net)
+ putStr $ showRepresentation tool net
hunk ./src/INTextualUI.hs 57
- filename = "" [_$_]
+ aux tool (str,"") = str ++ '-':show tool ++ ".net"
+ aux tool (str,".INblobs") = str ++ '-':show tool ++ ".net"
+ aux tool (str1, str2) = let (str3,str4) = span (/='.') (tail str2)
+ in aux tool (str1 ++ '.':str3, str4)
hunk ./src/INTextualUI.hs 62
-genTextualDialog :: State g n e -> IO (Maybe (What, Bool, Bool))
+genTextualDialog :: State g n e -> IO (Maybe (What, Bool, Bool, Representation))
hunk ./src/INTextualUI.hs 99
+ let infoTool = [ ("AMIN", AMIN)
+ , ("PIN", PIN)
+ ]
+ (labelsTool,dataTool) = unzip infoTool
+
+ rTool <- radioBox p Vertical labelsTool [_$_]
+ [ text := "Output Tool :"
+ , selection := 0 ]
hunk ./src/INTextualUI.hs 116
+ , widget rTool
hunk ./src/INTextualUI.hs 126
+ iTool <- get rTool selection
hunk ./src/INTextualUI.hs 130
- , dataWhere !! iWhere)
+ , dataWhere !! iWhere
+ , dataTool !! iTool
+ )
}