소스 검색

Added tree matching files.

Sander Mathijs van Veen 14 년 전
부모
커밋
bf906321c7
2개의 변경된 파일31개의 추가작업 그리고 0개의 파일을 삭제
  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]))