------------------------------------------ -- THE CONSTRAINT-UNDERSTANDING SYSTEM -- -- (Version 2) -- -- Written by Andrew Broad -- -- -- -- frame_classes.exp (2002:05:11 19:46) -- ------------------------------------------- (* Schemata boundaries commented out for the sake of Jex. *) (****************************************************************************) (** SCHEMA express_frame_class_model **) (****************************************************************************) (** Frame class model of EXPRESS (an EXPRESS metamodel). **) (****************************************************************************) SCHEMA express_frame_class_model; --USE FROM hlc_frame_class_model; (*****************************************************************) (* ENTITY frame *) (*****************************************************************) (* The superclass of all frame classes. *) (* Now /any/ frame can be extracted, not just HLCs! *) (* --IGNORE is a structured comment, which indicates that a slot *) (* should be ignored by the CCUS frame matching algorithm. *) (*****************************************************************) ENTITY frame ABSTRACT SUPERTYPE; extracted_from : OPTIONAL SET [1 : ?] OF frame; --IGNORE covers : OPTIONAL frame; --IGNORE description : OPTIONAL text; --IGNORE corresponds_to : OPTIONAL SET [1 : ?] OF frame; --IGNORE INVERSE hlcs_extracted : SET [0 : ?] OF frame FOR extracted_from; covered_by : SET [0 : ?] OF frame FOR covers; END_ENTITY; (******************************************************************) (* ENTITY named_frame *) (******************************************************************) (* The subclasses of frames which have the distinguished slot *) (* "name" (so that it's the same Slot object for comparable frame *) (* classes). Not used where it would cause multiple inheritance. *) (******************************************************************) ENTITY named_frame SUBTYPE OF (frame); name : STRING; END_ENTITY; (********************************************************************) (* ENTITY correspondence *) (********************************************************************) (* A reified correspondence between two frames, used in the case of *) (* plausible correspondences to record the semantic equivalence/ *) (* strength of the two frames. *) (********************************************************************) ENTITY correspondence SUBTYPE OF (frame); frame1 : frame; frame2 : frame; semantic_equivalence : semantic_equivalence; END_ENTITY; (****************************************************************) (* TYPE semantic_equivalence *) (****************************************************************) (* Two frames can either be semantically equivalent, one can be *) (* stronger than the other, otherwise they are incomparable. *) (****************************************************************) TYPE semantic_equivalence = ENUMERATION OF (equivalent, frame1_stronger, frame2_stronger, incomparable); END_TYPE; (****************************************************************) (* ENTITY model_frame *) (****************************************************************) (* Represents an EXPRESS model (i.e. a collection of schemata). *) (****************************************************************) ENTITY model_frame SUBTYPE OF (frame); schemata : SET [1 : ?] OF schema_frame; END_ENTITY; (********************************************) (* ENTITY schema_frame *) (********************************************) (* Represents a schema in an EXPRESS model. *) (********************************************) ENTITY schema_frame SUBTYPE OF (named_frame); entities : OPTIONAL SET [1 : ?] OF entity_type; defined_types : OPTIONAL SET [1 : ?] OF defined_type; rules : OPTIONAL SET [1 : ?] OF global_rule; functions : OPTIONAL SET [1 : ?] OF function_definition; procedures : OPTIONAL SET [1 : ?] OF procedure_definition; constants : OPTIONAL SET [1 : ?] OF constant_frame; uses : OPTIONAL SET [1 : ?] OF use_clause; references : OPTIONAL SET [1 : ?] OF reference_clause; INVERSE the_model : model_frame FOR schemata; END_ENTITY; (*********************************************************) (* ENTITY named_type *) (*********************************************************) (* Superclass of named types, namely ENTITYs and TYPEs. *) (*********************************************************) ENTITY named_type ABSTRACT SUPERTYPE OF (ONEOF (entity_type, defined_type)) SUBTYPE OF (named_frame); domain_rules : OPTIONAL SET [1 : ?] OF domain_rule; END_ENTITY; (********************************************************************) (* ENTITY entity_type *) (********************************************************************) (* Represents an entity, which can be used anywhere a named type is *) (* required. The attributes capture the information from the *) (* corresponding ENTITY definition. *) (********************************************************************) ENTITY entity_type SUBTYPE OF (named_type); is_abstract : BOOLEAN; supertype_of : OPTIONAL supertype_expression; subtype_of : OPTIONAL SET [1:?] OF entity_type; explicit_attributes : SET [0:?] OF explicit_attribute; explicit_attribute_redeclarations : OPTIONAL SET [1:?] OF explicit_attribute_redeclaration; derived_attributes : OPTIONAL SET [1:?] OF derived_attribute; derived_attribute_redeclarations : OPTIONAL SET [1:?] OF derived_attribute_redeclaration; inverse_attributes : OPTIONAL SET [1:?] OF inverse_attribute; inverse_attribute_redeclarations : OPTIONAL SET [1:?] OF inverse_attribute_redeclaration; unique_rules : OPTIONAL SET [1:?] OF unique_rule; INVERSE the_schema : schema_frame FOR entities; END_ENTITY; (*****************************************************************) (* ENTITY defined_type *) (*****************************************************************) (* Represents a defined type, which can be used anywhere a named *) (* type is required. The attributes capture the information from *) (* the corresponding TYPE definition. *) (*****************************************************************) ENTITY defined_type SUBTYPE OF (named_type); tipe : underlying_type; -- "type" is a reserved word INVERSE the_schema : schema_frame FOR defined_types; END_ENTITY; (*************************) (* TYPE abstract_type *) (*************************) (* Represents all types. *) (*************************) TYPE abstract_type = SELECT (parameter_type, underlying_type, indeterminate_type); END_TYPE; (*******************************************************************) (* TYPE underlying_type *) (*******************************************************************) (* Represents the possible underlying types for a type definition: *) (* simple types such as INTEGER, aggregations such as SET, *) (* entities, defined types, plus selects and enumerations. *) (*******************************************************************) TYPE underlying_type = SELECT (defined_type, simple_type, aggregation_type, select_type, enumeration_type); END_TYPE; (********************************************************************) (* TYPE parameter_type *) (********************************************************************) (* Represents the possible types of an attribute: simple types such *) (* as INTEGER, aggregation types such as SET, named types (entities *) (* and defined types) but not direct selects or enumerations. *) (********************************************************************) TYPE parameter_type = SELECT (simple_type, aggregation_type, named_type); END_TYPE; (********************************************************************) (* TYPE simple_type *) (********************************************************************) (* A simple type is either BOOLEAN, LOGICAL, NUMBER, INTEGER, REAL, *) (* STRING, BINARY or GENERIC. *) (********************************************************************) TYPE simple_type = ENUMERATION OF (boolean_type, logical_type, number_type, integer_type, real_type, string_type, binary_type, generic_type); END_TYPE; (********************************************************************) (* TYPE indeterminate_type *) (********************************************************************) (* The type of indeterminate aggregation-bounds (`?'). *) (********************************************************************) TYPE indeterminate_type = ENUMERATION OF (indeterminate); END_TYPE; (*******************************************************************) (* ENTITY aggregation_type *) (*******************************************************************) (* The supertype of aggregation types: SET, BAG, LIST and ARRAY. *) (* Represents AGGREGATE if the supertype is instantiated directly. *) (*******************************************************************) ENTITY aggregation_type SUPERTYPE OF (ONEOF (unordered_aggregation_type, ordered_aggregation_type)) SUBTYPE OF (frame); element_type : parameter_type; lower_bound : OPTIONAL expression; upper_bound : OPTIONAL expression; END_ENTITY; (**********************************************************) (* ENTITY unordered_aggregation_type *) (**********************************************************) (* Represents an unordered aggregation type (SET or BAG). *) (**********************************************************) ENTITY unordered_aggregation_type ABSTRACT SUPERTYPE OF (ONEOF (set_type, bag_type)) SUBTYPE OF (aggregation_type); END_ENTITY; (**************************) (* ENTITY set_type *) (**************************) (* Represents a set type. *) (**************************) ENTITY set_type SUBTYPE OF (unordered_aggregation_type); END_ENTITY; (**************************) (* ENTITY bag_type *) (**************************) (* Represents a bag type. *) (**************************) ENTITY bag_type SUBTYPE OF (unordered_aggregation_type); END_ENTITY; (***********************************************************) (* ENTITY ordered_aggregation_type *) (***********************************************************) (* Represents an ordered aggregation type (LIST or ARRAY). *) (* The elements could have to be unique. *) (***********************************************************) ENTITY ordered_aggregation_type ABSTRACT SUPERTYPE OF (ONEOF (list_type, array_type)) SUBTYPE OF (aggregation_type); is_unique : BOOLEAN; END_ENTITY; (***************************) (* ENTITY list_type *) (***************************) (* Represents a list type. *) (***************************) ENTITY list_type SUBTYPE OF (ordered_aggregation_type); END_ENTITY; (*************************************************************) (* ENTITY array_type *) (*************************************************************) (* Represents an array type. The elements could be optional. *) (*************************************************************) ENTITY array_type SUBTYPE OF (ordered_aggregation_type); is_optional : BOOLEAN; END_ENTITY; (*****************************************************************) (* TYPE select_type *) (*****************************************************************) (* A select is a set of named types (entities or defined types). *) (*****************************************************************) TYPE select_type = SET [1 : ?] OF named_type; END_TYPE; (******************************************************************) (* TYPE enumeration_type *) (******************************************************************) (* An enumeration is an ordered set of symbols (enumeration types *) (* do have an order relation). *) (******************************************************************) TYPE enumeration_type = LIST [1 : ?] OF UNIQUE enumeration_symbol; END_TYPE; (*****************************************************************) (* ENTITY enumeration_symbol *) (*****************************************************************) (* An enumeration symbol is a string, now elevated to an entity. *) (*****************************************************************) ENTITY enumeration_symbol SUBTYPE OF (named_frame); INVERSE the_type : defined_type FOR tipe; END_ENTITY; (********************************************************************) (* ENTITY supertype_expression *) (********************************************************************) (* A supertype expression is either just an entity reference, or an *) (* intermediate ONEOF, AND or ANDOR operation. *) (********************************************************************) ENTITY supertype_expression ABSTRACT SUPERTYPE OF (ONEOF (oneof_supertype_expression, and_supertype_expression, andor_supertype_expression)) SUBTYPE OF (frame); END_ENTITY; (*********************************************************) (* ENTITY oneof_supertype_expression *) (*********************************************************) (* A ONEOF expression is a set of supertype expressions. *) (*********************************************************) ENTITY oneof_supertype_expression SUBTYPE OF (supertype_expression); expressions : SET [1 : ?] OF supertype_expression; END_ENTITY; (*********************************************************) (* ENTITY and_supertype_expression *) (*********************************************************) (* An AND expression is a pair of supertype expressions. *) (*********************************************************) ENTITY and_supertype_expression SUBTYPE OF (supertype_expression); terms : SET [2 : ?] OF supertype_expression; END_ENTITY; (***********************************************************) (* ENTITY andor_supertype_expression *) (***********************************************************) (* An ANDOR expression is a pair of supertype expressions. *) (***********************************************************) ENTITY andor_supertype_expression SUBTYPE OF (supertype_expression); factors : SET [2 : ?] OF supertype_expression; END_ENTITY; (********************************************************************) (* ENTITY attribute *) (********************************************************************) (* Represents an attribute of an entity, which can either be *) (* explicit, INVERSE or DERIVEd. All attributes have a name and a *) (* type. `attribute' is a subtype of `expression' so that anywhere *) (* an expression is expected, it can be a reference to an attribute.*) (********************************************************************) ENTITY attribute ABSTRACT SUPERTYPE OF (ONEOF (explicit_attribute, derived_attribute, inverse_attribute)) SUBTYPE OF (expression); name : STRING; END_ENTITY; (***************************************************************) (* ENTITY explicit_attribute *) (***************************************************************) (* Represents an explicit attribute in an entity, which may be *) (* OPTIONAL. *) (***************************************************************) ENTITY explicit_attribute SUBTYPE OF (attribute); is_optional : BOOLEAN; INVERSE the_entity : entity_type FOR explicit_attributes; END_ENTITY; (********************************************************************) (* ENTITY inverse_attribute *) (********************************************************************) (* Represents an INVERSE attribute in an entity, the value of which *) (* is an entity that has this entity as the value of its FOR *) (* attribute. *) (********************************************************************) ENTITY inverse_attribute SUBTYPE OF (attribute); for_attribute : attribute; INVERSE the_entity : entity_type FOR inverse_attributes; END_ENTITY; (*******************************************************************) (* ENTITY derived_attribute *) (*******************************************************************) (* Represents a DERIVEd attribute in an entity, the value of which *) (* is calculated using a formula rather than stored explicitly. *) (*******************************************************************) ENTITY derived_attribute SUBTYPE OF (attribute); formula : expression; INVERSE the_entity : entity_type FOR derived_attributes; END_ENTITY; (***********************************************) (* ENTITY attribute_redeclaration *) (***********************************************) (* Represents a redeclaration of an attribute. *) (***********************************************) ENTITY attribute_redeclaration ABSTRACT SUPERTYPE OF (ONEOF (explicit_attribute_redeclaration, derived_attribute_redeclaration, inverse_attribute_redeclaration)) SUBTYPE OF (frame); attribute : attribute; entity_originally_declared_in : entity_type; tipe : abstract_type; -- "type" is a reserved word in EXPRESS END_ENTITY; (********************************************************) (* ENTITY explicit_attribute_redeclaration *) (********************************************************) (* Represents a redeclaration of an explicit attribute, *) (* which may be OPTIONAL. *) (********************************************************) ENTITY explicit_attribute_redeclaration SUBTYPE OF (attribute_redeclaration); is_optional : BOOLEAN; INVERSE the_entity: entity_type FOR explicit_attribute_redeclarations; END_ENTITY; (*******************************************************) (* ENTITY inverse_attribute_redeclaration *) (*******************************************************) (* Represents a redeclaration of an inverse attribute. *) (*******************************************************) ENTITY inverse_attribute_redeclaration SUBTYPE OF (attribute_redeclaration); for_attribute : attribute; INVERSE the_entity : entity_type FOR inverse_attribute_redeclarations; END_ENTITY; (******************************************************) (* ENTITY derived_attribute_redeclaration *) (******************************************************) (* Represents a redeclaration of a derived attribute. *) (******************************************************) ENTITY derived_attribute_redeclaration SUBTYPE OF (attribute_redeclaration); formula : expression; INVERSE the_entity : entity_type FOR derived_attribute_redeclarations; END_ENTITY; (****************************************************************) (* ENTITY local_rule *) (****************************************************************) (* Represents constraints on an entity, which are either UNIQUE *) (* rules or domain (WHERE) rules. *) (****************************************************************) ENTITY local_rule ABSTRACT SUPERTYPE OF (ONEOF (unique_rule, domain_rule)) SUBTYPE OF (frame); label : STRING; END_ENTITY; (**********************************************) (* ENTITY unique_rule *) (**********************************************) (* Represents a uniqueness rule on an entity. *) (**********************************************) ENTITY unique_rule SUBTYPE OF (local_rule); attributes : SET [1 : ?] OF attribute; INVERSE the_entity : entity_type FOR unique_rules; END_ENTITY; (******************************************) (* ENTITY domain_rule *) (******************************************) (* Represents a domain rule on an entity. *) (******************************************) ENTITY domain_rule SUBTYPE OF (local_rule); expression : expression; INVERSE the_type : named_type FOR domain_rules; END_ENTITY; (*****************************) (* ENTITY global_rule *) (*****************************) (* Represents a global RULE. *) (*****************************) ENTITY global_rule SUBTYPE OF (named_frame); for_entities : SET [1 : ?] OF entity_type; entity_types : OPTIONAL SET [1 : ?] OF entity_type; defined_types : OPTIONAL SET [1 : ?] OF defined_type; functions : OPTIONAL SET [1 : ?] OF function_definition; procedures : OPTIONAL SET [1 : ?] OF procedure_definition; constants : OPTIONAL SET [1 : ?] OF constant_frame; local_variables : OPTIONAL SET [1 : ?] OF local_variable; statements : SET [0 : ?] OF statement; domain_rules : SET [1 : ?] OF domain_rule; END_ENTITY; (**********************************) (* ENTITY expression *) (**********************************) (* Superclass of all expressions. *) (**********************************) ENTITY expression ABSTRACT SUPERTYPE SUBTYPE OF (frame); tipe : abstract_type; -- "type" is a reserved word in EXPRESS is_variable : BOOLEAN; END_ENTITY; (*******************************) (* ENTITY literal *) (*******************************) (* Represents a literal value. *) (*******************************) ENTITY literal ABSTRACT SUPERTYPE SUBTYPE OF (expression); END_ENTITY; (**************************) (* ENTITY integer_literal *) (**************************) (* An integer literal. *) (**************************) ENTITY integer_literal SUBTYPE OF (literal); literal_value : INTEGER; END_ENTITY; (***************************) (* ENTITY real_literal *) (***************************) (* An real-number literal. *) (***************************) ENTITY real_literal SUBTYPE OF (literal); literal_value : REAL; END_ENTITY; (***********************************************) (* ENTITY logical_literal *) (***********************************************) (* A logical literal (TRUE, FALSE or UNKNOWN). *) (***********************************************) ENTITY logical_literal SUBTYPE OF (literal); literal_value : LOGICAL; END_ENTITY; (*************************) (* ENTITY string_literal *) (*************************) (* A string literal. *) (*************************) ENTITY string_literal SUBTYPE OF (literal); literal_value : STRING; END_ENTITY; (*************************) (* ENTITY binary_literal *) (*************************) (* A binary literal. *) (*************************) ENTITY binary_literal SUBTYPE OF (literal); literal_value : BINARY; END_ENTITY; (**************************************************************) (* ENTITY built_in_constant *) (**************************************************************) (* Represents an occurrence of one of the built-in constants. *) (**************************************************************) ENTITY built_in_constant SUBTYPE OF (expression); built_in_value : built_in; END_ENTITY; (***************************************************) (* TYPE built_in *) (***************************************************) (* The built in constants are e, PI, SELF and `?'. *) (***************************************************) TYPE built_in = ENUMERATION OF (e, pi_constant, self_constant, indeterminate); END_TYPE; (*********************************************************) (* ENTITY equation *) (*********************************************************) (* Equality relation on a set of two or more expressions *) (* i.e. a = b = ... = z. *) (*********************************************************) ENTITY equation SUBTYPE OF (expression); equal_expressions : SET [2 : ?] OF expression; END_ENTITY; (********************************) (* ENTITY inequality *) (********************************) (* Represents a `<>' operation. *) (********************************) ENTITY inequality SUBTYPE OF (expression); first_expression : expression; second_expression : expression; END_ENTITY; (**************************************************************) (* Equality relation on a set of two or more entity instances *) (* i.e. a :=: b :=: ... :=: z. *) (**************************************************************) ENTITY instance_equation SUBTYPE OF (expression); equal_instances : SET [2 : ?] OF expression; END_ENTITY; (**********************************) (* ENTITY instance_inequality *) (**********************************) (* Represents a `:<>:' operation. *) (**********************************) ENTITY instance_inequality SUBTYPE OF (expression); first_instance : expression; second_instance : expression; END_ENTITY; (*********************************************) (* ENTITY comparator *) (*********************************************) (* Represents greater-than(-or-equal-to) and *) (* less-than(-or-equal-to) operations. *) (*********************************************) ENTITY comparator SUBTYPE OF (expression); greater : expression; lesser : expression; inclusive : inclusive_or_exclusive; discrete : discrete_or_continuous; which_way_round : way_round; END_ENTITY; (*****************************************************************) (* TYPE way_round *) (*****************************************************************) (* Encodes which way round a comparator is written ('>' or '<'). *) (*****************************************************************) TYPE way_round = ENUMERATION OF (greater_first, lesser_first); END_TYPE; (************************************************************) (* TYPE inclusive_or_exclusive *) (************************************************************) (* Encodes whether a comparator is inclusive ('>=' or '<=') *) (* or exclusive ('>' or '<'). *) (************************************************************) TYPE inclusive_or_exclusive = ENUMERATION OF (inclusive, exclusive); END_TYPE; (******************************************************) (* TYPE discrete_or_continuous *) (******************************************************) (* Encodes whether a comparator is discrete (integer) *) (* or continuous (real). *) (******************************************************) TYPE discrete_or_continuous = ENUMERATION OF (discrete, continuous); END_TYPE; (*******************************************************) (* ENTITY interval *) (*******************************************************) (* Represents an interval expression, i.e. {l < m < u} *) (* (where '<' could be '<=' instead). *) (*******************************************************) ENTITY interval SUBTYPE OF (expression); lower_bound : expression; lower_inclusive : inclusive_or_exclusive; variable : expression; discrete : discrete_or_continuous; upper_inclusive : inclusive_or_exclusive; upper_bound : expression; END_ENTITY; (************************************************) (* ENTITY in_operation *) (************************************************) (* Represents an IN (set membership) operation. *) (************************************************) ENTITY in_operation SUBTYPE OF (expression); element : expression; set_frame : expression; END_ENTITY; (***********************************************) (* ENTITY like_operation *) (***********************************************) (* Represents a LIKE (string match) operation. *) (***********************************************) ENTITY like_operation SUBTYPE OF (expression); source_string : expression; target_string : expression; END_ENTITY; (***************************************************************) (* ENTITY addition *) (***************************************************************) (* Represents an addition as a bag of addends (or subtractors) *) (* i.e. a + b + ... + z, where some terms could be negative. *) (***************************************************************) ENTITY addition SUBTYPE OF (expression); addends : BAG [2 : ?] OF expression; END_ENTITY; (****************************************************************) (* ENTITY minus *) (****************************************************************) (* Represents a minus (unary minus and the right-hand side of a *) (* binary minus are treated the same). *) (****************************************************************) ENTITY minus SUBTYPE OF (expression); operand : expression; END_ENTITY; (******************************************************************) (* ENTITY multiplication *) (******************************************************************) (* Represents a multiplication as a bag of multiplicands (or *) (* divisors) *) (* i.e. a * b * ... * z, where some factors could be reciprocals. *) (******************************************************************) ENTITY multiplication SUBTYPE OF (expression); multiplicands : BAG [2 : ?] OF expression; END_ENTITY; (**********************************) (* ENTITY reciprocal *) (**********************************) (* Represents a reciprocal (1/x). *) (**********************************) ENTITY reciprocal SUBTYPE OF (expression); operand : expression; END_ENTITY; (*********************************) (* ENTITY exponentiation *) (*********************************) (* Represents an exponentiation. *) (*********************************) ENTITY exponentiation SUBTYPE OF (expression); base : expression; exponent : expression; END_ENTITY; (*****************************************************************) (* ENTITY div_operation *) (*****************************************************************) (* Represents a DIV (quotient of an integer division) operation. *) (*****************************************************************) ENTITY div_operation SUBTYPE OF (expression); dividend : expression; divisor : expression; END_ENTITY; (******************************************************************) (* ENTITY mod_operation *) (******************************************************************) (* Represents a MOD (remainder of an integer division) operation. *) (******************************************************************) ENTITY mod_operation SUBTYPE OF (expression); dividend : expression; divisor : expression; END_ENTITY; (************************************) (* ENTITY disjunction *) (************************************) (* Abstract disjunction (OR) class. *) (************************************) ENTITY disjunction ABSTRACT SUPERTYPE OF (ONEOF (inclusive_disjunction, exclusive_disjunction)) SUBTYPE OF (expression); disjuncts : BAG [2 : ?] OF expression; END_ENTITY; (*************************************************************) (* ENTITY inclusive_disjunction *) (*************************************************************) (* Represents an inclusive disjunction as a set of disjuncts *) (* i.e. a OR b OR ... OR z. *) (*************************************************************) ENTITY inclusive_disjunction SUBTYPE OF (disjunction); END_ENTITY; (*************************************************************) (* ENTITY exclusive_disjunction *) (*************************************************************) (* Represents an exclusive disjunction as a bag of disjuncts *) (* i.e. a XOR b XOR ... XOR z. *) (*************************************************************) ENTITY exclusive_disjunction SUBTYPE OF (disjunction); END_ENTITY; (**************************************************) (* ENTITY conjunction *) (**************************************************) (* Represents a conjunction as a set of conjuncts *) (* i.e. a AND b AND ... AND z. *) (**************************************************) ENTITY conjunction SUBTYPE OF (expression); conjuncts : SET [0 : ?] OF frame; END_ENTITY; (**************************************) (* ENTITY negation *) (**************************************) (* Represents a negation, i.e. NOT a. *) (**************************************) ENTITY negation SUBTYPE OF (expression); operand : expression; END_ENTITY; (**************************************************************) (* ENTITY complex_constructor *) (**************************************************************) (* Represents a complex construction as a list of two or more *) (* entity initialisers, i.e. a || b || ... || z. *) (**************************************************************) ENTITY complex_constructor SUBTYPE OF (expression); entity_initialisers : LIST [2 : ?] OF expression; END_ENTITY; (***************************) (* ENTITY query_expression *) (***************************) (* Represents a query. *) (***************************) ENTITY query_expression SUBTYPE OF (expression); variable : query_variable; aggregation_expression : expression; logical_expression : expression; END_ENTITY; (*********************************************) (* ENTITY query_variable *) (*********************************************) (* Represents the bound variable in a query. *) (*********************************************) ENTITY query_variable SUBTYPE OF (expression); name : STRING; INVERSE the_query : query_expression FOR variable; END_ENTITY; (************************************) (* ENTITY function_call *) (************************************) (* Represents a call to a function. *) (************************************) ENTITY function_call SUBTYPE OF (expression); function_called : function_definition; actual_parameters : LIST [0 : ?] OF expression; END_ENTITY; (*************************************) (* ENTITY function_definition *) (*************************************) (* Represents a FUNCTION definition. *) (*************************************) ENTITY function_definition ABSTRACT SUPERTYPE OF (ONEOF(built_in_function, user_defined_function)) SUBTYPE OF (named_frame); formal_parameters : LIST [0 : ?] OF formal_parameter; return_type : abstract_type; END_ENTITY; (****************************************************) (* ENTITY built_in_function *) (****************************************************) (* Represents the signature of a built-in function. *) (****************************************************) ENTITY built_in_function SUBTYPE OF (function_definition); END_ENTITY; (*********************************************************) (* ENTITY user_defined_function *) (*********************************************************) (* Represents the definition of a user-defined function. *) (*********************************************************) ENTITY user_defined_function SUBTYPE OF (function_definition); parameter_type : parameter_type; constants : OPTIONAL SET [1 : ?] OF constant_frame; entities : OPTIONAL SET [1 : ?] OF entity_type; functions : OPTIONAL SET [1 : ?] OF user_defined_function; procedures : OPTIONAL SET [1 : ?] OF procedure_definition; local_variables : OPTIONAL SET [1 : ?] OF local_variable; body : SET [1 : ?] OF statement; END_ENTITY; (*******************************************************************) (* ENTITY formal_parameter *) (*******************************************************************) (* Represents a formal parameter of a function or procedure. *) (* User-defined functions/procedures cannot have optional formal *) (* parameters. The is_optional slot is for built-in functions such *) (* as ATAN, which can be called with one parameter or with two. *) (* I decided to model this as one function which has an optional *) (* parameter, rather than two functions with the same name. *) (*******************************************************************) ENTITY formal_parameter SUBTYPE OF (named_frame); tipe : parameter_type; is_optional : BOOLEAN; INVERSE the_function : function_definition FOR formal_parameters; END_ENTITY; (**************************************) (* ENTITY procedure_definition *) (**************************************) (* Represents a PROCEDURE definition. *) (**************************************) ENTITY procedure_definition SUBTYPE OF (frame); END_ENTITY; (***************************) (* ENTITY qualifier *) (***************************) (* Represents a qualifier. *) (***************************) ENTITY qualifier ABSTRACT SUPERTYPE OF (ONEOF (attribute_qualifier, group_qualifier, index_qualifier)) SUBTYPE OF (expression); qualified_factor : expression; END_ENTITY; (**************************************************************) (* ENTITY attribute_qualifier *) (**************************************************************) (* Represents an attribute qualifier as a qualified factor l *) (* and an attribute r, i.e. "l.r". Attribute qualification is *) (* left-associative, i.e. (c.b.a) = ((c.b).a) *) (**************************************************************) ENTITY attribute_qualifier SUBTYPE OF (qualifier); attribute_reference : attribute; END_ENTITY; (********************************************************) (* ENTITY group_qualifier *) (********************************************************) (* Represents a group qualifier as a qualified factor l *) (* and an entity r, i.e. "l\r". *) (********************************************************) ENTITY group_qualifier SUBTYPE OF (qualifier); entity_reference : entity_type; END_ENTITY; (******************************************************) (* ENTITY index_qualifier *) (******************************************************) (* Represents an index qualifier, i.e. a[i] or a[i:j] *) (******************************************************) ENTITY index_qualifier SUBTYPE OF (qualifier); index1 : expression; index2 : OPTIONAL expression; END_ENTITY; (********************************************************************) (* TYPE unresolved_reference *) (********************************************************************) (* Yes, I'm afraid the current frame system cannot resolve all *) (* references. So this is officially represented in this model! ;-) *) (********************************************************************) TYPE unresolved_reference = STRING; END_TYPE; (**************************************) (* ENTITY aggregate_initialiser *) (**************************************) (* Represents an aggregation literal. *) (**************************************) ENTITY aggregate_initialiser SUBTYPE OF (expression); elements : LIST [0 : ?] OF aggregate_initialiser_element; END_ENTITY; (****************************************************) (* ENTITY aggregate_initialiser_element *) (****************************************************) (* Represents an element in an aggregation literal. *) (****************************************************) ENTITY aggregate_initialiser_element; expression : expression; repeat_count : OPTIONAL expression; INVERSE the_aggregate_initialiser : aggregate_initialiser FOR elements; END_ENTITY; (**************************) (* ENTITY constant_frame *) (**************************) (* Represents a CONSTANT. *) (**************************) ENTITY constant_frame SUBTYPE OF (frame); END_ENTITY; (*****************************) (* ENTITY use_clause *) (*****************************) (* Represents a USES clause. *) (*****************************) ENTITY use_clause SUBTYPE OF (frame); END_ENTITY; (***********************************) (* ENTITY reference_clause *) (***********************************) (* Represents a REFERENCES clause. *) (***********************************) ENTITY reference_clause SUBTYPE OF (frame); END_ENTITY; (*END_SCHEMA; ------------------------------------------------------------------------------- (****************************************************************************) (** SCHEMA hlc_frame_class_model **) (****************************************************************************) (** Frame class model of higher-level constraints. **) (****************************************************************************) SCHEMA hlc_frame_class_model; USE FROM express_frame_class_model;*) (***************************************************) (* ENTITY higher_level_constraint *) (***************************************************) (* The superclass of all higher-level constraints. *) (***************************************************) ENTITY higher_level_constraint ABSTRACT SUPERTYPE SUBTYPE OF (frame); END_ENTITY; (**********************************************) (* ENTITY choice_set *) (**********************************************) (* Higher-level CHOICE_SET constraint. *) (* This replaces EXACTLY_ONE and AT_MOST_ONE. *) (**********************************************) ENTITY choice_set SUBTYPE OF (higher_level_constraint); choice_set : SET [1 : ?] OF frame; is_optional : BOOLEAN; constrained_entity : entity_type; attribute : OPTIONAL attribute; END_ENTITY; (****************************************************************) (* ENTITY bound *) (****************************************************************) (* Higher-level BOUND constraint on a variable expression which *) (* must be <, >, <= or >= some limit. *) (****************************************************************) ENTITY bound SUBTYPE OF (higher_level_constraint); kind : bound_kind; inclusive : inclusive_or_exclusive; discrete : discrete_or_continuous; variable : expression; limit : expression; END_ENTITY; (*****************************************) (* TYPE bound_kind *) (*****************************************) (* A bound can either be lower or upper. *) (*****************************************) TYPE bound_kind = ENUMERATION OF (lower, upper); END_TYPE; (******************************************) (* ENTITY range *) (******************************************) (* Higher-level numeric RANGE constraint. *) (******************************************) ENTITY range SUBTYPE OF (higher_level_constraint); lower_bound : bound; upper_bound : bound; variable : expression; discrete : discrete_or_continuous; END_ENTITY; (*******************************************************************) (* ENTITY non_null *) (*******************************************************************) (* Higher-level constraint that the value of an explicit attribute *) (* must not be null. *) (*******************************************************************) ENTITY non_null SUBTYPE OF (higher_level_constraint); attribute : explicit_attribute; END_ENTITY; (*******************************************************************) (* ENTITY type_hlc *) (*******************************************************************) (* Higher-level constraint that the value of an explicit attribute *) (* must be of a certain type. *) (*******************************************************************) ENTITY type_hlc SUBTYPE OF (higher_level_constraint); attribute : explicit_attribute; tipe : abstract_type; END_ENTITY; (*******************************************************************) (* ENTITY domain_rules_hlc *) (*******************************************************************) (* Higher-level constraint used to propagate domain rules from *) (* a defined type to an entity through an attribute. *) (*******************************************************************) ENTITY domain_rules_hlc SUBTYPE OF (higher_level_constraint); the_entity : entity_type; domain_rules : OPTIONAL SET [1 : ?] OF domain_rule; substitute_for_self : OPTIONAL expression; --IGNORE END_ENTITY; (**************************************************************) (* ENTITY optional_xor_empty_aggregation *) (**************************************************************) (* Higher-level constraint that captures the common semantics *) (* of OPTIONAL SET [1 : ?] and SET [0 : ?]. *) (**************************************************************) ENTITY optional_xor_empty_aggregation SUBTYPE OF (higher_level_constraint); attribute : explicit_attribute; END_ENTITY; (**********************************) (* ENTITY adder *) (**********************************) (* Higher-level adder constraint. *) (**********************************) ENTITY adder SUBTYPE OF (higher_level_constraint); addends : BAG [2 : ?] OF expression; sum : expression; END_ENTITY; (***************************************) (* ENTITY multiplier *) (***************************************) (* Higher-level multiplier constraint. *) (***************************************) ENTITY multiplier SUBTYPE OF (higher_level_constraint); multiplicands : BAG [2 : ?] OF expression; product : expression; END_ENTITY; (*****************************************) (* ENTITY relationship *) (*****************************************) (* Higher-level relationship constraint. *) (*****************************************) ENTITY relationship ABSTRACT SUPERTYPE OF (ONEOF (one_to_one_relationship, one_to_many_relationship, many_to_many_relationship)) SUBTYPE OF (higher_level_constraint); source_entity : entity_type; source_attribute : attribute; target_entity : entity_type; target_attribute : attribute; END_ENTITY; (****************************************************) (* ENTITY one_to_one_relationship *) (****************************************************) (* Higher-level one-to-one relationship constraint. *) (****************************************************) ENTITY one_to_one_relationship SUBTYPE OF (relationship); END_ENTITY; (*****************************************************) (* ENTITY one_to_many_relationship *) (*****************************************************) (* Higher-level one-to-many relationship constraint. *) (*****************************************************) ENTITY one_to_many_relationship SUBTYPE OF (relationship); END_ENTITY; (******************************************************) (* ENTITY many_to_many_relationship *) (******************************************************) (* Higher-level many-to-many relationship constraint. *) (******************************************************) ENTITY many_to_many_relationship SUBTYPE OF (relationship); END_ENTITY; (******************************************************************) (* ENTITY quantifier *) (******************************************************************) (* Superclass for higher-level quantifier (universal/existential) *) (* constraints. *) (******************************************************************) ENTITY quantifier ABSTRACT SUPERTYPE OF (ONEOF(for_all, there_exists)) SUBTYPE OF (higher_level_constraint); bound_variable : query_variable; aggregation : expression; proposition : expression; END_ENTITY; (*************************************************) (* ENTITY for_all *) (*************************************************) (* Higher-level universal quantifier constraint. *) (*************************************************) ENTITY for_all SUBTYPE OF (quantifier); END_ENTITY; (***************************************************) (* ENTITY there_exists *) (***************************************************) (* Higher-level existential quantifier constraint. *) (***************************************************) ENTITY there_exists SUBTYPE OF (quantifier); END_ENTITY; (*END_SCHEMA; ------------------------------------------------------------------------------- (****************************************************************************) (** SCHEMA cbr_frame_class_model **) (****************************************************************************) (** Frame class model of case-based reasoning. **) (****************************************************************************) SCHEMA cbr_frame_class_model; USE FROM express_frame_class_model; USE FROM hlc_frame_class_model;*) (****************************************************************) (* ENTITY case_frame *) (****************************************************************) (* Represents a case, which has a problem and a solution. *) (* The solution is no longer restricted to being a higher-level *) (* constraint, as was the case in Version 1. It could now be an *) (* EXPRESS frame (making the implicit explicit), or a cliche or *) (* design pattern extracted from a program. It can also be a *) (* set of frames now. *) (****************************************************************) ENTITY case_frame ABSTRACT SUPERTYPE OF (ONEOF (extraction_case, navigation_case, pretty_print_case, subexpression_case, semantic_case)) SUBTYPE OF (frame); problem : frame; solution : frame_or_set_of_frames; language : language; filename : STRING; END_ENTITY; (*******************************) (* TYPE frame_or_set_of_frames *) (*******************************) TYPE frame_or_set_of_frames = SELECT (frame, set_of_frames); END_TYPE; (**********************) (* TYPE set_of_frames *) (**********************) TYPE set_of_frames = SET [1 : ?] OF frame; END_TYPE; (********************************************************) (* TYPE language *) (********************************************************) (* Represents the various languages that the CUS knows. *) (********************************************************) TYPE language = ENUMERATION OF (express,java); END_TYPE; (*********************************************************) (* ENTITY extraction_case *) (*********************************************************) (* Represents a case for extracting knowledge from code. *) (*********************************************************) ENTITY extraction_case SUBTYPE OF (case_frame); END_ENTITY; (******************************************************************) (* ENTITY navigation_case *) (******************************************************************) (* Represents a case for navigating code, suggesting which frames *) (* to submit as extraction prompts. *) (******************************************************************) ENTITY navigation_case SUBTYPE OF (case_frame); END_ENTITY; (*************************************************************) (* ENTITY subexpression_case *) (*************************************************************) (* Represents a case for matching subexpressions in the CCUS *) (* (e.g. age >= 0, (age >= 0) AND (age <= 130)). *) (*************************************************************) ENTITY subexpression_case SUBTYPE OF (case_frame); END_ENTITY; (******************************************************************) (* ENTITY submit *) (******************************************************************) (* Represents a suggestion of what frames to submit as extraction *) (* prompts, as used in the solution part of navigation cases. *) (******************************************************************) ENTITY submit SUBTYPE OF (frame); frames : SET [1 : ?] OF frame; END_ENTITY; (****************************************************) (* ENTITY semantic_case *) (****************************************************) (* Represents a semantic-equivalence/strength case. *) (****************************************************) ENTITY semantic_case SUBTYPE OF (case_frame); END_ENTITY; (******************************************************************) (* ENTITY semantic_match_prescription *) (******************************************************************) (* The solution part of a semantic-equivalence/strength case - *) (* it specifies which slots are necessary to match for the frames *) (* correspond, and which slots affect semantic strength. *) (******************************************************************) ENTITY semantic_match_prescription SUBTYPE OF (frame); necessary_slots : SET [0 : ?] OF slot_name; semantic_strength_slots : SET [0:?] OF semantic_strength_slot; END_ENTITY; (***********************************) (* TYPE slot_name; *) (***********************************) (* A slot name is simply a string. *) (***********************************) TYPE slot_name = STRING; END_TYPE; (*****************************************************************) (* ENTITY semantic_strength_slot *) (*****************************************************************) (* The specification, within a semantic match prescription, *) (* of a slot that affects semantic strength, and whether it does *) (* so positively (i.e. the stronger frame will have the greater *) (* (numerical) value for this slot) or negatively. *) (*****************************************************************) ENTITY semantic_strength_slot SUBTYPE OF (frame); slot_name : slot_name; influence : semantic_strength_influence; INVERSE the_semantic_match_prescription : semantic_match_prescription FOR semantic_strength_slots; END_ENTITY; (***************************************************************) (* TYPE semantic_strength_influence *) (***************************************************************) (* A slot can influence semantic strength either positively or *) (* negatively. *) (***************************************************************) TYPE semantic_strength_influence = ENUMERATION OF (positive,negative); END_TYPE; (***************************************************) (* ENTITY pretty_print_case *) (***************************************************) (* Represents a case for pretty-printing HLCs, *) (* i.e. generating a natural-language description. *) (***************************************************) ENTITY pretty_print_case SUBTYPE OF (case_frame); END_ENTITY; (*****************************************************************) (* ENTITY pretty_print *) (*****************************************************************) (* Represents how to generate a natural language description for *) (* an HLC, as used in the solution part of pretty-print cases. *) (*****************************************************************) ENTITY pretty_print SUBTYPE OF (frame); text : LIST [1 : ?] OF pretty_print_type; END_ENTITY; (**************************************************) (* TYPE pretty_print_type; *) (**************************************************) (* The possible element types for a pretty_print. *) (**************************************************) TYPE pretty_print_type = SELECT (text, frame, pp_set, pp_bag, pp_list); END_TYPE; (*****************************) (* TYPE text; *) (*****************************) (* STRING as a defined type. *) (*****************************) TYPE text = STRING; END_TYPE; (*******************************************) (* TYPE pp_set; *) (*******************************************) (* SET as a defined type for pretty_print. *) (*******************************************) TYPE pp_set = SET OF pretty_print_type; END_TYPE; (*******************************************) (* TYPE pp_bag; *) (*******************************************) (* BAG as a defined type for pretty_print. *) (*******************************************) TYPE pp_bag = BAG OF pretty_print_type; END_TYPE; (********************************************) (* TYPE pp_list; *) (********************************************) (* LIST as a defined type for pretty_print. *) (********************************************) TYPE pp_list = LIST OF pretty_print_type; END_TYPE; (*END_SCHEMA; ------------------------------------------------------------------------------- (****************************************************************************) (** SCHEMA java_frame_class_model **) (****************************************************************************) (** Frame class model of Java 1.2. **) (****************************************************************************) SCHEMA java_frame_class_model; REFERENCE FROM hlc_frame_class_model;*) (****************************************) (* ENTITY compilation_unit *) (****************************************) (* The top-level frame for a Java file. *) (****************************************) ENTITY compilation_unit SUBTYPE OF (frame); package : OPTIONAL qualified_name; imports : SET [0 : ?] OF qualified_name; classes : SET [0 : ?] OF type_declaration; END_ENTITY; (*****************************************************) (* TYPE qualified_name *) (*****************************************************) (* Represents a qualified name as a list of strings. *) (*****************************************************) TYPE qualified_name = LIST [1 : ?] OF STRING; END_TYPE; (*******************************************************************) (* TYPE access_modifier *) (*******************************************************************) (* Represents whether something is public, protected or private. *) (* If none of these modifiers are used, the default is `friendly', *) (* i.e. accessible to all classes within the same package. *) (*******************************************************************) TYPE access_modifier = ENUMERATION OF (public, protected, private, friendly); END_TYPE; (**************************************) (* ENTITY type_declaration *) (**************************************) (* Represents classes and interfaces. *) (**************************************) ENTITY type_declaration ABSTRACT SUPERTYPE OF (ONEOF(class, interface)) SUBTYPE OF (frame); name : OPTIONAL STRING; --OPTIONAL for anonymous local classes access_status : access_modifier; is_abstract : BOOLEAN; is_strictfp : BOOLEAN; nested_classes : SET [0 : ?] OF nested_class; nested_interfaces : SET [0 : ?] OF nested_interface; methods : SET [0 : ?] OF method; fields : SET [0 : ?] OF field; END_ENTITY; (*********************************************) (* ENTITY nested_type_declaration *) (*********************************************) (* Represents nested classes and interfaces. *) (*********************************************) ENTITY nested_type_declaration ABSTRACT SUPERTYPE OF (ONEOF(nested_class, nested_interface)) SUBTYPE OF (type_declaration); is_static : BOOLEAN; END_ENTITY; (********************************************) (* ENTITY local_type_declaration *) (********************************************) (* Represents local classes and interfaces. *) (********************************************) ENTITY local_type_declaration ABSTRACT SUPERTYPE OF (ONEOF(local_class, local_interface)) SUBTYPE OF (type_declaration); END_ENTITY; (****************************) (* ENTITY class *) (****************************) (* Represents a Java class. *) (****************************) ENTITY class SUBTYPE OF (type_declaration); is_final : OPTIONAL BOOLEAN; superclass : OPTIONAL class; interfaces_implemented : OPTIONAL SET [1 : ?] OF interface; initialisers : SET [0 : ?] OF class_initialiser; constructors : SET [0 : ?] OF constructor; INVERSE subclasses : SET [0 : ?] OF class FOR superclass; END_ENTITY; (***********************************) (* ENTITY nested_class *) (***********************************) (* Represents a nested Java class. *) (***********************************) ENTITY nested_class SUBTYPE OF (class, nested_type_declaration); END_ENTITY; (**********************************) (* ENTITY local_class *) (**********************************) (* Represents a local Java class. *) (**********************************) ENTITY local_class SUBTYPE OF (class, local_type_declaration); WHERE a_local_class_has_no_modifiers: NOT EXISTS(is_final); END_ENTITY; (********************************) (* ENTITY interface *) (********************************) (* Represents a Java interface. *) (********************************) ENTITY interface SUBTYPE OF (type_declaration); superinterfaces : OPTIONAL SET [1 : ?] OF interface; END_ENTITY; (***************************************) (* ENTITY nested_interface *) (***************************************) (* Represents a nested Java interface. *) (***************************************) ENTITY nested_interface SUBTYPE OF(interface,nested_type_declaration); END_ENTITY; (**************************************) (* ENTITY local_interface *) (**************************************) (* Represents a local Java interface. *) (**************************************) ENTITY local_interface SUBTYPE OF (interface, local_type_declaration); END_ENTITY; (****************************************************************) (* ENTITY class_initialiser *) (****************************************************************) (* Represents a class initialiser, i.e. a block of code that is *) (* executed when the class is loaded (if static), or when an *) (* instance of the class is created. *) (****************************************************************) ENTITY class_initialiser SUBTYPE OF (type_declaration); is_static : BOOLEAN; block : block; END_ENTITY; (***********************************************) (* ENTITY java_function *) (***********************************************) (* The superclass of constructors and methods. *) (***********************************************) ENTITY java_function ABSTRACT SUPERTYPE OF (ONEOF (constructor, method)) SUBTYPE OF (frame); access_status : access_modifier; formal_parameters : LIST [0 : ?] OF java_formal_parameter; throws_exceptions : OPTIONAL SET [1 : ?] OF class; body : OPTIONAL block; END_ENTITY; (*********************************************) (* ENTITY constructor *) (*********************************************) (* Represents a constructor of a Java class. *) (*********************************************) ENTITY constructor SUBTYPE OF (java_function); END_ENTITY; (****************************************) (* ENTITY method *) (****************************************) (* Represents a method of a Java class. *) (****************************************) ENTITY method SUBTYPE OF (java_function); name : STRING; is_static : BOOLEAN; is_abstract : BOOLEAN; is_final : BOOLEAN; is_native : BOOLEAN; is_synchronised : BOOLEAN; is_strictfp : BOOLEAN; return_type : OPTIONAL java_type; -- null represents void END_ENTITY; (*************************************************) (* ENTITY java_variable *) (*************************************************) (* The superclass of fields and local variables. *) (*************************************************) ENTITY java_variable ABSTRACT SUPERTYPE OF (ONEOF (field, java_formal_parameter, local_variable)) SUBTYPE OF (named_frame); tipe : java_type; is_final : BOOLEAN; END_ENTITY; (***************************************) (* ENTITY field *) (***************************************) (* Represents a field of a Java class. *) (***************************************) ENTITY field SUBTYPE OF (java_variable); access_status : access_modifier; is_static : BOOLEAN; is_transient : BOOLEAN; is_volatile : BOOLEAN; initialiser : OPTIONAL variable_initialiser; END_ENTITY; (*************************************) (* ENTITY block *) (*************************************) (* Represents a block of statements. *) (*************************************) ENTITY block SUBTYPE OF (statement); statements : LIST [0 : ?] OF statement; local_variables : SET [0 : ?] OF local_variable; local_classes : SET [0 : ?] OF local_class; local_interfaces : SET [0 : ?] OF local_interface; END_ENTITY; (******************************) (* TYPE java_type *) (******************************) (* Represents a type in Java. *) (******************************) TYPE java_type = SELECT (type_declaration, primitive_type, java_array_type); END_TYPE; (****************************************) (* TYPE primitive_type *) (****************************************) (* Represents a primitive type in Java. *) (****************************************) TYPE primitive_type = ENUMERATION OF (boolean_type, char, byte, short, int, long, float, double); END_TYPE; (**************************) (* ENTITY java_array_type *) (**************************) ENTITY java_array_type SUBTYPE OF (frame); element_type : java_type; number_of_dimensions : INTEGER; END_ENTITY; (*****************************************************) (* ENTITY java_formal_parameter *) (*****************************************************) (* Represents a formal parameter of a Java function. *) (*****************************************************) ENTITY java_formal_parameter SUBTYPE OF (java_variable); END_ENTITY; (********************************************************) (* TYPE variable_initialiser *) (********************************************************) (* Represents an initialiser in a variable declaration. *) (********************************************************) TYPE variable_initialiser = SELECT (expression, array_initialiser); END_TYPE; (******************************************************) (* TYPE array_initialiser *) (******************************************************) (* Represents an initialiser in an array declaration. *) (******************************************************) TYPE array_initialiser = LIST [1 : ?] OF variable_initialiser; END_TYPE; (***************************) (* ENTITY statement *) (***************************) (* Represents a statement. *) (***************************) ENTITY statement ABSTRACT SUPERTYPE SUBTYPE OF (frame); label : OPTIONAL STRING; END_ENTITY; (**************************************************) (* ENTITY explicit_constructor_invocation *) (**************************************************) (* Represents an explicit constructor invocation, *) (* i.e. "this(...)" or "super(...)". *) (**************************************************) ENTITY explicit_constructor_invocation SUBTYPE OF (statement); constructor_invoked : constructor; -- What about when there's a primary exppression `.'? arguments : LIST [0 : ?] OF expression; END_ENTITY; (**************************************************) (* ENTITY local_variable_declaration *) (**************************************************) (* Represents the declaration of a local variable *) (* (or several at once). *) (**************************************************) ENTITY local_variable_declaration SUBTYPE OF (statement); the_variables : LIST [1 : ?] OF local_variable; END_ENTITY; (************************************************) (* ENTITY local_variable *) (************************************************) (* Represents a local variable in a Java block. *) (************************************************) ENTITY local_variable SUBTYPE OF (java_variable); initialiser : OPTIONAL variable_initialiser; END_ENTITY; (************************************************) (* ENTITY local_class_declaration *) (************************************************) (* Represents the declaration of a local class. *) (************************************************) ENTITY local_class_declaration SUBTYPE OF (statement); the_class : local_class; END_ENTITY; (****************************************************) (* ENTITY local_interface_declaration *) (****************************************************) (* Represents the declaration of a local interface. *) (****************************************************) ENTITY local_interface_declaration SUBTYPE OF (statement); the_interface : local_interface; END_ENTITY; (**********************************) (* ENTITY empty_statement *) (**********************************) (* Represents an empty statement. *) (**********************************) ENTITY empty_statement SUBTYPE OF (statement); END_ENTITY; (*************************************************) (* ENTITY expression_statement *) (*************************************************) (* Represents a statement that is an expression. *) (*************************************************) ENTITY expression_statement SUBTYPE OF (statement); expression : expression; END_ENTITY; (**********************************) (* ENTITY switch_statement *) (**********************************) (* Represents a switch statement. *) (**********************************) ENTITY switch_statement SUBTYPE OF (statement); switch_value : expression; cases : LIST [0 : ?] OF switch_case; END_ENTITY; (********************************************) (* ENTITY switch_case *) (********************************************) (* Represents a case in a switch statement. *) (********************************************) ENTITY switch_case ABSTRACT SUPERTYPE OF (ONEOF (case_switch_case, default_switch_case)) SUBTYPE OF (frame); statements : LIST [0 : ?] OF statement; END_ENTITY; (******************************************************************) (* ENTITY case_switch_case *) (******************************************************************) (* Represents a case in a switch statement that is not "default". *) (******************************************************************) ENTITY case_switch_case SUBTYPE OF (switch_case); case_value : expression; END_ENTITY; (****************************************************) (* ENTITY default_switch_case *) (****************************************************) (* Represents a default case in a switch statement. *) (****************************************************) ENTITY default_switch_case SUBTYPE OF (switch_case); END_ENTITY; (*******************************) (* ENTITY if_statement *) (*******************************) (* Represents an if statement. *) (*******************************) ENTITY if_statement SUBTYPE OF (statement); condition : expression; then_statement : statement; else_statement : OPTIONAL statement; END_ENTITY; (****************************) (* ENTITY while_statement *) (****************************) (* Represents a while loop. *) (****************************) ENTITY while_statement SUBTYPE OF (statement); condition : expression; statement : statement; END_ENTITY; (*******************************) (* ENTITY do_while_statement *) (*******************************) (* Represents a do-while loop. *) (*******************************) ENTITY do_while_statement SUBTYPE OF (statement); statement : statement; condition : expression; END_ENTITY; (**************************) (* ENTITY for_statement *) (**************************) (* Represents a for loop. *) (**************************) ENTITY for_statement SUBTYPE OF (statement); initialisation : OPTIONAL for_initialiser; condition : OPTIONAL expression; update : OPTIONAL expression_statement_list; statement : statement; END_ENTITY; (*********************************************) (* TYPE for_initialiser *) (*********************************************) (* Represents the initialiser of a for loop. *) (*********************************************) TYPE for_initialiser = SELECT (local_variable_declaration, expression_statement_list); END_TYPE; (**********************************************************) (* ENTITY expression_statement_list *) (**********************************************************) (* Represents a list of expressions, separated by commas, *) (* as found in for loops. *) (**********************************************************) ENTITY expression_statement_list SUBTYPE OF (frame); expression_statements : LIST [1 : ?] OF expression_statement; END_ENTITY; (*********************************) (* ENTITY break_statement *) (*********************************) (* Represents a break statement. *) (*********************************) ENTITY break_statement SUBTYPE OF (statement); destination_label : OPTIONAL STRING; END_ENTITY; (************************************) (* ENTITY continue_statement *) (************************************) (* Represents a continue statement. *) (************************************) ENTITY continue_statement SUBTYPE OF (statement); destination_label : OPTIONAL STRING; END_ENTITY; (**********************************) (* ENTITY return_statement *) (**********************************) (* Represents a return statement. *) (**********************************) ENTITY return_statement SUBTYPE OF (statement); return_value : OPTIONAL expression; END_ENTITY; (*********************************) (* ENTITY throw_statement *) (*********************************) (* Represents a throw statement. *) (*********************************) ENTITY throw_statement SUBTYPE OF (statement); throwable_object : expression; END_ENTITY; (****************************************) (* ENTITY synchronised_statement *) (****************************************) (* Represents a synchronised statement. *) (****************************************) ENTITY synchronised_statement SUBTYPE OF (statement); expression : expression; block : block; END_ENTITY; (*******************************) (* ENTITY try_statement *) (*******************************) (* Represents a try statement. *) (*******************************) ENTITY try_statement SUBTYPE OF (statement); try_block : block; catches : LIST [0 : ?] OF catch; finally_block : OPTIONAL block; ---x--- WHERE ---x--- at_least_one_catch_or_finally: ---x--- (SIZEOF(catches) >= 1) OR EXISSTS(finally_block); END_ENTITY; (******************************************) (* ENTITY catch *) (******************************************) (* Represents a catch in a try statement. *) (******************************************) ENTITY catch SUBTYPE OF (frame); parameter : java_formal_parameter; block : block; END_ENTITY; (***********************************************) (* ENTITY assignment_operation *) (***********************************************) (* Represents an assignment operation in Java, *) (* which is an expression. *) (***********************************************) ENTITY assignment_operation SUBTYPE OF (expression); lvalue : expression; rvalue : expression; END_ENTITY; (****************************************************************) (* ENTITY conditional_expression *) (****************************************************************) (* Represents an conditional expression in Java, i.e. c ? t : e *) (****************************************************************) ENTITY conditional_expression SUBTYPE OF (expression); condition : expression; then_expression : expression; else_expression : expression; END_ENTITY; (*********************************************************) (* ENTITY bitwise_or *) (*********************************************************) (* Represents a bitwise inclusive OR in Java, i.e. a | b *) (*********************************************************) ENTITY bitwise_or SUBTYPE OF (expression); disjuncts : BAG [2 : ?] OF expression; END_ENTITY; (************************************************) (* ENTITY bitwise_xor *) (************************************************) (* Represents a bitwise XOR in Java, i.e. a ^ b *) (************************************************) ENTITY bitwise_xor SUBTYPE OF (expression); disjuncts : BAG [2 : ?] OF expression; END_ENTITY; (************************************************) (* ENTITY bitwise_and *) (************************************************) (* Represents a bitwise AND in Java, i.e. a & b *) (************************************************) ENTITY bitwise_and SUBTYPE OF (expression); conjuncts : BAG [2 : ?] OF expression; END_ENTITY; (*********************************************) (* ENTITY bitwise_not *) (*********************************************) (* Represents a bitwise NOT in Java, i.e. ~a *) (*********************************************) ENTITY bitwise_not SUBTYPE OF (expression); operand : expression; END_ENTITY; (***********************************************) (* ENTITY instanceof *) (***********************************************) (* Represents an instanceof predicate in Java. *) (***********************************************) ENTITY instanceof SUBTYPE OF (expression); object : expression; class : type_declaration; END_ENTITY; (*************************************************) (* ENTITY shift_left *) (*************************************************) (* Represents a left shift in Java, i.e. a << b. *) (*************************************************) ENTITY shift_left SUBTYPE OF (expression); operand : expression; number_of_bits : expression; END_ENTITY; (*************************************) (* ENTITY shift_right *) (*************************************) (* Represents a right shift in Java. *) (*************************************) ENTITY shift_right ABSTRACT SUPERTYPE OF (ONEOF(shift_right_arithmetic, shift_right_logical)) SUBTYPE OF (expression); operand : expression; number_of_bits : expression; END_ENTITY; (*************************************************************) (* ENTITY shift_right_arithmetic *) (*************************************************************) (* Represents an arithmetic right shift in Java, i.e. a >> b *) (*************************************************************) ENTITY shift_right_arithmetic SUBTYPE OF (shift_right); END_ENTITY; (**********************************************************) (* ENTITY shift_right_logical *) (**********************************************************) (* Represents a logical right shift in Java, i.e. a >>> b *) (**********************************************************) ENTITY shift_right_logical SUBTYPE OF (shift_right); END_ENTITY; (*****************************************) (* ENTITY increment *) (*****************************************) (* Represents an increment (++) in Java. *) (*****************************************) ENTITY increment ABSTRACT SUPERTYPE OF (ONEOF(postincrement, preincrement)) SUBTYPE OF (expression); variable : expression; END_ENTITY; (************************************************) (* ENTITY postincrement *) (************************************************) (* Represents a postincrement in Java, i.e. v++ *) (************************************************) ENTITY postincrement SUBTYPE OF (increment); END_ENTITY; (***********************************************) (* ENTITY preincrement *) (***********************************************) (* Represents a preincrement in Java, i.e. ++v *) (***********************************************) ENTITY preincrement SUBTYPE OF (increment); END_ENTITY; (****************************************) (* ENTITY decrement *) (****************************************) (* Represents a decrement (--) in Java. *) (****************************************) ENTITY decrement ABSTRACT SUPERTYPE OF (ONEOF(postdecrement, predecrement)) SUBTYPE OF (expression); variable : expression; END_ENTITY; (************************************************) (* ENTITY postdecrement *) (************************************************) (* Represents a postdecrement in Java, i.e. v-- *) (************************************************) ENTITY postdecrement SUBTYPE OF (decrement); END_ENTITY; (***********************************************) (* ENTITY predecrement *) (***********************************************) (* Represents a predecrement in Java, i.e. --v *) (***********************************************) ENTITY predecrement SUBTYPE OF (decrement); END_ENTITY; (***********************************) (* ENTITY cast *) (***********************************) (* Represents a type cast in Java. *) (***********************************) ENTITY cast SUBTYPE OF (expression); cast_type : java_type; object : expression; END_ENTITY; (***************************************) (* ENTITY class_literal *) (***************************************) (* Represents a class literal in Java. *) (***************************************) ENTITY class_literal SUBTYPE OF (expression); class : type_declaration; END_ENTITY; (****************************) (* ENTITY character_literal *) (****************************) (* A character literal. *) (****************************) ENTITY character_literal SUBTYPE OF (literal); literal_value : STRING; END_ENTITY; (********************************) (* ENTITY null *) (********************************) (* Represents the null literal. *) (********************************) ENTITY null SUBTYPE OF (expression); END_ENTITY; (************************************************************) (* ENTITY allocation *) (************************************************************) (* Represents an allocation expression in Java, i.e. new... *) (************************************************************) ENTITY allocation SUBTYPE OF (expression); new_type : java_type; arguments : OPTIONAL LIST [0 : ?] OF expression; array_dimensions : OPTIONAL LIST [1 : ?] OF expression; array_initialiser : OPTIONAL array_initialiser; anonymous_class : OPTIONAL local_class; END_ENTITY; (*END_SCHEMA; ------------------------------------------------------------------------------- (****************************************************************************) (** SCHEMA java_hlk_frame_class_model **) (****************************************************************************) (** Frame class model of higher-level knowledge for Java. **) (****************************************************************************) SCHEMA java_hlk_frame_class_model; USE FROM java_frame_class_model;*) (****************************************************) (* ENTITY swap *) (****************************************************) (* Represents swapping the values of two variables. *) (****************************************************) ENTITY swap SUBTYPE OF (higher_level_constraint); var1 : frame; var2 : frame; temp_var : frame; END_ENTITY; END_SCHEMA;