• 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

修訂96da5581ccbe5bd47c30d3a31f55fc4be50cb71c (tree)
時間2022-01-03 07:43:33
作者Albert Mietus < albert AT mietus DOT nl >
CommiterAlbert Mietus < albert AT mietus DOT nl >

Log Message

groups (normal ones) do work

Change Summary

差異

diff -r f0bc39d34f56 -r 96da5581ccbe AST/castle/peg.py
--- a/AST/castle/peg.py Sun Jan 02 21:43:48 2022 +0100
+++ b/AST/castle/peg.py Sun Jan 02 23:43:33 2022 +0100
@@ -61,7 +61,7 @@
6161 self.settings = settings
6262
6363
64-class Group(Expression):pass # abstract
64+class Group(Expression):pass # abstract -- Do not use for a '(' ...')' group, that's a Sequence!!
6565 class UnorderedGroup(Group):pass # It looks like a Quantity, but is a group
6666
6767
diff -r f0bc39d34f56 -r 96da5581ccbe Arpeggio/pytst/d2_ast/test_5_group.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Arpeggio/pytst/d2_ast/test_5_group.py Sun Jan 02 23:43:33 2022 +0100
@@ -0,0 +1,38 @@
1+import pytest
2+import logging;logger = logging.getLogger(__name__)
3+
4+import grammar
5+from castle import peg # has the AST classes
6+
7+from . import parse, assert_ID
8+
9+def test_simple_group():
10+ txt = "R <- ( A B ) ;"
11+
12+ ast = parse(txt, grammar.rule)
13+ assert_ID(ast.name, 'R')
14+
15+ grp = ast.expr
16+ assert len(grp)==1, "There should be only one expr; the group"
17+ assert isinstance(grp[0], peg.Sequence)
18+
19+ assert_ID(grp[0][0], 'A')
20+ assert_ID(grp[0][1], 'B')
21+
22+def test_nested_group():
23+ txt = "R <- ( ( A B ) ) ;"
24+
25+ ast = parse(txt, grammar.rule)
26+ assert_ID(ast.name, 'R')
27+
28+ grp = ast.expr
29+ assert len(grp)==1, "There should be only one expr; the group"
30+ assert isinstance(grp[0], peg.Sequence)
31+
32+ ngrp = grp[0]
33+ assert len(ngrp)==1
34+ assert isinstance(ngrp[0], peg.Sequence)
35+
36+ assert_ID(ngrp[0][0], 'A')
37+ assert_ID(ngrp[0][1], 'B')
38+
diff -r f0bc39d34f56 -r 96da5581ccbe Arpeggio/visitor.py
--- a/Arpeggio/visitor.py Sun Jan 02 21:43:48 2022 +0100
+++ b/Arpeggio/visitor.py Sun Jan 02 23:43:33 2022 +0100
@@ -34,7 +34,7 @@
3434 n = children[0].name
3535 except AttributeError:
3636 n = str(children[0])
37- logger.warning(f'visit_single_expr==1:: {n}:{type(children[0])}')
37+ logger.debug(f'visit_single_expr==1:: {n}:{type(children[0])}')
3838 return children[0]
3939 elif len(children) == 2: # Optional part
4040 logger.debug(f'visit_single_expr==2:: {children[0]}, {children[1]}')