• R/O
  • SSH

Commit

Tags
No Tags

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

Revisiónb631a4bad20025b4a08decc33ac4370acdf4c8fc (tree)
Tiempo2022-01-30 23:55:45
AutorAlbert Mietus < albert AT mietus DOT nl >
CommiterAlbert Mietus < albert AT mietus DOT nl >

Log Message

ASIS: Gowing to rewrite peg.Rules (children_as_tuple)

Cambiar Resumen

Diferencia incremental

diff -r 0d5752139a70 -r b631a4bad200 castle/ast/_base.py
--- a/castle/ast/_base.py Sat Jan 29 00:47:01 2022 +0100
+++ b/castle/ast/_base.py Sun Jan 30 15:55:45 2022 +0100
@@ -44,9 +44,9 @@
4444 def validate_or_raise(value):
4545 if isinstance(value, ID): return
4646 if not isinstance(value, str):
47- raise IDError("not a str (or an ID)")
47+ raise IDError(f">>{value}<<: not a str (or an ID)")
4848 if ID._pattern.fullmatch(value) is None:
49- raise IDError("not a valid pattern")
49+ raise IDError(f">>{value}<<: not a valid pattern")
5050
5151 def __init__(self, *, name, **kwargs):
5252 super().__init__(**kwargs)
diff -r 0d5752139a70 -r b631a4bad200 castle/ast/serialization.py
--- a/castle/ast/serialization.py Sat Jan 29 00:47:01 2022 +0100
+++ b/castle/ast/serialization.py Sun Jan 30 15:55:45 2022 +0100
@@ -56,24 +56,30 @@
5656
5757
5858 def _MixIn_value_attribute2xml(self, ast, parent, cls_name):
59- logger.debug(f"{cls_name}2xml:: value={ast._valType(ast.value)}")
59+ logger.debug(f"{cls_name}2xml:: ast={ast._valType(ast.value)}")
6060 ET.SubElement(parent, cls_name, value=ast.value)
6161
6262 def StrTerm2xml(self, ast, parent): self._MixIn_value_attribute2xml(ast, parent, 'StrTerm')
6363 def RegExpTerm2xml(self, ast, parent): self._MixIn_value_attribute2xml(ast, parent, 'RegExpTerm')
6464
6565 def Sequence2xml(self, ast, parent) ->None:
66- logger.debug(f"Sequence2xml:: value={ast._valType(ast.value)}")
66+ logger.debug(f"Sequence2xml::ast={ast._valType(ast.value)}")
6767 seq = ET.SubElement(parent, 'Sequence')
6868 for elm in ast.value:
69- self._ast2xml(elm, seq)
69+ self._ast2xml(elm, parent=seq)
7070
7171 def Rule2xml(self, ast, parent) ->None:
7272 rule = ET.SubElement(parent, 'Rule', name=ast.name.name)
73- self._ast2xml(ast.expr, rule)
73+ self._ast2xml(ast.expr, parent=rule)
74+
75+ def Rules2xml(self, ast, parent) ->None:
76+ logger.debug(f"Rules2xml:: ast[{len(ast)}]")
77+ for child in ast:
78+ logger.debug(f'Rules2xml child={child}:{type(child)}')
79+ self._ast2xml(child, parent=parent)
7480
7581 #############
76- def Rules2xml(self, ast, parent) ->None: ...
82+
7783 def Setting2xml(self, ast, parent) ->None: ...
7884 def Settings2xml(self, ast, parent) ->None: ...
7985 def Grammar2xml(self, ast, parent) ->None: ...
diff -r 0d5752139a70 -r b631a4bad200 pytst/ast/XML_serialization/test_1_simple.py
--- a/pytst/ast/XML_serialization/test_1_simple.py Sat Jan 29 00:47:01 2022 +0100
+++ b/pytst/ast/XML_serialization/test_1_simple.py Sun Jan 30 15:55:45 2022 +0100
@@ -100,5 +100,13 @@
100100 rn.assert_xml_Element(txt)
101101 seq.assert_xml_Element(txt)
102102
103+@pytest.mark.skip(reason="Will rewrite peg.Rules first --")
104+def test_Rules(xml_serialize):
105+ r1 = peg.Rule(name='rule_1', expr=peg.Sequence(value=[peg.ID(name='id1')]))
106+ r2 = peg.Rule(name='rule_2', expr=peg.Sequence(value=[peg.StrTerm(value='str2')]))
103107
108+ txt = xml_serialize(peg.Rules(children=[r1,r2]))
109+ logger.debug(f'XML:: {txt}')
104110
111+ assert False, "not yet done"
112+