From c9ac1a7af218cb2977ba832665b45b81ab5fd25f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Doser?= Date: Wed, 9 Nov 2005 18:37:10 +0000 Subject: [PATCH] parse _empty_ CollectionLiterals (again, a change to OclTerm was necessary, so please check) git-svn-id: https://projects.brucker.ch/su4sml/svn/infsec-import/trunk/src/su4sml@3331 3260e6d1-4efc-4170-b0a7-36055960796d --- src/rep_ocl.sig | 5 +++++ src/rep_ocl.sml | 5 +++++ src/xmi2rep.sml | 10 ++++++++++ src/xmi_ocl.sml | 1 + 4 files changed, 21 insertions(+) diff --git a/src/rep_ocl.sig b/src/rep_ocl.sig index f4d83ee..65dd006 100644 --- a/src/rep_ocl.sig +++ b/src/rep_ocl.sig @@ -44,6 +44,7 @@ include REP_OCL_TYPE datatype OclTerm = Literal of string * OclType (* Literal with type *) + | CollectionLiteral of CollectionPart list * OclType (* content with type *) | If of OclTerm * OclType (* condition *) * OclTerm * OclType (* then *) * OclTerm * OclType (* else *) @@ -75,4 +76,8 @@ datatype OclTerm = * OclTerm * OclType (* source *) * OclTerm * OclType (* iterator-body *) * OclType (* result type *) +and CollectionPart = CollectionItem of OclTerm * OclType + | CollectionRange of OclTerm (* first *) + * OclTerm (* last *) + * OclType end diff --git a/src/rep_ocl.sml b/src/rep_ocl.sml index eb4f354..65df4b7 100644 --- a/src/rep_ocl.sml +++ b/src/rep_ocl.sml @@ -62,6 +62,7 @@ open Rep_OclType datatype OclTerm = Literal of string * OclType (* Literal with type *) + | CollectionLiteral of CollectionPart list * OclType (* content with type *) | If of OclTerm * OclType (* condition *) * OclTerm * OclType (* then *) * OclTerm * OclType (* else *) @@ -93,5 +94,9 @@ datatype OclTerm = * OclTerm * OclType (* source *) * OclTerm * OclType (* iterator-body *) * OclType (* result type *) +and CollectionPart = CollectionItem of OclTerm * OclType + | CollectionRange of OclTerm (* first *) + * OclTerm (* last *) + * OclType end diff --git a/src/xmi2rep.sml b/src/xmi2rep.sml index dbc76e2..7399181 100644 --- a/src/xmi2rep.sml +++ b/src/xmi2rep.sml @@ -45,6 +45,9 @@ val triv_expr = Rep_OclTerm.Literal ("true",Rep_OclType.Boolean) fun transform_expression t (XMI.LiteralExp {symbol,expression_type}) = Rep_OclTerm.Literal (symbol,find_classifier_type t expression_type) + | transform_expression t (XMI.CollectionLiteralExp {parts,expression_type}) = + Rep_OclTerm.CollectionLiteral (map (transform_collection_part t) parts, + find_classifier_type t expression_type) | transform_expression t (XMI.IfExp {condition,thenExpression, elseExpression,expression_type}) = Rep_OclTerm.If (transform_expression t condition, @@ -114,6 +117,13 @@ fun transform_expression t (XMI.LiteralExp {symbol,expression_type}) = ) end | transform_expression t _ = raise NotYetImplemented +and transform_collection_part t (XMI.CollectionItem {item,expression_type}) = + Rep_OclTerm.CollectionItem (transform_expression t item, + find_classifier_type t expression_type) + | transform_collection_part t (XMI.CollectionRange {first,last,expression_type}) = + Rep_OclTerm.CollectionRange (transform_expression t first, + transform_expression t last, + find_classifier_type t expression_type) fun transform_constraint t ({xmiid,name,body,...}:XMI.Constraint) = diff --git a/src/xmi_ocl.sml b/src/xmi_ocl.sml index 6c1019c..f5c85b5 100644 --- a/src/xmi_ocl.sml +++ b/src/xmi_ocl.sml @@ -94,6 +94,7 @@ withtype VariableDeclaration = { xmiid: string, fun expression_type_of (LiteralExp{expression_type,...}) = expression_type + | expression_type_of (CollectionLiteralExp{expression_type,...}) = expression_type | expression_type_of (IfExp{expression_type,...}) = expression_type | expression_type_of (AssociationEndCallExp{expression_type,...}) = expression_type | expression_type_of (AssociationClassCallExp{expression_type,...}) = expression_type