|
@@ -54,11 +54,15 @@ class ModelVisitor(Visitor):
|
|
def visit_model_element(self, tree):
|
|
def visit_model_element(self, tree):
|
|
children = tree.get_children("MODEL_ID")
|
|
children = tree.get_children("MODEL_ID")
|
|
element_type = children[0].get_text()
|
|
element_type = children[0].get_text()
|
|
- element_name = children[1].get_text()
|
|
|
|
|
|
+ if len(children) == 2 or len(children) == 4:
|
|
|
|
+ element_name = children[1].get_text()
|
|
|
|
+ else:
|
|
|
|
+ element_name = ""
|
|
|
|
|
|
- if len(children) == 4:
|
|
|
|
- source_name = children[2].get_text()
|
|
|
|
- target_name = children[3].get_text()
|
|
|
|
|
|
+ if len(children) > 2:
|
|
|
|
+ # So we have a source and target; but aren't sure which is which, because the name is optional!
|
|
|
|
+ source_name = children[-2].get_text()
|
|
|
|
+ target_name = children[-1].get_text()
|
|
self.constructors.extend(['"instantiate_link"', jsonstr(self.current_model), jsonstr(element_type), jsonstr(element_name), jsonstr(source_name), jsonstr(target_name)])
|
|
self.constructors.extend(['"instantiate_link"', jsonstr(self.current_model), jsonstr(element_type), jsonstr(element_name), jsonstr(source_name), jsonstr(target_name)])
|
|
else:
|
|
else:
|
|
self.constructors.extend(['"instantiate_node"', jsonstr(self.current_model), jsonstr(element_type), jsonstr(element_name)])
|
|
self.constructors.extend(['"instantiate_node"', jsonstr(self.current_model), jsonstr(element_type), jsonstr(element_name)])
|
|
@@ -80,5 +84,5 @@ class ModelVisitor(Visitor):
|
|
else:
|
|
else:
|
|
# is assign
|
|
# is assign
|
|
attr_name = children[0].get_text()
|
|
attr_name = children[0].get_text()
|
|
- attr_value = children[1]
|
|
|
|
|
|
+ attr_value = tree.get_children("value")[0]
|
|
self.constructors.extend(['"instantiate_attribute"', jsonstr(self.current_element), jsonstr(attr_name), jsonstr(attr_value.get_text()) if attr_value.head == "STRVALUE" else attr_value.get_text()])
|
|
self.constructors.extend(['"instantiate_attribute"', jsonstr(self.current_element), jsonstr(attr_name), jsonstr(attr_value.get_text()) if attr_value.head == "STRVALUE" else attr_value.get_text()])
|