|
@@ -8,45 +8,37 @@ Element function create_metamodels():
|
|
|
if (bool_not(dict_in(dict_read(read_root(), "__hierarchy"), "models"))):
|
|
|
Element scd
|
|
|
scd = instantiate_bottom()
|
|
|
+
|
|
|
+ // Initial model, typed using LTM_bottom
|
|
|
model_add_node(scd, "Class")
|
|
|
- model_add_node(scd, "Type")
|
|
|
model_add_node(scd, "Any")
|
|
|
model_add_node(scd, "String")
|
|
|
- model_add_value(scd, "inheritance", "inheritance")
|
|
|
- model_add_value(scd, "link", "link")
|
|
|
model_add_value(scd, "name", "name")
|
|
|
- model_add_edge(scd, "class_inherits_any", "Class", "Any")
|
|
|
- model_add_edge(scd, "type_inherits_any", "Type", "Any")
|
|
|
- model_add_edge(scd, "Inheritance", "Any", "Any")
|
|
|
- model_add_edge(scd, "inheritance_name", "Inheritance", "inheritance")
|
|
|
- model_add_edge(scd, "Association", "Any", "Any")
|
|
|
- model_add_edge(scd, "assoc_inherits_any", "Association", "Any")
|
|
|
- model_add_edge(scd, "association_name", "Association", "link")
|
|
|
- model_add_edge(scd, "association_attr", "Association", "String")
|
|
|
- model_add_edge(scd, "attr_name", "association_attr", "name")
|
|
|
- model_add_node(scd, "Integer")
|
|
|
+ model_add_edge(scd, "Association", "Class", "Any")
|
|
|
+ model_add_edge(scd, "Inheritance", "Class", "Class")
|
|
|
+ model_add_edge(scd, "Association_attribute", "Association", "String")
|
|
|
+ model_add_edge(scd, "Association_name", "Association_attribute", "name")
|
|
|
+ model_add_edge(scd, "assoc_inh_class", "Association", "Class")
|
|
|
+ model_add_edge(scd, "class_inh_any", "Class", "Any")
|
|
|
+ model_add_edge(scd, "string_inh_any", "String", "Any")
|
|
|
|
|
|
+ // Retype to a "real" LTM, which happens to be itself
|
|
|
retype_model(scd, scd)
|
|
|
define_inheritance(scd, "Inheritance")
|
|
|
retype(scd, "Class", "Class")
|
|
|
- retype(scd, "Type", "Class")
|
|
|
retype(scd, "Any", "Class")
|
|
|
- retype(scd, "String", "Type")
|
|
|
- retype(scd, "inheritance", "String")
|
|
|
- retype(scd, "link", "String")
|
|
|
+ retype(scd, "String", "Class")
|
|
|
retype(scd, "name", "String")
|
|
|
- retype(scd, "class_inherits_any", "Inheritance")
|
|
|
- retype(scd, "type_inherits_any", "Inheritance")
|
|
|
- retype(scd, "Inheritance", "Association")
|
|
|
- retype(scd, "inheritance_name", "association_attr")
|
|
|
retype(scd, "Association", "Association")
|
|
|
- retype(scd, "assoc_inherits_any", "Inheritance")
|
|
|
- retype(scd, "association_name", "association_attr")
|
|
|
- retype(scd, "association_attr", "Association")
|
|
|
- retype(scd, "attr_name", "association_attr")
|
|
|
- retype(scd, "Integer", "Type")
|
|
|
+ retype(scd, "Inheritance", "Association")
|
|
|
+ retype(scd, "Association_attribute", "Association")
|
|
|
+ retype(scd, "Association_name", "Association_attribute")
|
|
|
+ retype(scd, "assoc_inh_class", "Inheritance")
|
|
|
+ retype(scd, "class_inh_any", "Inheritance")
|
|
|
+ retype(scd, "string_inh_any", "Inheritance")
|
|
|
|
|
|
- // Add some attributes "the nice way" now that everything is typed
|
|
|
+ // Add some attributes, now that it is an ordinary model
|
|
|
+ instantiate_node(scd, "Class", "Integer")
|
|
|
instantiate_link(scd, "Association", "lc", "Class", "Integer")
|
|
|
instantiate_attribute(scd, "lc", "name", "lower_cardinality")
|
|
|
instantiate_link(scd, "Association", "uc", "Class", "Integer")
|
|
@@ -60,8 +52,80 @@ Element function create_metamodels():
|
|
|
instantiate_link(scd, "Association", "tuc", "Association", "Integer")
|
|
|
instantiate_attribute(scd, "tuc", "name", "target_upper_cardinality")
|
|
|
|
|
|
+ // Add in the Action Language metamodel
|
|
|
+ instantiate_node(scd, "Class", "Action")
|
|
|
+ instantiate_node(scd, "Class", "Statement")
|
|
|
+ instantiate_node(scd, "Class", "Expression")
|
|
|
+ instantiate_node(scd, "Class", "funcdef")
|
|
|
+ instantiate_node(scd, "Class", "param")
|
|
|
+ instantiate_node(scd, "Class", "if")
|
|
|
+ instantiate_node(scd, "Class", "break")
|
|
|
+ instantiate_node(scd, "Class", "while")
|
|
|
+ instantiate_node(scd, "Class", "continue")
|
|
|
+ instantiate_node(scd, "Class", "assign")
|
|
|
+ instantiate_node(scd, "Class", "return")
|
|
|
+ instantiate_node(scd, "Class", "output")
|
|
|
+ instantiate_node(scd, "Class", "declare")
|
|
|
+ instantiate_node(scd, "Class", "global")
|
|
|
+ instantiate_node(scd, "Class", "access")
|
|
|
+ instantiate_node(scd, "Class", "constant")
|
|
|
+ instantiate_node(scd, "Class", "input")
|
|
|
+ instantiate_node(scd, "Class", "resolve")
|
|
|
+ instantiate_node(scd, "Class", "call")
|
|
|
+ instantiate_link(scd, "Association", "dict_link", "Action", "Any")
|
|
|
+ instantiate_link(scd, "Association", "to_str", "dict_link", "String")
|
|
|
+ instantiate_attribute(scd, "to_str", "name", "name")
|
|
|
+ instantiate_link(scd, "Inheritance", "", "Action", "Any")
|
|
|
+ instantiate_link(scd, "Inheritance", "", "funcdef", "Action")
|
|
|
+ instantiate_link(scd, "Inheritance", "", "param", "Action")
|
|
|
+ instantiate_link(scd, "Inheritance", "", "Statement", "Action")
|
|
|
+ instantiate_link(scd, "Inheritance", "", "Expression", "Action")
|
|
|
+ instantiate_link(scd, "Inheritance", "", "resolve", "Statement")
|
|
|
+ instantiate_link(scd, "Inheritance", "", "if", "Statement")
|
|
|
+ instantiate_link(scd, "Inheritance", "", "break", "Statement")
|
|
|
+ instantiate_link(scd, "Inheritance", "", "continue", "Statement")
|
|
|
+ instantiate_link(scd, "Inheritance", "", "global", "Statement")
|
|
|
+ instantiate_link(scd, "Inheritance", "", "while", "Statement")
|
|
|
+ instantiate_link(scd, "Inheritance", "", "assign", "Statement")
|
|
|
+ instantiate_link(scd, "Inheritance", "", "return", "Statement")
|
|
|
+ instantiate_link(scd, "Inheritance", "", "call", "Statement")
|
|
|
+ instantiate_link(scd, "Inheritance", "", "declare", "Statement")
|
|
|
+ instantiate_link(scd, "Inheritance", "", "call", "Expression")
|
|
|
+ instantiate_link(scd, "Inheritance", "", "access", "Expression")
|
|
|
+ instantiate_link(scd, "Inheritance", "", "constant", "Expression")
|
|
|
+ instantiate_link(scd, "Inheritance", "", "input", "Expression")
|
|
|
+ instantiate_link(scd, "Association", "statement_next", "Statement", "Statement")
|
|
|
+ instantiate_link(scd, "Association", "if_cond", "if", "Expression")
|
|
|
+ instantiate_link(scd, "Association", "if_true", "if", "Statement")
|
|
|
+ instantiate_link(scd, "Association", "if_false", "if", "Statement")
|
|
|
+ instantiate_link(scd, "Association", "while_cond", "while", "Expression")
|
|
|
+ instantiate_link(scd, "Association", "while_body", "while", "Statement")
|
|
|
+ instantiate_link(scd, "Association", "assign_var", "assign", "Any")
|
|
|
+ instantiate_link(scd, "Association", "assign_value", "assign", "Expression")
|
|
|
+ instantiate_link(scd, "Association", "break_while", "break", "while")
|
|
|
+ instantiate_link(scd, "Association", "continue_while", "continue", "while")
|
|
|
+ instantiate_link(scd, "Association", "return_value", "return", "Expression")
|
|
|
+ instantiate_link(scd, "Association", "resolve_var", "resolve", "Any")
|
|
|
+ instantiate_link(scd, "Association", "access_var", "access", "Any")
|
|
|
+ instantiate_link(scd, "Association", "constant_node", "constant", "Any")
|
|
|
+ instantiate_link(scd, "Association", "output_node", "output", "Expression")
|
|
|
+ instantiate_link(scd, "Association", "global_var", "global", "String")
|
|
|
+ instantiate_link(scd, "Association", "param_name", "param", "String")
|
|
|
+ instantiate_link(scd, "Association", "param_value", "param", "Expression")
|
|
|
+ instantiate_link(scd, "Association", "param_next_param", "param", "param")
|
|
|
+ instantiate_link(scd, "Association", "funcdef_body", "funcdef", "Statement")
|
|
|
+ instantiate_link(scd, "Association", "call_func", "call", "Expression")
|
|
|
+ instantiate_link(scd, "Association", "call_params", "call", "param")
|
|
|
+ instantiate_link(scd, "Association", "call_last_param", "call", "param")
|
|
|
+
|
|
|
+ // Now still allow for constraints on classes
|
|
|
+ instantiate_link(scd, "Association", "constraint", "Class", "funcdef")
|
|
|
+ instantiate_attribute(scd, "constraint", "name", "constraint")
|
|
|
+
|
|
|
+ // Finally done, so export!
|
|
|
export_node("models/SimpleClassDiagrams", scd)
|
|
|
|
|
|
+ // Now for some examples: a PetriNet
|
|
|
Element pn
|
|
|
pn = instantiate_model(scd)
|
|
|
define_inheritance(pn, "Inheritance")
|