Browse Source

Removed the global keyword altogether

Yentl Van Tendeloo 9 years ago
parent
commit
a063055f90

+ 5 - 21
bootstrap/constructors.alc

@@ -119,8 +119,6 @@ Action function construct_unknown():
 		return construct_const()
 	elif (elem == "declare"):
 		return construct_declare()
-	elif (elem == "global"):
-		return construct_global()
 	elif (elem == "funcdef"):
 		return construct_funcdef()
 	elif (elem == "output"):
@@ -133,11 +131,6 @@ Action function construct_unknown():
 		return construct_break()
 	elif (elem == "continue"):
 		return construct_continue()
-	elif (elem == "tag"):
-		Element tmp_constructed
-		tmp_constructed = construct_unknown()
-		output(tmp_constructed)
-		return tmp_constructed
 	elif (elem == "instantiate_bottom"):
 		new_model = create_node()
 		dict_add(new_model, "model", create_node())
@@ -237,11 +230,13 @@ Action function construct_call():
 	return this_element
 
 Action function construct_return():
-	Action this_element
-	this_element = create_value(!return)
 	if (input()):
+		Action this_element
+		this_element = create_value(!return)
 		dict_add(this_element, "value", construct_unknown())
-	return this_element
+		return this_element
+	else:
+		return create_value(!return)
 
 Action function construct_const():
 	Action this_element
@@ -260,17 +255,6 @@ Action function construct_declare():
 		dict_add(this_element, "next", construct_unknown())
 	return this_element
 
-// TODO remove global keyword
-Action function construct_global():
-	Action this_element
-	String declared_element
-	this_element = create_value(!global)
-	declared_element = input()
-	dict_add(this_element, "var", declared_element)
-	if (input()):
-		dict_add(this_element, "next", construct_unknown())
-	return this_element
-
 Action function construct_input():
 	Action this_element
 	this_element = create_value(!input)

+ 88 - 88
integration/code/pn_interface.alc

@@ -51,29 +51,29 @@ Element function create_metamodels():
 		export_node("models/SimpleClassDiagrams", scd)
 
 		// TODO this code is also very dirty as there is no nice "dictionary" and "list" syntax yet
-		Element pn_metamodel
-		pn_metamodel = instantiate_new_model(scd, dict_read(scd_model, "Inheritance"))
+		Element modeletamodel
+		modeletamodel = instantiate_new_model(scd, dict_read(scd_model, "Inheritance"))
 		Element tokens
 		tokens = create_node()
 		dict_add(tokens, "tokens", Integer)
-		instantiate_model_lib(pn_metamodel, dict_read(scd_model, "Class"), "Place", create_node(), tokens, create_node())
-		instantiate_model_lib(pn_metamodel, dict_read(scd_model, "Class"), "Transition", create_node(), create_node(), create_node())
+		instantiate_model_lib(modeletamodel, dict_read(scd_model, "Class"), "Place", create_node(), tokens, create_node())
+		instantiate_model_lib(modeletamodel, dict_read(scd_model, "Class"), "Transition", create_node(), create_node(), create_node())
 		Element weight
 		weight = create_node()
 		dict_add(weight, "weight", Integer)
 		Element p2t_links
 		p2t_links = create_node()
-		list_append(p2t_links, dict_read(dict_read(pn_metamodel, "model"), "Place"))
-		list_append(p2t_links, dict_read(dict_read(pn_metamodel, "model"), "Transition"))
+		list_append(p2t_links, dict_read(dict_read(modeletamodel, "model"), "Place"))
+		list_append(p2t_links, dict_read(dict_read(modeletamodel, "model"), "Transition"))
 		Element t2p_links
 		t2p_links = create_node()
-		list_append(t2p_links, dict_read(dict_read(pn_metamodel, "model"), "Transition"))
-		list_append(t2p_links, dict_read(dict_read(pn_metamodel, "model"), "Place"))
-		instantiate_model_lib(pn_metamodel, dict_read(scd_model, "Association"), "P2T", p2t_links, weight, create_node())
-		instantiate_model_lib(pn_metamodel, dict_read(scd_model, "Association"), "T2P", t2p_links, weight, create_node())
+		list_append(t2p_links, dict_read(dict_read(modeletamodel, "model"), "Transition"))
+		list_append(t2p_links, dict_read(dict_read(modeletamodel, "model"), "Place"))
+		instantiate_model_lib(modeletamodel, dict_read(scd_model, "Association"), "P2T", p2t_links, weight, create_node())
+		instantiate_model_lib(modeletamodel, dict_read(scd_model, "Association"), "T2P", t2p_links, weight, create_node())
 
-		set_model_constraints(pn_metamodel, petrinet_constraints)
-		export_node("models/PetriNets", pn_metamodel)
+		set_model_constraints(modeletamodel, petrinet_constraints)
+		export_node("models/PetriNets", modeletamodel)
 
 		// Also create conformance bottom metamodel
 		Element mm_bottom
@@ -121,29 +121,29 @@ Element function create_metamodels():
 
 	return 0
 
-String function petrinet_constraints(pn_mo : Element):
+String function petrinet_constraints(model : Element):
 	// Check places to have positive number of tokens
 	Element all_elems
 	Element elem_constraint
-	all_elems = allInstances(pn_mo, dict_read(dict_read(dict_read(pn_mo, "metamodel"), "model"), "Place"))
+	all_elems = allInstances(model, dict_read(dict_read(dict_read(model, "metamodel"), "model"), "Place"))
 	while (0 < read_nr_out(all_elems)):
 		elem_constraint = set_pop(all_elems)
-		if (integer_lt(readAttribute(pn_mo, elem_constraint, "tokens"), 0)):
-			return "Negative number of tokens in Place " + getName(pn_mo, elem_constraint)
+		if (integer_lt(readAttribute(model, elem_constraint, "tokens"), 0)):
+			return "Negative number of tokens in Place " + getName(model, elem_constraint)
 
 	// Check P2T transitions to have positive weight
-	all_elems = allInstances(pn_mo, dict_read(dict_read(dict_read(pn_mo, "metamodel"), "model"), "P2T"))
+	all_elems = allInstances(model, dict_read(dict_read(dict_read(model, "metamodel"), "model"), "P2T"))
 	while (0 < read_nr_out(all_elems)):
 		elem_constraint = set_pop(all_elems)
-		if (integer_lt(readAttribute(pn_mo, elem_constraint, "weight"), 0)):
-			return "Negative weight in arc " + getName(pn_mo, elem_constraint)
+		if (integer_lt(readAttribute(model, elem_constraint, "weight"), 0)):
+			return "Negative weight in arc " + getName(model, elem_constraint)
 
 	// Check T2P transitions to have positive weight
-	all_elems = allInstances(pn_mo, dict_read(dict_read(dict_read(pn_mo, "metamodel"), "model"), "T2P"))
+	all_elems = allInstances(model, dict_read(dict_read(dict_read(model, "metamodel"), "model"), "T2P"))
 	while (0 < read_nr_out(all_elems)):
 		elem_constraint = set_pop(all_elems)
-		if (integer_lt(readAttribute(pn_mo, elem_constraint, "weight"), 0)):
-			return "Negative weight in arc " + getName(pn_mo, elem_constraint)
+		if (integer_lt(readAttribute(model, elem_constraint, "weight"), 0)):
+			return "Negative weight in arc " + getName(model, elem_constraint)
 
 	return "OK"
 
@@ -154,17 +154,17 @@ Element function pn_operations():
 	dict_add(ops, "enabled", petrinet_enabled)
 	return ops
 
-Element function petrinet_enabled(pn_m : Element):
+Element function petrinet_enabled(model : Element):
 	Element set_enabled
-	set_enabled = petrinet_enabled_set(pn_m)
+	set_enabled = petrinet_enabled_set(model)
 	output("Enabled transitions:")
 	while (0 < read_nr_out(set_enabled)):
-		output(getName(pn_m, set_pop(set_enabled)))
-	return pn_m
+		output(getName(model, set_pop(set_enabled)))
+	return model
 
-Element function petrinet_enabled_set(pn_mod : Element):
+Element function petrinet_enabled_set(model : Element):
 	Element all_transitions
-	all_transitions = allInstances(pn_mod, dict_read(dict_read(dict_read(pn_mod, "metamodel"), "model"), "Transition"))
+	all_transitions = allInstances(model, dict_read(dict_read(dict_read(model, "metamodel"), "model"), "Transition"))
 
 	Element enabled_transitions
 	enabled_transitions = create_node()
@@ -178,15 +178,15 @@ Element function petrinet_enabled_set(pn_mod : Element):
 		enabled = True
 
 		// Find all incoming transitions
-		in_arcs = allIncomingAssociationInstances(pn_mod, under_study, dict_read(dict_read(dict_read(pn_mod, "metamodel"), "model"), "P2T"))
+		in_arcs = allIncomingAssociationInstances(model, under_study, dict_read(dict_read(dict_read(model, "metamodel"), "model"), "P2T"))
 
 		while (0 < read_nr_out(in_arcs)):
 			arc_under_study = set_pop(in_arcs)
 
 			Integer present_tokens
 			Integer required_tokens
-			required_tokens = readAttribute(pn_mod, arc_under_study, "weight")
-			present_tokens = readAttribute(pn_mod, read_edge_src(arc_under_study), "tokens")
+			required_tokens = readAttribute(model, arc_under_study, "weight")
+			present_tokens = readAttribute(model, read_edge_src(arc_under_study), "tokens")
 			if (present_tokens < required_tokens):
 				// Less tokens than required, so disable the transition completely
 				enabled = False
@@ -196,40 +196,40 @@ Element function petrinet_enabled_set(pn_mod : Element):
 
 	return enabled_transitions
 
-Element function petrinet_fire(pn_mode : Element):
+Element function petrinet_fire(model : Element):
 	output("Transition to fire?")
 	Element transition
 	transition = input()
-	if (dict_in(dict_read(pn_mode, "model"), transition)):
-		transition = dict_read(dict_read(pn_mode, "model"), transition)
-		if (set_in(petrinet_enabled_set(pn_mode), transition)):
+	if (dict_in(dict_read(model, "model"), transition)):
+		transition = dict_read(dict_read(model, "model"), transition)
+		if (set_in(petrinet_enabled_set(model), transition)):
 			Element workset
 			Element working_place
 			Element working_arc
 
 			// Consume tokens
-			workset = allIncomingAssociationInstances(pn_mode, transition, dict_read(dict_read(dict_read(pn_mode, "metamodel"), "model"), "P2T"))
+			workset = allIncomingAssociationInstances(model, transition, dict_read(dict_read(dict_read(model, "metamodel"), "model"), "P2T"))
 			while (0 < read_nr_out(workset)):
 				working_arc = set_pop(workset)
 				working_place = read_edge_src(working_arc)
-				setAttribute(pn_mode, working_place, "tokens", integer_subtraction(readAttribute(pn_mode, working_place, "tokens"), readAttribute(pn_mode, working_arc, "weight")))
-				output((("  " + getName(pn_mode, working_place)) + ": ") + cast_i2s(readAttribute(pn_mode, working_place, "tokens")))
+				setAttribute(model, working_place, "tokens", integer_subtraction(readAttribute(model, working_place, "tokens"), readAttribute(model, working_arc, "weight")))
+				output((("  " + getName(model, working_place)) + ": ") + cast_i2s(readAttribute(model, working_place, "tokens")))
 
 			// Add tokens
-			workset = allOutgoingAssociationInstances(pn_mode, transition, dict_read(dict_read(dict_read(pn_mode, "metamodel"), "model"), "T2P"))
+			workset = allOutgoingAssociationInstances(model, transition, dict_read(dict_read(dict_read(model, "metamodel"), "model"), "T2P"))
 			while (0 < read_nr_out(workset)):
 				working_arc = set_pop(workset)
 				working_place = read_edge_dst(working_arc)
-				setAttribute(pn_mode, working_place, "tokens", integer_addition(readAttribute(pn_mode, working_place, "tokens"), readAttribute(pn_mode, working_arc, "weight")))
-				output((("  " + getName(pn_mode, working_place)) + ": ") + cast_i2s(readAttribute(pn_mode, working_place, "tokens")))
+				setAttribute(model, working_place, "tokens", integer_addition(readAttribute(model, working_place, "tokens"), readAttribute(model, working_arc, "weight")))
+				output((("  " + getName(model, working_place)) + ": ") + cast_i2s(readAttribute(model, working_place, "tokens")))
 			output("Transition fired!")
 		else:
 			output("Cannot fire if not enabled; aborting")
 	else:
 		output("Unknown transition; aborting")
-	return pn_mode
+	return model
 	
-Element function petrinet_loaded(pn_model : Element):
+Element function petrinet_loaded(model : Element):
 	String cmd
 
 	Element attr_list_pn
@@ -242,7 +242,7 @@ Element function petrinet_loaded(pn_model : Element):
 
 	bottom = False
 	other_metamodel = create_node()
-	dict_add(other_metamodel, "model", dict_read(pn_model, "model"))
+	dict_add(other_metamodel, "model", dict_read(model, "model"))
 	dict_add(other_metamodel, "type_mapping", create_node())
 	dict_add(other_metamodel, "metamodel", import_node("models/LTM_bottom"))
 	dict_add(other_metamodel, "inheritance", dict_read(dict_read(dict_read(other_metamodel, "metamodel"), "model"), "__Inheritance"))
@@ -275,17 +275,17 @@ Element function petrinet_loaded(pn_model : Element):
 					specific_op = set_pop(specific_ops)
 					output("  " + specific_op)
 		elif (cmd == "exit"):
-			return pn_model
+			return model
 		elif (cmd == "instantiate"):
 			String mm_type_name
 			output("Type to instantiate?")
 			mm_type_name = input()
-			if (dict_in(dict_read(dict_read(pn_model, "metamodel"), "model"), mm_type_name)):
-				metamodel_element_pn = dict_read(dict_read(dict_read(pn_model, "metamodel"), "model"), mm_type_name)
+			if (dict_in(dict_read(dict_read(model, "metamodel"), "model"), mm_type_name)):
+				metamodel_element_pn = dict_read(dict_read(dict_read(model, "metamodel"), "model"), mm_type_name)
 				String element_name
 				output("Name of new element?")
 				element_name = input()
-				if (dict_in(dict_read(pn_model, "model"), element_name)):
+				if (dict_in(dict_read(model, "model"), element_name)):
 					output("Element already exists; aborting")
 				else:
 					Boolean cnt
@@ -296,13 +296,13 @@ Element function petrinet_loaded(pn_model : Element):
 						output("Source name?")
 						String src_name
 						src_name = input()
-						if (dict_in(dict_read(pn_model, "model"), src_name)):
-							list_append(additional_opts, dict_read(dict_read(pn_model, "model"), src_name))
+						if (dict_in(dict_read(model, "model"), src_name)):
+							list_append(additional_opts, dict_read(dict_read(model, "model"), src_name))
 							output("Destination name?")
 							String dst_name
 							dst_name = input()
-							if (dict_in(dict_read(pn_model, "model"), dst_name)):
-								list_append(additional_opts, dict_read(dict_read(pn_model, "model"), dst_name))
+							if (dict_in(dict_read(model, "model"), dst_name)):
+								list_append(additional_opts, dict_read(dict_read(model, "model"), dst_name))
 							else:
 								output("Unknown destination; aborting")
 								cnt = False
@@ -314,7 +314,7 @@ Element function petrinet_loaded(pn_model : Element):
 						output("Value?")
 						list_append(additional_opts, input())
 					if (cnt):
-						attr_list_pn = getAttributeList(pn_model, metamodel_element_pn)
+						attr_list_pn = getAttributeList(model, metamodel_element_pn)
 						attr_keys_pn = dict_keys(attr_list_pn)
 						Element attrs
 						attrs = create_node()
@@ -323,27 +323,27 @@ Element function petrinet_loaded(pn_model : Element):
 							output(((attr_key_pn + " : ") + cast_t2s(dict_read(attr_list_pn, attr_key_pn))) + "?")
 							dict_add(attrs, attr_key_pn, input())
 						Element resulting_element
-						resulting_element = instantiate_model_lib(pn_model, metamodel_element_pn, element_name, additional_opts, create_node(), attrs)
+						resulting_element = instantiate_model_lib(model, metamodel_element_pn, element_name, additional_opts, create_node(), attrs)
 						output("Instantiation successful!")
 			else:
 				output("Unknown type specified; aborting")
 		elif (cmd == "delete"):
 			output("What is the name of the element you want to delete?")
 			cmd = input()
-			if (dict_in(dict_read(pn_model, "model"), cmd)):
-				delete_element(dict_read(dict_read(pn_model, "model"), cmd))
+			if (dict_in(dict_read(model, "model"), cmd)):
+				delete_element(dict_read(dict_read(model, "model"), cmd))
 				output("Deleted!")
 			else:
 				output("No such element; aborting")
 		elif (cmd == "modify"):
 			output("Element to modify?")
 			cmd = input()
-			if (dict_in(dict_read(pn_model, "model"), cmd)):
+			if (dict_in(dict_read(model, "model"), cmd)):
 				Element mod
-				mod = dict_read(dict_read(pn_model, "model"), cmd)
-				metamodel_element_pn = dict_read_node(dict_read(pn_model, "type_mapping"), mod)
+				mod = dict_read(dict_read(model, "model"), cmd)
+				metamodel_element_pn = dict_read_node(dict_read(model, "type_mapping"), mod)
 
-				attr_list_pn = getAttributeList(pn_model, metamodel_element_pn)
+				attr_list_pn = getAttributeList(model, metamodel_element_pn)
 				attr_keys_pn = dict_keys(attr_list_pn)
 				while (0 < read_nr_out(attr_keys_pn)):
 					attr_key_pn = set_pop(attr_keys_pn)
@@ -352,9 +352,9 @@ Element function petrinet_loaded(pn_model : Element):
 				output("Attribute to modify?")
 				String attr_name
 				attr_name = input()
-				if (set_in(dict_keys(getAttributeList(pn_model, metamodel_element_pn)), attr_name)):
+				if (set_in(dict_keys(getAttributeList(model, metamodel_element_pn)), attr_name)):
 					output("New value?")
-					setAttribute(pn_model, mod, attr_name, input())
+					setAttribute(model, mod, attr_name, input())
 					output("Modified!")
 				else:
 					output("Unknown attribute; aborting")
@@ -364,82 +364,82 @@ Element function petrinet_loaded(pn_model : Element):
 			output("Old name?")
 			String old_name_e
 			old_name_e = input()
-			if (dict_in(dict_read(pn_model, "model"), old_name_e)):
+			if (dict_in(dict_read(model, "model"), old_name_e)):
 				output("New name?")
 				String new_name_e
 				new_name_e = input()
-				if (dict_in(dict_read(pn_model, "model"), new_name_e)):
+				if (dict_in(dict_read(model, "model"), new_name_e)):
 					output("New name already used; aborting")
 				else:
-					dict_add(dict_read(pn_model, "model"), new_name_e, dict_read(dict_read(pn_model, "model"), old_name_e))
-					dict_delete(dict_read(pn_model, "model"), old_name_e)
+					dict_add(dict_read(model, "model"), new_name_e, dict_read(dict_read(model, "model"), old_name_e))
+					dict_delete(dict_read(model, "model"), old_name_e)
 					output("Rename complete!")
 			else:
 				output("Unknown element; aborting")
 		elif (cmd == "list"):
 			Element keys_m
-			keys_m = dict_keys(dict_read(pn_model, "model"))
+			keys_m = dict_keys(dict_read(model, "model"))
 			output("List of all elements:")
 			String v_m
 			while (read_nr_out(keys_m) > 0):
 				v_m = set_pop(keys_m)
 				// Filter out anonymous objects
-				typename = getName(dict_read(pn_model, "metamodel"), dict_read_node(dict_read(pn_model, "type_mapping"), dict_read(dict_read(pn_model, "model"), v_m)))
+				typename = getName(dict_read(model, "metamodel"), dict_read_node(dict_read(model, "type_mapping"), dict_read(dict_read(model, "model"), v_m)))
 				if (bool_not(string_startswith(v_m, "__"))):
 					output((("  " + v_m) + " : ") + typename)
 		elif (cmd == "read"):
 			output("Element to read?")
 			cmd = input()
-			if (dict_in(dict_read(pn_model, "model"), cmd)):
+			if (dict_in(dict_read(model, "model"), cmd)):
 				Element read_elem
-				read_elem = dict_read(dict_read(pn_model, "model"), cmd)
-				metamodel_element_pn = dict_read_node(dict_read(pn_model, "type_mapping"), read_elem)
+				read_elem = dict_read(dict_read(model, "model"), cmd)
+				metamodel_element_pn = dict_read_node(dict_read(model, "type_mapping"), read_elem)
 
 				output("Name: " + cmd)
-				output("Type: " + getName(dict_read(pn_model, "metamodel"), metamodel_element_pn))
+				output("Type: " + getName(dict_read(model, "metamodel"), metamodel_element_pn))
 				if (is_edge(read_elem)):
-					output("Source: " + getName(pn_model, read_edge_src(read_elem)))
-					output("Destination: " + getName(pn_model, read_edge_dst(read_elem)))
+					output("Source: " + getName(model, read_edge_src(read_elem)))
+					output("Destination: " + getName(model, read_edge_dst(read_elem)))
 				if (cast_v2s(read_elem) != "None"):
 					output("Value: " + cast_v2s(read_elem))
 				output("Defines attributes:")
-				attr_list_pn = getInstantiatableAttributes(pn_model, read_elem)
+				attr_list_pn = getInstantiatableAttributes(model, read_elem)
 				attr_keys_pn = dict_keys(attr_list_pn)
 				while (0 < read_nr_out(attr_keys_pn)):
 					attr_key_pn = set_pop(attr_keys_pn)
 					output(((("   " + attr_key_pn) + " : ") + cast_t2s(dict_read(attr_list_pn, attr_key_pn))))
 				output("Attributes:")
-				attr_list_pn = getAttributeList(pn_model, metamodel_element_pn)
+				attr_list_pn = getAttributeList(model, metamodel_element_pn)
 				attr_keys_pn = dict_keys(attr_list_pn)
 				while (0 < read_nr_out(attr_keys_pn)):
 					attr_key_pn = set_pop(attr_keys_pn)
-					output((((("   " + attr_key_pn) + " : ") + cast_t2s(dict_read(attr_list_pn, attr_key_pn))) + " = ") + cast_v2s(readAttribute(pn_model, read_elem, attr_key_pn)))
+					output((((("   " + attr_key_pn) + " : ") + cast_t2s(dict_read(attr_list_pn, attr_key_pn))) + " = ") + cast_v2s(readAttribute(model, read_elem, attr_key_pn)))
 			else:
 				output("Unknown element; aborting")
 		elif (cmd == "verify"):
-			output(conformance_scd(pn_model))
+			output(conformance_scd(model))
 		elif (cmd == "types"):
 			Element keys_t
-			keys_t = dict_keys(dict_read(dict_read(pn_model, "metamodel"), "model"))
+			keys_t = dict_keys(dict_read(dict_read(model, "metamodel"), "model"))
 			output("List of types:")
 			String v_t
 			while (read_nr_out(keys_t) > 0):
 				v_t = set_pop(keys_t)
 				if (bool_not(string_startswith(v_t, "__"))):
-					output(string_join(("  " + v_t) + " : ", getName(dict_read(dict_read(pn_model, "metamodel"), "metamodel"), dict_read_node(dict_read(dict_read(pn_model, "metamodel"), "type_mapping"), dict_read(dict_read(dict_read(pn_model, "metamodel"), "model"), v_t)))))
+					output(string_join(("  " + v_t) + " : ", getName(dict_read(dict_read(model, "metamodel"), "metamodel"), dict_read_node(dict_read(dict_read(model, "metamodel"), "type_mapping"), dict_read(dict_read(dict_read(model, "metamodel"), "model"), v_t)))))
 		elif (cmd == "retype"):
 			output("Element to retype?")
 			String elementname
 			elementname = input()
-			if (dict_in(dict_read(pn_model, "model"), elementname)):
+			if (dict_in(dict_read(model, "model"), elementname)):
 				output("New type")
 				typename = input()
-				if (dict_in(dict_read(dict_read(pn_model, "metamodel"), "model"), typename)):
+				if (dict_in(dict_read(dict_read(model, "metamodel"), "model"), typename)):
 					// OK, do the retyping
 					// First try removing the previous type if it exists
-					dict_delete(dict_read(pn_model, "type_mapping"), dict_read(dict_read(pn_model, "model"), elementname))
+					dict_delete(dict_read(model, "type_mapping"), dict_read(dict_read(model, "model"), elementname))
 					// Now add the new type
-					dict_add(dict_read(pn_model, "type_mapping"), dict_read(dict_read(pn_model, "model"), elementname), dict_read(dict_read(dict_read(pn_model, "metamodel"), "model"), typename))
+					dict_add(dict_read(model, "type_mapping"), dict_read(dict_read(model, "model"), elementname), dict_read(dict_read(dict_read(model, "metamodel"), "model"), typename))
 					output("Retyped!")
 				else:
 					output("Unknown type; aborting")
@@ -449,15 +449,15 @@ Element function petrinet_loaded(pn_model : Element):
 			bottom = bool_not(bottom)
 
 			Element tmp_model
-			tmp_model = pn_model
-			pn_model = other_metamodel
+			tmp_model = model
+			model = other_metamodel
 			other_metamodel = tmp_model
 
 			if (bottom):
 				// The type mapping we are using is probably not complete for our model
 				// so we completely recreate it from the model we have.
 				output("Switching to conformance bottom mode!")
-				generate_bottom_type_mapping(pn_model)
+				generate_bottom_type_mapping(model)
 			else:
 				// We already switched the models and such, so we are already done!
 				output("Switching to linguistic metamodel!")
@@ -465,7 +465,7 @@ Element function petrinet_loaded(pn_model : Element):
 			// A model-specific operation, so execute that one
 			Element specific_op
 			specific_op = dict_read(pn_operations(), cmd)
-			specific_op(pn_model)
+			specific_op(model)
 		else:
 			output("Unknown command; aborting")
 			output("Use command 'help' to get a list of available commands")

+ 4 - 77
integration/test_constructors_al.py

@@ -185,28 +185,11 @@ class TestConstructorsActionLanguage(unittest.TestCase):
                 ]
         self.assertTrue(run_barebone(flatten(commands) + ['123456'], ["123456"], 1))
 
-    def test_constructors_global_and_assign(self):
-        commands = ['"global"',
-                        '"my_global"',
-                        'true',
-                    '"assign"',
-                        '"resolve"', '"my_global"',
-                        '"const"', '5',
-                        'true',
-                    '"output"',
-                        '"access"', '"resolve"', '"my_global"',
-                        'true',
-                    '"return"',
-                        'true',
-                        '"const"', "true",
-                ]
-        self.assertTrue(run_barebone(flatten(commands), ["5"], 1))
-
     def test_constructors_funcdecl(self):
-        commands = ['"global"',
-                        '"my_global"',
+        commands = ['"declare"',
+                        1,
                         'true',
-                    '"funcdef"', '"my_global"',
+                    '"funcdef"', 1,
                         '2',
                         2,
                         3,
@@ -220,7 +203,7 @@ class TestConstructorsActionLanguage(unittest.TestCase):
                         'true',
                     '"output"',
                         '"call"',
-                            '"access"', '"resolve"', '"my_global"',
+                            '"access"', '"resolve"', 1,
                             '2',
                             '"input"',
                             '"input"',
@@ -231,62 +214,6 @@ class TestConstructorsActionLanguage(unittest.TestCase):
                 ]
         self.assertTrue(run_barebone(flatten(commands) + ['2', '5'], ["7"], 1))
 
-    def test_constructors_fibonacci(self):
-        commands = ['"global"',
-                        '"fibonacci"',
-                        'true',
-                    '"funcdef"', '"fibonacci"',
-                        '1',
-                        2,
-                        '"if"',
-                            '"call"',
-                                '"deref"', '"primitives/integer_lte"',
-                                '2',
-                                '"access"', '"resolve"', 2,
-                                '"const"', '2',
-                                'false',
-                            '"return"', 'true', '"const"', '1',
-                            'true',
-                            '"return"', 'true',
-                                '"call"',
-                                    '"deref"', '"primitives/integer_addition"',
-                                    '2',
-                                    '"call"',
-                                        '"access"', '"resolve"', '"fibonacci"',
-                                        '1',
-                                        '"call"',
-                                            '"deref"', '"primitives/integer_subtraction"',
-                                            '2',
-                                            '"access"', '"resolve"', 2,
-                                            '"const"', '1',
-                                            'false',
-                                        'false',
-                                    '"call"',
-                                        '"access"', '"resolve"', '"fibonacci"',
-                                        '1',
-                                        '"call"',
-                                            '"deref"', '"primitives/integer_subtraction"',
-                                            '2',
-                                            '"access"', '"resolve"', 2,
-                                            '"const"', '2',
-                                            'false',
-                                        'false',
-                                    'false',
-                            'false',
-                        'true',
-                    '"while"',
-                        '"const"', 'true',
-                        '"output"',
-                            '"call"',
-                                '"access"', '"resolve"', '"fibonacci"',
-                                '1',
-                                '"input"',
-                                'false',
-                            'false',
-                        'false',
-                    ]
-        self.assertTrue(run_barebone(flatten(commands) + ['1', '2', '3', '4', '5', '6', '7', '8'], ['1', '1', '2', '3', '5', '8', '13', '21'], 1))
-
     def test_constructors_continue(self):
         commands = ['"while"',
                         '"const"', 'true',

+ 4 - 82
integration/test_constructors_al_linkable.py

@@ -199,34 +199,12 @@ class TestConstructorsActionLanguageLinkable(unittest.TestCase):
                 ]
         commands = extend_commands(commands)
         self.assertTrue(run_barebone(commands + ['123456'], ["123456"], None, link=["test.o"]))
-    """
-
-    def test_constructors_global_and_assign(self):
-        commands = [
-                    '"global"',
-                        '"my_global"',
-                        'true',
-                    '"assign"',
-                        '"resolve"', '"my_global"',
-                        '"const"', '5',
-                        'true',
-                    '"output"',
-                        '"access"', '"resolve"', '"my_global"',
-                        'true',
-                    '"return"',
-                        'true',
-                        '"const"', "true",
-                    'false',
-                ]
-        commands = extend_commands(commands)
-        self.assertTrue(run_barebone(commands, ["5"], None, link=["test.o"]))
 
-    """
     def test_constructors_funcdecl(self):
-        commands = ['"global"',
-                        '"my_global"',
+        commands = ['"declare"',
+                        1,
                         'true',
-                    '"funcdef"', '"my_global"',
+                    '"funcdef"', 1,
                         '2',
                         2,
                         3,
@@ -240,7 +218,7 @@ class TestConstructorsActionLanguageLinkable(unittest.TestCase):
                         'true',
                     '"output"',
                         '"call"',
-                            '"access"', '"resolve"', '"my_global"',
+                            '"access"', '"resolve"', 1,
                             '2',
                             '"input"',
                             '"input"',
@@ -251,62 +229,6 @@ class TestConstructorsActionLanguageLinkable(unittest.TestCase):
                 ]
         self.assertTrue(run_barebone(flatten(commands) + ['2', '5'], ["7"], 1))
 
-    def test_constructors_fibonacci(self):
-        commands = ['"global"',
-                        '"fibonacci"',
-                        'true',
-                    '"funcdef"', '"fibonacci"',
-                        '1',
-                        2,
-                        '"if"',
-                            '"call"',
-                                '"deref"', '"primitives/integer_lte"',
-                                '2',
-                                '"access"', '"resolve"', 2,
-                                '"const"', '2',
-                                'false',
-                            '"return"', 'true', '"const"', '1',
-                            'true',
-                            '"return"', 'true',
-                                '"call"',
-                                    '"deref"', '"primitives/integer_addition"',
-                                    '2',
-                                    '"call"',
-                                        '"access"', '"resolve"', '"fibonacci"',
-                                        '1',
-                                        '"call"',
-                                            '"deref"', '"primitives/integer_subtraction"',
-                                            '2',
-                                            '"access"', '"resolve"', 2,
-                                            '"const"', '1',
-                                            'false',
-                                        'false',
-                                    '"call"',
-                                        '"access"', '"resolve"', '"fibonacci"',
-                                        '1',
-                                        '"call"',
-                                            '"deref"', '"primitives/integer_subtraction"',
-                                            '2',
-                                            '"access"', '"resolve"', 2,
-                                            '"const"', '2',
-                                            'false',
-                                        'false',
-                                    'false',
-                            'false',
-                        'true',
-                    '"while"',
-                        '"const"', 'true',
-                        '"output"',
-                            '"call"',
-                                '"access"', '"resolve"', '"fibonacci"',
-                                '1',
-                                '"input"',
-                                'false',
-                            'false',
-                        'false',
-                    ]
-        self.assertTrue(run_barebone(flatten(commands) + ['1', '2', '3', '4', '5', '6', '7', '8'], ['1', '1', '2', '3', '5', '8', '13', '21'], 1))
-
     def test_constructors_continue(self):
         commands = ['"while"',
                         '"const"', 'true',

+ 2 - 12
integration/test_pn_interface.py

@@ -161,18 +161,8 @@ class TestPetrinetInterface(unittest.TestCase):
         self.pn_interface_new("CO")
 
     def pn_interface_new(self, mode):
-        self.assertTrue(run_file(all_files, ["new", "PetriNets", "abc"],
-            init + new_full, mode))
-
-    def test_po_pn_interface_help(self):
-        self.pn_interface_help("PO")
-
-    def test_co_pn_interface_help(self):
-        self.pn_interface_help("CO")
-
-    def pn_interface_help(self, mode):
-        self.assertTrue(run_file(all_files, ["help"],
-            init + help_full, mode))
+        self.assertTrue(run_file(all_files, ["help", "new", "PetriNets", "abc"],
+            init + help_full + new_full, mode))
 
     def test_po_pn_interface_list_empty(self):
         self.pn_interface_list_empty("PO")

+ 1 - 2
interface/HUTN/grammars/actionlanguage.g

@@ -7,7 +7,7 @@ grammar{
 
     statement: ((vardecl | assignment | return | func_call) newline) | (ifelse | while) | (newline) @Rm;
 
-    vardecl: (GLOBAL)? type_specifier ID;
+    vardecl: type_specifier ID;
 
     assignment
         :   lvalue ASSIGN expression;
@@ -145,7 +145,6 @@ grammar{
 
         FUNCTION: 'function';
         RETURN: 'return';
-        GLOBAL: 'global';
 
         WHILE: 'while';
         IF: 'if';

+ 1 - 1
interface/HUTN/test/grammar_action_language/code/global.al

@@ -1,5 +1,5 @@
 Integer a = 1
+String b
 
 Integer function abc():
-	global String b
 	String c

+ 2 - 2
interface/HUTN/test/graph_compilation_action_language/code/global.al

@@ -1,5 +1,5 @@
-Integer a
+Integer a = 1
+String b
 
 Integer function abc():
-	global String b
 	String c

+ 30 - 19
interface/HUTN/test/graph_compilation_action_language/expected/global

@@ -1,24 +1,35 @@
 V auto_initial_IP(global)
 V auto_1(assign)
-V auto_10(resolve)
-V auto_11("abc")
+V auto_10("a")
+V auto_11(constant)
+N auto_12
+V auto_13(declare)
+N auto_14
+V auto_15(resolve)
+V auto_16("abc")
 V auto_2(global)
-V auto_3("a")
-V auto_4(constant)
-N auto_5
-V auto_6(global)
-V auto_7(declare)
-N auto_8
-V auto_9("b")
+V auto_3(assign)
+V auto_4(global)
+V auto_5("b")
+V auto_6(constant)
+V auto_7(constant)
+V auto_8(1)
+V auto_9(resolve)
 D auto_initial_IP,"next",auto_1
-D auto_initial_IP,"var",auto_11
+D auto_initial_IP,"var",auto_16
 D auto_1,"next",auto_2
-D auto_1,"value",auto_4
-D auto_1,"var",auto_10
-D auto_10,"var",auto_11
-D auto_2,"var",auto_3
-D auto_4,"node",auto_5
-D auto_5,"body",auto_6
-D auto_6,"next",auto_7
-D auto_6,"var",auto_9
-D auto_7,"var",auto_8
+D auto_1,"value",auto_11
+D auto_1,"var",auto_15
+D auto_11,"node",auto_12
+D auto_12,"body",auto_13
+D auto_13,"var",auto_14
+D auto_15,"var",auto_16
+D auto_2,"next",auto_3
+D auto_2,"var",auto_10
+D auto_3,"next",auto_4
+D auto_3,"value",auto_6
+D auto_3,"var",auto_9
+D auto_4,"var",auto_5
+D auto_6,"node",auto_7
+D auto_7,"node",auto_8
+D auto_9,"var",auto_10