Browse Source

Merge branch 'testing' of msdl.uantwerpen.be:yentl/modelverse into testing

Yentl Van Tendeloo 6 years ago
parent
commit
1143803120

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

@@ -19,6 +19,7 @@ grammar{
         | FLOAT_NUMBER
         | TRUE
         | FALSE
+        | LONG_STR
         | STRVALUE;
 
     tokens{
@@ -48,5 +49,6 @@ grammar{
         ANYTHING_EXCEPT_DOLLAR: '[^$]*';
         INCLUDE: 'include';
         EXCLAMATION: '!';
+        LONG_STR: '"""[^\"]*"""';
     }
 }

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

@@ -136,6 +136,9 @@ class ModelVisitor(Visitor):
             attr_value = tree.get_children("value")[0].get_tail()[0]
             if attr_value.head == "STRVALUE":
                 attr_value = attr_value.get_text()[1:-1]
+            elif attr_value.head == "LONG_STR":
+                attr_value = attr_value.get_text()[3:-3]
+                print("Got value: " + str(attr_value))
             elif attr_value.head == "TRUE":
                 attr_value = True
             elif attr_value.head == "FALSE":

+ 6 - 0
interface/HUTN/test/modelling_language/code/multiline.mvc

@@ -0,0 +1,6 @@
+Codeblock {
+	code = """
+        def test_code(a, b):
+            return a + b
+    """
+}

+ 1 - 0
interface/HUTN/test/modelling_language/expected/multiline

@@ -0,0 +1 @@
+[7, "instantiate_node", "Codeblock", "__0", "instantiate_attribute", "__0", "code", "\n        def test_code(a, b):\n            return a + b\n    "]

+ 5 - 2
interface/HUTN/test/modelling_language/test_compile.py

@@ -8,12 +8,12 @@ def compile_file(obj, filename):
     result = main(util.get_code_path(filename), "grammars/modelling.g", "M", [])
     try:
         expected = json.loads(open(util.get_expected_path(filename)).read())
+        assert result == expected
     except:
         #f = open(util.get_expected_path(filename), 'w')
         #f.write(json.dumps(result))
         #f.close()
-        pass
-    assert result == expected
+        assert False
 
 class TestCompile(unittest.TestCase):
     def test_PetriNets(self):
@@ -27,3 +27,6 @@ class TestCompile(unittest.TestCase):
 
     def test_PetriNets_constraints(self):
         compile_file(self, "petrinets_constraints.mvc")
+
+    def test_multiline(self):
+        compile_file(self, "multiline.mvc")