2005-08-17 15:45:10 +00:00
|
|
|
(*****************************************************************************
|
2005-08-18 05:55:15 +00:00
|
|
|
* su4sml - a SecureUML repository for SML
|
2005-08-17 15:45:10 +00:00
|
|
|
*
|
|
|
|
* ocl.sig -
|
|
|
|
* Copyright (C) 2001-2005 Achim D. Brucker <brucker@inf.ethz.ch>
|
2005-08-18 05:55:15 +00:00
|
|
|
* Jürgen Doser <doserj@inf.ethz.ch>
|
2005-08-17 15:45:10 +00:00
|
|
|
*
|
|
|
|
* This file is part of su4sml.
|
|
|
|
*
|
|
|
|
* su4sml is free software; you can redistribute it and/or modify it under
|
|
|
|
* the terms of the GNU General Public License as published by the Free
|
|
|
|
* Software Foundation; either version 2 of the License, or (at your option)
|
|
|
|
* any later version.
|
|
|
|
*
|
|
|
|
* su4sml is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
|
|
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
|
|
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
|
|
|
* details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
******************************************************************************)
|
|
|
|
|
2006-12-08 17:16:33 +00:00
|
|
|
(** Repository datatypes and helper functions for UML/OCL types. *)
|
2006-04-27 14:27:16 +00:00
|
|
|
signature REP_OCL_TYPE =
|
|
|
|
sig
|
|
|
|
|
|
|
|
type Path = string list
|
|
|
|
|
|
|
|
datatype OclType = Integer | Real | String | Boolean | OclAny
|
|
|
|
| Set of OclType | Sequence of OclType
|
|
|
|
| OrderedSet of OclType | Bag of OclType
|
|
|
|
| Collection of OclType
|
2006-10-04 08:03:29 +00:00
|
|
|
| Classifier of Path | OclVoid | DummyT | TemplateParameter of string
|
2006-04-27 14:27:16 +00:00
|
|
|
val string_of_OclType : OclType -> string
|
|
|
|
val string_of_path : Path -> string
|
2006-05-04 15:22:13 +00:00
|
|
|
val is_Classifier : OclType -> bool
|
|
|
|
val is_Collection : OclType -> bool
|
2006-04-27 14:27:16 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
2006-12-08 17:16:33 +00:00
|
|
|
(** Repository datatypes and helper functions for OCL expressions. *)
|
2006-04-27 14:27:16 +00:00
|
|
|
signature REP_OCL_TERM =
|
|
|
|
sig
|
|
|
|
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 *)
|
|
|
|
* OclType (* result type *)
|
|
|
|
| AssociationEndCall of OclTerm * OclType (* source *)
|
|
|
|
* Path (* assoc.-enc *)
|
|
|
|
* OclType (* result type *)
|
|
|
|
| AttributeCall of OclTerm * OclType (* source *)
|
|
|
|
* Path (* attribute *)
|
|
|
|
* OclType (* result type *)
|
|
|
|
| OperationCall of OclTerm * OclType (* source *)
|
|
|
|
* Path (* operation *)
|
|
|
|
* (OclTerm * OclType) list (* parameters *)
|
|
|
|
* OclType (* result tupe *)
|
|
|
|
| OperationWithType of OclTerm * OclType (* source *)
|
|
|
|
* string * OclType (* type parameter *)
|
|
|
|
* OclType (* result type *)
|
|
|
|
| Variable of string * OclType (* name with type *)
|
|
|
|
| Let of string * OclType (* variable *)
|
|
|
|
* OclTerm * OclType (* rhs *)
|
|
|
|
* OclTerm * OclType (* in *)
|
|
|
|
| Iterate of (string * OclType) list (* iterator variables *)
|
|
|
|
* string * OclType * OclTerm (* result variable *)
|
|
|
|
* OclTerm * OclType (* source *)
|
|
|
|
* OclTerm * OclType (* iterator body *)
|
|
|
|
* OclType (* result type *)
|
|
|
|
| Iterator of string (* name of iterator *)
|
|
|
|
* (string * OclType) list (* iterator variables *)
|
|
|
|
* OclTerm * OclType (* source *)
|
|
|
|
* OclTerm * OclType (* iterator-body *)
|
|
|
|
* OclType (* result type *)
|
|
|
|
and CollectionPart = CollectionItem of OclTerm * OclType
|
|
|
|
| CollectionRange of OclTerm (* first *)
|
|
|
|
* OclTerm (* last *)
|
|
|
|
* OclType
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2005-09-07 18:23:24 +00:00
|
|
|
structure Rep_OclType : REP_OCL_TYPE =
|
2005-08-17 15:45:10 +00:00
|
|
|
struct
|
2005-09-14 13:24:57 +00:00
|
|
|
open library
|
2005-08-17 15:45:10 +00:00
|
|
|
type Path = string list
|
|
|
|
|
|
|
|
|
|
|
|
datatype OclType = Integer | Real | String | Boolean | OclAny
|
|
|
|
| Set of OclType | Sequence of OclType
|
|
|
|
| OrderedSet of OclType | Bag of OclType
|
2005-08-26 11:50:39 +00:00
|
|
|
| Collection of OclType | OclVoid | DummyT
|
2005-08-17 15:45:10 +00:00
|
|
|
| Classifier of Path
|
2006-10-04 08:03:29 +00:00
|
|
|
| TemplateParameter of string
|
2005-08-17 15:45:10 +00:00
|
|
|
|
|
|
|
fun string_of_path (path:Path) = case path of
|
|
|
|
[] => ""
|
|
|
|
| p => foldr1 (fn (a,b) => a^"."^b) p
|
|
|
|
|
|
|
|
|
|
|
|
fun string_of_OclType Integer = "Integer"
|
|
|
|
| string_of_OclType Real = "Real"
|
|
|
|
| string_of_OclType String = "String"
|
|
|
|
| string_of_OclType Boolean = "Boolean"
|
|
|
|
| string_of_OclType OclAny = "OclAny"
|
|
|
|
| string_of_OclType (Set t) = ("Set("^(string_of_OclType t)^")")
|
|
|
|
| string_of_OclType (Sequence t) = ("Sequence("^(string_of_OclType t)^")")
|
|
|
|
| string_of_OclType (OrderedSet t) = ("OrderedSet("^(string_of_OclType t)^")")
|
|
|
|
| string_of_OclType (Bag t) = ("Bag("^(string_of_OclType t)^")")
|
|
|
|
| string_of_OclType (Collection t) = ("Collection("^(string_of_OclType t)^")")
|
|
|
|
| string_of_OclType OclVoid = "OclVoid"
|
|
|
|
| string_of_OclType (Classifier p) = (string_of_path p)
|
2005-08-29 06:28:17 +00:00
|
|
|
| string_of_OclType DummyT = "DummyT"
|
2005-08-17 15:45:10 +00:00
|
|
|
|
2006-05-04 15:22:13 +00:00
|
|
|
fun is_Classifier (Classifier p) = true
|
|
|
|
| is_Classifier _ = false
|
|
|
|
|
|
|
|
fun is_Collection (Set _) = true
|
|
|
|
| is_Collection (Sequence _) = true
|
|
|
|
| is_Collection (OrderedSet _) = true
|
|
|
|
| is_Collection (Bag _) = true
|
|
|
|
| is_Collection (Collection _) = true
|
|
|
|
| is_Collection _ = false
|
2005-08-17 15:45:10 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
2005-09-07 18:23:24 +00:00
|
|
|
structure Rep_OclTerm : REP_OCL_TERM =
|
2005-08-17 15:45:10 +00:00
|
|
|
struct
|
2005-09-07 18:23:24 +00:00
|
|
|
open Rep_OclType
|
2005-08-17 15:45:10 +00:00
|
|
|
|
|
|
|
datatype OclTerm =
|
2005-11-09 18:06:29 +00:00
|
|
|
Literal of string * OclType (* Literal with type *)
|
2005-11-09 18:37:10 +00:00
|
|
|
| CollectionLiteral of CollectionPart list * OclType (* content with type *)
|
2005-11-09 18:06:29 +00:00
|
|
|
| If of OclTerm * OclType (* condition *)
|
|
|
|
* OclTerm * OclType (* then *)
|
|
|
|
* OclTerm * OclType (* else *)
|
|
|
|
* OclType (* result type *)
|
|
|
|
| AssociationEndCall of OclTerm * OclType (* source *)
|
|
|
|
* Path (* assoc.-enc *)
|
|
|
|
* OclType (* result type *)
|
|
|
|
| AttributeCall of OclTerm * OclType (* source *)
|
|
|
|
* Path (* attribute *)
|
|
|
|
* OclType (* result type *)
|
|
|
|
| OperationCall of OclTerm * OclType (* source *)
|
|
|
|
* Path (* operation *)
|
|
|
|
* (OclTerm * OclType) list (* parameters *)
|
|
|
|
* OclType (* result tupe *)
|
|
|
|
| OperationWithType of OclTerm * OclType (* source *)
|
|
|
|
* string * OclType (* type parameter *)
|
|
|
|
* OclType (* result type *)
|
|
|
|
| Variable of string * OclType (* name with type *)
|
|
|
|
| Let of string * OclType (* variable *)
|
|
|
|
* OclTerm * OclType (* rhs *)
|
|
|
|
* OclTerm * OclType (* in *)
|
|
|
|
| Iterate of (string * OclType) list (* iterator variables *)
|
|
|
|
* string * OclType * OclTerm (* result variable *)
|
|
|
|
* OclTerm * OclType (* source *)
|
|
|
|
* OclTerm * OclType (* iterator body *)
|
|
|
|
* OclType (* result type *)
|
|
|
|
| Iterator of string (* name of iterator *)
|
|
|
|
* (string * OclType) list (* iterator variables *)
|
|
|
|
* OclTerm * OclType (* source *)
|
|
|
|
* OclTerm * OclType (* iterator-body *)
|
|
|
|
* OclType (* result type *)
|
2005-11-09 18:37:10 +00:00
|
|
|
and CollectionPart = CollectionItem of OclTerm * OclType
|
|
|
|
| CollectionRange of OclTerm (* first *)
|
|
|
|
* OclTerm (* last *)
|
|
|
|
* OclType
|
2006-12-08 17:16:33 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2005-08-17 15:45:10 +00:00
|
|
|
end
|
|
|
|
|