Ver código fonte

Added tree matching files.

Sander Mathijs van Veen 14 anos atrás
pai
commit
bf906321c7
2 arquivos alterados com 31 adições e 0 exclusões
  1. 13 0
      src/match.py
  2. 18 0
      tests/test_match.py

+ 13 - 0
src/match.py

@@ -0,0 +1,13 @@
+from node import Node, Leaf
+from parser import Parser
+
+from external.graph_drawing.graph import generate_graph
+from external.graph_drawing.line import generate_line
+
+
+patterns = {
+        #'': L('')
+        }
+
+def matches(exp, pattern):
+    pass

+ 18 - 0
tests/test_match.py

@@ -0,0 +1,18 @@
+import unittest
+
+from src.node import ExpressionNode as N, ExpressionLeaf as L
+from src.match import patterns, matches
+from src.parser import Parser
+
+from tests.parser import ParserWrapper
+
+
+class TestMatch(unittest.TestCase):
+    def setUp(self):
+        self.parser = ParserWrapper(Parser)
+
+    def test_constant(self):
+        pass
+
+    def assert_matches(self, exp, pattern_name):
+        self.assertTrue(matches(self.parser.run([exp]), patterns[pattern_name]))