• 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

修訂7676a5cd2196d35437142b2852f0f268e821bd66 (tree)
時間2021-12-10 00:00:05
作者Albert Mietus < albert AT mietus DOT nl >
CommiterAlbert Mietus < albert AT mietus DOT nl >

Log Message

AST: peg.Rule() has a 'expr', not a 'value'

Change Summary

差異

diff -r 21c5690c5c1c -r 7676a5cd2196 AST/Makefile
--- a/AST/Makefile Thu Dec 09 14:43:55 2021 +0100
+++ b/AST/Makefile Thu Dec 09 16:00:05 2021 +0100
@@ -2,6 +2,7 @@
22
33 all: test demos
44
5+test:
56 (cd pytst/; pytest)
67 test-s:
78 (cd pytst/; pytest -s)
@@ -9,7 +10,6 @@
910 DEMOS:=$(wildcard demo/*demo*.py)
1011 demos:
1112 for d in ${DEMOS}; do echo "*** $$d ***"; python $$d; done
12-test:
1313
1414 clean:
1515 rm -rf {.,castle}/{__pycache__,.pytest_cache}/
diff -r 21c5690c5c1c -r 7676a5cd2196 AST/castle/peg.py
--- a/AST/castle/peg.py Thu Dec 09 14:43:55 2021 +0100
+++ b/AST/castle/peg.py Thu Dec 09 16:00:05 2021 +0100
@@ -37,12 +37,12 @@
3737 class Rule(NonTerminal):
3838 def __init__(self, *,
3939 name: ID,
40- value :Expression,
40+ expr :Expression=None,
4141 **kwargs):
4242 ID.validate_or_raise(name)
4343 super().__init__(**kwargs)
4444 self.name = name
45- self.value = value
45+ self.expr = expr
4646
4747
4848
diff -r 21c5690c5c1c -r 7676a5cd2196 AST/pytst/test_1_Rules.py
--- a/AST/pytst/test_1_Rules.py Thu Dec 09 14:43:55 2021 +0100
+++ b/AST/pytst/test_1_Rules.py Thu Dec 09 16:00:05 2021 +0100
@@ -1,22 +1,18 @@
11 import pytest
22
3-## Notice `test_1_Rules.py` and `test_1_Settings.py` are the same, but for the SUT; in the line below -- Keep it that way!!
4-from castle.peg import Rule as SUT
3+from castle.peg import Rule
54
65 def test_a_ID():
76 a_name, a_val = 'aName', 42
8- s=SUT(name=a_name, value=a_val)
7+ s=Rule(name=a_name, expr=a_val)
98 assert s.name == a_name, "Remember the ID"
10- assert s.value == a_val, "Remember the value"
9+ assert s.expr == a_val, "Remember the expr"
1110
1211
1312 def test_needID():
1413 with pytest.raises(ValueError):
15- SUT(name=42, value="the name should be an ID, or string")
14+ Rule(name=42) # The name should be an ID, or string
1615 with pytest.raises(ValueError):
17- SUT(name='a b', value="a space in not allowed in an ID")
16+ Rule(name='a b') # "A space in not allowed in an ID
1817
19-def test_needID():
20- with pytest.raises(TypeError):
21- SUT(name='Forgot_a_Value')
2218
diff -r 21c5690c5c1c -r 7676a5cd2196 AST/pytst/test_1_Settings.py
--- a/AST/pytst/test_1_Settings.py Thu Dec 09 14:43:55 2021 +0100
+++ b/AST/pytst/test_1_Settings.py Thu Dec 09 16:00:05 2021 +0100
@@ -1,22 +1,22 @@
11 import pytest
22
3-## Notice `test_1_Rules.py` and `test_1_Settings.py` are the same, but for the SUT; in the line below -- Keep it that way!!
4-from castle.peg import Setting as SUT
3+
4+from castle.peg import Setting
55
66 def test_a_ID():
77 a_name, a_val = 'aName', 42
8- s=SUT(name=a_name, value=a_val)
8+ s=Setting(name=a_name, value=a_val)
99 assert s.name == a_name, "Remember the ID"
1010 assert s.value == a_val, "Remember the value"
1111
1212
1313 def test_needID():
1414 with pytest.raises(ValueError):
15- SUT(name=42, value="the name should be an ID, or string")
15+ Setting(name=42, value="the name should be an ID, or string")
1616 with pytest.raises(ValueError):
17- SUT(name='a b', value="a space in not allowed in an ID")
17+ Setting(name='a b', value="a space in not allowed in an ID")
1818
1919 def test_needID():
2020 with pytest.raises(TypeError):
21- SUT(name='Forgot_a_Value')
21+ Setting(name='Forgot_a_Value')
2222