• R/O
  • SSH

提交

標籤
無標籤

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Castle: The best Real-Time/Embedded/HighTech language EVER. Attempt 2


Commit MetaInfo

修訂4c63a33e26c27a7c97af4d8d65db179a09b3686f (tree)
時間2021-12-20 06:21:15
作者Albert Mietus < albert AT mietus DOT nl >
CommiterAlbert Mietus < albert AT mietus DOT nl >

Log Message

moved visitor-class from test to visitor.py (PegVisitor)

Change Summary

差異

diff -r d89d215a0dd2 -r 4c63a33e26c2 Arpeggio/pytst/d2_ast/test_1_term.py
--- a/Arpeggio/pytst/d2_ast/test_1_term.py Sun Dec 19 22:03:53 2021 +0100
+++ b/Arpeggio/pytst/d2_ast/test_1_term.py Sun Dec 19 22:21:15 2021 +0100
@@ -1,23 +1,18 @@
11 import pytest
22
33 import grammar
4+import visitor
45 import arpeggio
56
67 import sys; sys.path.append("./../AST/") ; sys.path.append("./../../AST/")
78 from castle import peg # has the AST clases
89
910
10-class DemoVisitor(arpeggio.PTNodeVisitor):
11- def visit_str_term(self, node, children):
12- ast = peg.StrTerm(value=node[1], parse_tree=node)
13- return ast
14-
15-
1611 def parse(txt, rule):
1712 parser = arpeggio.ParserPython(rule)
1813 pt = parser.parse(txt)
1914 assert pt.position_end == len(txt), "Did not parse all input"# JTBS
20- ast = arpeggio.visit_parse_tree(pt, DemoVisitor())
15+ ast = arpeggio.visit_parse_tree(pt, visitor.PegVisitor())
2116 return ast
2217
2318 def test_simple_str():
@@ -37,4 +32,3 @@
3732 assert ast.value == "triple string", "It's correct value should be without quotes"
3833 assert ast.position == 0, "The term's position includes the quotes ..."
3934 assert ast.position_end == len(txt), " ... on both ends."
40-
diff -r d89d215a0dd2 -r 4c63a33e26c2 Arpeggio/visitor.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Arpeggio/visitor.py Sun Dec 19 22:21:15 2021 +0100
@@ -0,0 +1,9 @@
1+import arpeggio
2+
3+import sys; sys.path.append("./../AST/") ; sys.path.append("./../../AST/")
4+from castle import peg # has the AST clases
5+
6+class PegVisitor(arpeggio.PTNodeVisitor):
7+ def visit_str_term(self, node, children):
8+ ast = peg.StrTerm(value=node[1], parse_tree=node)
9+ return ast