allow OCL expressions in transition guards

git-svn-id: https://projects.brucker.ch/su4sml/svn/infsec-import/trunk/src/su4sml@4319 3260e6d1-4efc-4170-b0a7-36055960796d
This commit is contained in:
Jürgen Doser 2006-04-05 09:50:36 +00:00
parent 08d30e9545
commit 71c7e39694
3 changed files with 23 additions and 12 deletions

View File

@ -250,10 +250,12 @@ fun transform_guard t (XMI.mk_Guard g) =
let val self_type = Rep_OclType.DummyT (* FIX *) let val self_type = Rep_OclType.DummyT (* FIX *)
val package_path = nil (* FIX *) val package_path = nil (* FIX *)
in in
Rep_OclTerm.OperationCall ( Rep_OclTerm.Variable ("self",self_type), case #expression g of
self_type, NONE => Rep_OclTerm.OperationCall ( Rep_OclTerm.Variable ("self",self_type),
List.concat [package_path,[#body g]],nil, self_type,
Rep_OclType.Boolean ) List.concat [package_path,[Option.valOf(#body g)]],nil,
Rep_OclType.Boolean )
| SOME exp => transform_expression t exp
end end
fun transform_event t (XMI.CallEvent ev) = fun transform_event t (XMI.CallEvent ev) =
@ -408,12 +410,12 @@ fun transformXMI ({classifiers,constraints,packages,
handle Empty => raise Option handle Empty => raise Option
fun readXMI f = (transformXMI o ParseXMI.readFile) f fun readXMI f = (transformXMI o ParseXMI.readFile) f
(* handle ParseXMI.IllFormed msg => (print ("Warning: in Xmi2Mdr.readXMI: could not parse file "^f^":\n"^msg^"\n"); handle ParseXMI.IllFormed msg => (print ("Warning: in Xmi2Mdr.readXMI: could not parse file "^f^":\n"^msg^"\n");
nil) nil)
| Option => (print ("Warning: in Xmi2Mdr.readXMI: could not parse file "^f^"\n"); | Option => (print ("Warning: in Xmi2Mdr.readXMI: could not parse file "^f^"\n");
nil) nil)
| IllFormed msg => (print ("Warning: in Xmi2Mdr.readXMI: could not parse file "^f^": "^msg^"\n"); | IllFormed msg => (print ("Warning: in Xmi2Mdr.readXMI: could not parse file "^f^": "^msg^"\n");
nil)*) nil)
end end

View File

@ -60,8 +60,8 @@ datatype Guard = mk_Guard of {xmiid : string,
name : string, name : string,
visibility : VisibilityKind, visibility : VisibilityKind,
language : string, language : string,
body : string, body : string option,
expression : string list} expression : XMI_OCL.OCLExpression option}
datatype Event = SignalEvent of Parameter list datatype Event = SignalEvent of Parameter list
| CallEvent of { xmiid : string, | CallEvent of { xmiid : string,

View File

@ -616,16 +616,25 @@ fun mkProcedure tree =
*) *)
fun mkGuard tree = fun mkGuard tree =
let val getExpr = XmlTree.attributes_of o (XmlTree.find "UML:BooleanExpression") o let val getExpr = XmlTree.node_children_of o (XmlTree.find "UML:Guard.expression")
val getBoolExpr = XmlTree.attributes_of o (XmlTree.find "UML:BooleanExpression") o
XmlTree.node_children_of o (XmlTree.find "UML:Guard.expression") XmlTree.node_children_of o (XmlTree.find "UML:Guard.expression")
val getOclExpr = (XmlTree.find "UML:ExpressionInOcl") o
XmlTree.node_children_of o (XmlTree.find "UML:Guard.expression")
fun f atts trees = XMI.mk_Guard{ fun f atts trees = XMI.mk_Guard{
xmiid = getXmiId atts, xmiid = getXmiId atts,
name = getMaybeEmptyName atts, name = getMaybeEmptyName atts,
isSpecification = getBoolAtt "isSpecification" atts, isSpecification = getBoolAtt "isSpecification" atts,
visibility = getVisibility atts, visibility = getVisibility atts,
language = getLang(getExpr trees), language = if XmlTree.exists "UML:ExpressionInOCL" (getExpr trees)
body = getBody(getExpr trees), then getLang(XmlTree.attributes_of (getOclExpr trees))
expression = nil} else getLang(getBoolExpr trees),
body = if XmlTree.exists "UML:ExpressionInOCL" (getExpr trees)
then NONE
else SOME (getBody (getBoolExpr trees)) ,
expression = if XmlTree.exists "UML:ExpressionInOCL" (getExpr trees)
then SOME (mkOCLExpression (getOclExpr trees))
else NONE}
in XmlTree.apply_on "UML:Guard" f tree in XmlTree.apply_on "UML:Guard" f tree
handle XmlTree.IllFormed msg => raise IllFormed ("in mkGuard: "^msg) handle XmlTree.IllFormed msg => raise IllFormed ("in mkGuard: "^msg)
end end