catch errors while parsing constraints and return the trivial constraint "true" in these cases.

git-svn-id: https://projects.brucker.ch/su4sml/svn/infsec-import/trunk/src/su4sml@2995 3260e6d1-4efc-4170-b0a7-36055960796d
This commit is contained in:
Jürgen Doser 2005-08-26 12:29:56 +00:00
parent 2b615407b9
commit 60fd646460
2 changed files with 13 additions and 1 deletions

View File

@ -182,6 +182,11 @@ fun findExpressionType trees = findXmiIdRef "OCL.Expressions.OclExpression.type"
(* hack: return a reference to a dummy*)
(* type if the real type is not found *)
(* this is a hack. This will still throw an exception in xmi2mdr, because the *)
(* expression_type should be the xmiid of oclLib.Boolean, which we do not know *)
val triv_expr = XMI_UML.LiteralExp {symbol = "true",
expression_type = "bool" }
fun mkOCLExpression tree =
let val elem = XmlTree.tagname_of tree
val atts = XmlTree.attributes_of tree
@ -341,7 +346,9 @@ fun mkConstraint tree =
in { xmiid = getXmiId atts,
name = case XmlTree.attvalue_of "name" atts of SOME s => SOME s | _ => NONE,
constraint_type = st_type_ref,
body = mkOCLExpression expr }
body = (mkOCLExpression expr (* if something goes wrong, we return *)
handle _ => triv_expr) (* return trivial expression "true" *)
}
end
in XmlTree.apply_on "UML:Constraint" f tree
handle XmlTree.IllFormed msg => raise IllFormed ("in mkConstraint: "^msg)

View File

@ -212,6 +212,8 @@ fun insert_classifier table package_prefix class =
end
val triv_expr = ocl_term.Literal ("true",ocl_type.Boolean)
fun transform_expression t (XMI_UML.LiteralExp {symbol,expression_type}) =
ocl_term.Literal (symbol,find_classifier_type t expression_type)
| transform_expression t (XMI_UML.IfExp {condition,thenExpression,
@ -267,6 +269,9 @@ fun transform_constraint t ({xmiid,name,body,...}:XMI_UML.Constraint) =
|NONE => NONE
in
(n_name,transform_expression t body)
handle NotYetImplemented => (print "Warning: in Xmi2Mdr.transform_constraint: Something is not yet implemented.\n";(NONE, triv_expr))
| IllFormed msg => (print ("Warning: in Xmi2Mdr.transform_constraint: Could not parse Constraint: "^msg^"\n");(NONE, triv_expr))
| ParseXMI.IllFormed msg => (print ("Warning: in Xmi2Mdr.transform_constraint: Could not parse Constraint: "^msg^"\n");(NONE, triv_expr))
end
fun transform_parameter t {xmiid,name,kind,type_id} =