Browse Source

Added export construct and always add in the define inheritance call

Yentl Van Tendeloo 9 years ago
parent
commit
698548da6f

+ 3 - 0
interface/HUTN/grammars/modelling.g

@@ -2,6 +2,7 @@ grammar{
     start: (import | model | NEWLINE)+;
 
     import: IMPORT MV_URL AS MODEL_ID;
+    export: EXPORT MODEL_ID TO MV_URL;
 
     model: MODEL_ID MODEL_ID NEWLINE? LCURLY NEWLINE? (model_element)* RCURLY;
 
@@ -41,5 +42,7 @@ grammar{
         LPAR: '\(';
         RPAR: '\)';
         COMMA: ',';
+        EXPORT: 'export';
+        TO: 'to';
     }
 }

+ 6 - 0
interface/HUTN/hutn_compiler/model_visitor.py

@@ -34,11 +34,17 @@ class ModelVisitor(Visitor):
         target = tree.get_children("MODEL_ID")[0]
         self.constructors.extend(['"import_node"', jsonstr(url.get_text()), jsonstr(target.get_text())])
 
+    def visit_export(self, tree):
+        url = tree.get_children("MV_URL")[0]
+        target = tree.get_children("MODEL_ID")[0]
+        self.constructors.extend(['"export_node"', jsonstr(target.get_text()), jsonstr(url.get_text())])
+
     def visit_model(self, tree):
         children = tree.get_children("MODEL_ID")
         model_type = children[0].get_text()
         model_name = children[1].get_text()
         self.constructors.extend(['"instantiate_model"', jsonstr(model_type), jsonstr(model_name)])
+        self.constructors.extend(['"define_inheritance"', jsonstr(model_name), jsonstr("Inheritance")])
         self.current_model = model_name
         for element in tree.get_children("model_element"):
             self.visit(element)