File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -24,17 +24,8 @@ def __init__(self, *nodes):
2424 def make_node (cls , * args ):
2525 """ Creates a chain of code blocks.
2626 """
27- new_args = []
28-
29- args = [x for x in args if not is_null (x )]
30- for x in args :
31- assert isinstance (x , Symbol )
32- if x .token == 'BLOCK' :
33- new_args .extend (SymbolBLOCK .make_node (* x .children ).children )
34- else :
35- new_args .append (x )
36-
37- result = SymbolBLOCK (* new_args )
27+ result = SymbolBLOCK ()
28+ result .append (* args )
3829 return result
3930
4031 def __getitem__ (self , item ):
@@ -54,3 +45,13 @@ def __hash__(self):
5445
5546 def pop (self , pos : int ) -> Symbol :
5647 return self .children .pop (pos )
48+
49+ def append (self , * args ):
50+ for arg in args :
51+ if check .is_null (arg ):
52+ continue
53+ assert isinstance (arg , Symbol ), f"Invalid argument '{ arg } '"
54+ if arg .token == 'BLOCK' :
55+ self .append (* arg .children )
56+ else :
57+ self .children .append (arg )
You can’t perform that action at this time.
0 commit comments