|
@@ -0,0 +1,270 @@
|
|
|
+include "primitives.alh"
|
|
|
+include "object_operations.alh"
|
|
|
+include "modelling.alh"
|
|
|
+
|
|
|
+
|
|
|
+SimpleAttribute Neutral {}
|
|
|
+SimpleAttribute Boolean {
|
|
|
+ constraint = $
|
|
|
+ String function constraint(model: Element, id: String):
|
|
|
+ if (bool_not(is_physical_boolean(model["model"][id]))):
|
|
|
+ return "Boolean has no boolean value at " + id!
|
|
|
+ else:
|
|
|
+ return "OK"!
|
|
|
+ $
|
|
|
+}
|
|
|
+SimpleAttribute String {
|
|
|
+ constraint = $
|
|
|
+ String function constraint(model: Element, id: String):
|
|
|
+ if (bool_not(is_physical_string(model["model"][id]))):
|
|
|
+ return "String has no string value at " + id!
|
|
|
+ else:
|
|
|
+ return "OK"!
|
|
|
+ $
|
|
|
+}
|
|
|
+SimpleAttribute Natural {
|
|
|
+ constraint =$
|
|
|
+ String function constraint(model: Element, id: String):
|
|
|
+ if (bool_not(is_physical_int(model["model"][id]))):
|
|
|
+ return "Natural has no integer value at " + id!
|
|
|
+ elif (integer_lt(model["model"][id], 0)):
|
|
|
+ return "Natural does not have a positive or zero value at " + id!
|
|
|
+ else:
|
|
|
+ return "OK"!
|
|
|
+ $
|
|
|
+}
|
|
|
+SimpleAttribute PositiveFloat {
|
|
|
+ constraint =$
|
|
|
+ String function constraint(model: Element, id: String):
|
|
|
+ if (bool_not(is_physical_float(model["model"][id]))):
|
|
|
+ return "PositiveFloat has no float value at " + id!
|
|
|
+ elif (integer_lt(model["model"][id], 0)):
|
|
|
+ return "PositiveFloat does not have a positive or zero value at " + id!
|
|
|
+ else:
|
|
|
+ return "OK"!
|
|
|
+ $
|
|
|
+}
|
|
|
+SimpleAttribute EventScope {
|
|
|
+ constraint =$
|
|
|
+ String function constraint(model: Element, id: String):
|
|
|
+ String self
|
|
|
+ self = model["model"][id]
|
|
|
+ if (bool_not(is_physical_string(self))):
|
|
|
+ return "EventScope has no string value at " + id!
|
|
|
+ elif (bool_or(bool_or(bool_or(self != "broad", self != "cd"), bool_or(self != "narrow", self != "output")), self != 'local')):
|
|
|
+ return "EventScope can be either 'local', 'broad', 'cd', 'narrow' or 'output' and it does not have a proper value at " + id!
|
|
|
+ else:
|
|
|
+ return "OK"!
|
|
|
+ $
|
|
|
+}
|
|
|
+
|
|
|
+Class Diagram{
|
|
|
+ name : String
|
|
|
+ author ?: String
|
|
|
+ description ?: String
|
|
|
+ top ?: String
|
|
|
+ class_reference_items ?: String
|
|
|
+ lower_cardinality = 1
|
|
|
+ upper_cardinality = 1
|
|
|
+}
|
|
|
+Class Inport{
|
|
|
+ name: String
|
|
|
+}
|
|
|
+Class Outport{
|
|
|
+ name: String
|
|
|
+}
|
|
|
+Association diagram_inports(Diagram, Inport){}
|
|
|
+Association diagram_outports(Diagram, Outport){}
|
|
|
+
|
|
|
+Class Class{
|
|
|
+ name : String
|
|
|
+ constructor_body ?: String
|
|
|
+ destructor ?: String
|
|
|
+ default ?: Boolean
|
|
|
+ external ?: Boolean
|
|
|
+ class_behaviour_items ?: String
|
|
|
+}
|
|
|
+Association diagram_classes(Diagram, Class){
|
|
|
+ target_lower_cardinality = 1
|
|
|
+}
|
|
|
+
|
|
|
+Class Attribute{
|
|
|
+ name : String
|
|
|
+ type ?: String
|
|
|
+}
|
|
|
+Association class_attributes(Class, Attribute){}
|
|
|
+
|
|
|
+Class Method{
|
|
|
+ name : String
|
|
|
+ body : String
|
|
|
+ return_type ?: String
|
|
|
+}
|
|
|
+
|
|
|
+Class FormalParameter{
|
|
|
+ name: String
|
|
|
+ type ?: String
|
|
|
+ default ?: String
|
|
|
+}
|
|
|
+Association method_parameters(Method, FormalParameter){}
|
|
|
+Association class_methods(Class, Method){}
|
|
|
+Association class_constructor_parameters(Class, FormalParameter){}
|
|
|
+
|
|
|
+Class CanvasPosition{
|
|
|
+ x1: Natural
|
|
|
+ y1: Natural
|
|
|
+ x2 ?: Natural
|
|
|
+ y2 ?: Natural
|
|
|
+}
|
|
|
+Association class_ref_position(Class, CanvasPosition){
|
|
|
+ target_upper_cardinality = 1
|
|
|
+}
|
|
|
+Association class_beh_position(Class, CanvasPosition){
|
|
|
+ target_upper_cardinality = 1
|
|
|
+}
|
|
|
+
|
|
|
+Association association(Class, Class){
|
|
|
+ name : String
|
|
|
+ min ?: Natural
|
|
|
+ max ?: Natural
|
|
|
+ source_upper_cardinality = 1
|
|
|
+}
|
|
|
+Association association_positions(association, CanvasPosition){
|
|
|
+ order: Natural
|
|
|
+}
|
|
|
+
|
|
|
+Association inheritance(Class, Class){
|
|
|
+ priority ?: Natural
|
|
|
+ source_upper_cardinality = 1
|
|
|
+}
|
|
|
+
|
|
|
+Class SuperClassConstructorParameter{
|
|
|
+ value : Neutral
|
|
|
+}
|
|
|
+Association inheritance_parent_constructor_parameters(inheritance, SuperClassConstructorParameter){
|
|
|
+ order : Natural
|
|
|
+}
|
|
|
+Association inheritance_positions(inheritance, CanvasPosition){
|
|
|
+ order: Natural
|
|
|
+}
|
|
|
+
|
|
|
+Class State{
|
|
|
+ name : String
|
|
|
+ state_reference_path ?: String
|
|
|
+}
|
|
|
+Association state_position(State, CanvasPosition){
|
|
|
+ target_upper_cardinality = 1
|
|
|
+}
|
|
|
+
|
|
|
+Class BasicState : State{
|
|
|
+ isInitial : Boolean
|
|
|
+ onEntryScript ?: String
|
|
|
+ onExitScript ?: String
|
|
|
+}
|
|
|
+
|
|
|
+Class ActualParameter{
|
|
|
+ exp: String
|
|
|
+}
|
|
|
+
|
|
|
+Class Raise{
|
|
|
+ event: String
|
|
|
+ scope ?: EventScope
|
|
|
+ port ?: String
|
|
|
+ target ?: String
|
|
|
+}
|
|
|
+Association raise_parameters(Raise, ActualParameter){
|
|
|
+ order : Natural
|
|
|
+}
|
|
|
+Association state_onentry_raises(BasicState, Raise){
|
|
|
+ order : Natural
|
|
|
+}
|
|
|
+Association state_onexit_raises(BasicState, Raise){
|
|
|
+ order : Natural
|
|
|
+}
|
|
|
+
|
|
|
+Class CompositeState : BasicState{}
|
|
|
+Association composite_children(CompositeState, State){
|
|
|
+ source_upper_cardinality = 1
|
|
|
+}
|
|
|
+Association behaviour(Class, CompositeState){
|
|
|
+ target_lower_cardinality = 1
|
|
|
+ target_upper_cardinality = 1
|
|
|
+}
|
|
|
+Association behaviour_positions(behaviour, CanvasPosition){
|
|
|
+ order: Natural
|
|
|
+}
|
|
|
+
|
|
|
+Class ParallelState : BasicState{}
|
|
|
+Association parallel_children(ParallelState, CompositeState){
|
|
|
+ source_upper_cardinality = 1
|
|
|
+}
|
|
|
+
|
|
|
+Class HistoryState : State{
|
|
|
+ type : String
|
|
|
+}
|
|
|
+
|
|
|
+Association transition(State, State){
|
|
|
+ name: String
|
|
|
+ cond ?: String
|
|
|
+ script ?: String
|
|
|
+ after ?: PositiveFloat
|
|
|
+ event ?: String
|
|
|
+ port ?: String
|
|
|
+ source_upper_cardinality = 1
|
|
|
+}
|
|
|
+Association transition_parameters(transition, FormalParameter){
|
|
|
+ order : Natural
|
|
|
+}
|
|
|
+Association transition_raises(transition, Raise){
|
|
|
+ order : Natural
|
|
|
+}
|
|
|
+Association transition_positions(transition, CanvasPosition){
|
|
|
+ order: Natural
|
|
|
+}
|
|
|
+
|
|
|
+GlobalConstraint {
|
|
|
+ global_constraint = $
|
|
|
+ String function constraint(model : Element):
|
|
|
+ Element composite_states
|
|
|
+ Element parallel_states
|
|
|
+ Element children
|
|
|
+ String state
|
|
|
+ String child
|
|
|
+ String name
|
|
|
+ Boolean CompInitialFound
|
|
|
+ Element encountered_names
|
|
|
+
|
|
|
+ composite_states = allInstances(model, "CompositeState")
|
|
|
+ parallel_states = allInstances(model, "ParallelState")
|
|
|
+
|
|
|
+ while (list_len(composite_states) >0):
|
|
|
+ CompInitialFound = False
|
|
|
+ encountered_names = create_node()
|
|
|
+ state = set_pop(composite_states)
|
|
|
+ children = allAssociationDestinations(model, state, "composite_children")
|
|
|
+ while (list_len(children)>0):
|
|
|
+ child = set_pop(children)
|
|
|
+ name = read_attribute(model, child, 'name')
|
|
|
+ if (set_in(encountered_names, name)):
|
|
|
+ return "Unique state identifier names on the same level/parent violated"!
|
|
|
+ else:
|
|
|
+ set_add(encountered_names, name)
|
|
|
+ if bool_and(read_type(model, child) != 'HistoryState' , read_attribute(model, child, 'isInitial')):
|
|
|
+ CompInitialFound = True
|
|
|
+ if CompInitialFound == False:
|
|
|
+ return "Composite state does not have an initial child state"!
|
|
|
+
|
|
|
+ while (list_len(parallel_states) >0):
|
|
|
+ encountered_names = create_node()
|
|
|
+ state = set_pop(parallel_states)
|
|
|
+ children = allAssociationDestinations(model, state, "parallel_children")
|
|
|
+ while (list_len(children)>0):
|
|
|
+ child = set_pop(children)
|
|
|
+ name = read_attribute(model, child, 'name')
|
|
|
+ if (set_in(encountered_names, name)):
|
|
|
+ return "Unique state identifier names on the same level/parent violated"!
|
|
|
+ else:
|
|
|
+ set_add(encountered_names, name)
|
|
|
+
|
|
|
+ return "OK"!
|
|
|
+ $
|
|
|
+ }
|