Skip to content

Commit 435312a

Browse files
committed
Rename Tree.appendChild() to Tree.append_child()
1 parent ba9daac commit 435312a

7 files changed

Lines changed: 23 additions & 21 deletions

File tree

src/ast/tree.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,12 @@ def postorder(self):
7171

7272
yield self
7373

74-
def appendChild(self, node: 'Tree'):
74+
def append_child(self, node: 'Tree'):
7575
""" Appends the given node to the current children list
7676
"""
7777
self.children.append(node)
7878

79-
def prependChild(self, node: 'Tree'):
79+
def prepend_child(self, node: 'Tree'):
8080
""" Inserts the given node at the beginning of the children list
8181
"""
8282
self.children.insert(0, node)

src/symbols/arglist.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def args(self):
2424
def args(self, value):
2525
for i in value:
2626
assert isinstance(value, SymbolARGUMENT)
27-
self.appendChild(i)
27+
self.append_child(i)
2828

2929
def __getitem__(self, range_):
3030
return self.args[range_]
@@ -56,6 +56,6 @@ def make_node(cls, node, *args):
5656

5757
for arg in args:
5858
assert isinstance(arg, SymbolARGUMENT)
59-
node.appendChild(arg)
59+
node.append_child(arg)
6060

6161
return node

src/symbols/boundlist.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
# the GNU General License
1010
# ----------------------------------------------------------------------
1111

12+
from typing import Optional
13+
1214
from .symbol_ import Symbol
1315
from .bound import SymbolBOUND
1416

@@ -32,7 +34,7 @@ def __str__(self):
3234
return '(%s)' % ', '.join(str(x) for x in self)
3335

3436
@classmethod
35-
def make_node(cls, node, *args):
37+
def make_node(cls, node: Optional[Symbol], *args):
3638
""" Creates an array BOUND LIST.
3739
"""
3840
if node is None:
@@ -44,6 +46,6 @@ def make_node(cls, node, *args):
4446
for arg in args:
4547
if arg is None:
4648
continue
47-
node.appendChild(arg)
49+
node.append_child(arg)
4850

4951
return node

src/symbols/paramlist.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,14 @@ def make_node(cls, node, *params):
4444

4545
for i in params:
4646
if i is not None:
47-
node.appendChild(i)
47+
node.append_child(i)
4848

4949
return node
5050

51-
def appendChild(self, param):
51+
def append_child(self, param):
5252
""" Overrides base class.
5353
"""
54-
Symbol.appendChild(self, param)
54+
Symbol.append_child(self, param)
5555
if param.offset is None:
5656
param.offset = self.size
5757
self.size += param.size

src/symbols/symbol_.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def __init__(self, *children):
2626
self._t = None
2727
for child in children:
2828
assert isinstance(child, Symbol)
29-
self.appendChild(child)
29+
self.append_child(child)
3030

3131
self._required_by: Counter = Counter() # Symbols that depends on this one
3232
self._requires: Counter = Counter() # Symbols this one depends on

src/zxbasm/asmparse.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ def makenode(cls, symbol, *nexts):
322322
continue
323323
if not isinstance(i, cls):
324324
raise NotAnAstError(i)
325-
result.appendChild(i)
325+
result.append_child(i)
326326

327327
return result
328328

src/zxbc/zxbparser.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ def make_call(id_: str, lineno: int, args: symbols.ARGLIST):
403403
offset = make_typecast(TYPE.uinteger,
404404
make_number(arr.offset, lineno=lineno),
405405
lineno)
406-
arr.appendChild(offset)
406+
arr.append_child(offset)
407407
return arr
408408

409409
if entry.class_ == CLASS.var: # An already declared/used string var
@@ -532,7 +532,7 @@ def p_start(p):
532532

533533
if not is_null(ast):
534534
if isinstance(ast, symbols.BLOCK) and not is_ender(ast[-1]):
535-
ast.appendChild(__end)
535+
ast.append_child(__end)
536536
else:
537537
ast = __end
538538

@@ -554,11 +554,11 @@ def p_start(p):
554554

555555
# Appends variable declarations at the end.
556556
for var in SYMBOL_TABLE.vars_:
557-
data_ast.appendChild(make_var_declaration(var))
557+
data_ast.append_child(make_var_declaration(var))
558558

559559
# Appends arrays declarations at the end.
560560
for var in SYMBOL_TABLE.arrays:
561-
data_ast.appendChild(make_array_declaration(var))
561+
data_ast.append_child(make_array_declaration(var))
562562

563563

564564
def p_program_program_line(p):
@@ -1514,7 +1514,7 @@ def p_if_then_part(p):
15141514
def p_if_inline(p):
15151515
""" statement : if_inline else_part_inline
15161516
"""
1517-
p[1].appendChild(make_block(p[2][0], p[2][1]))
1517+
p[1].append_child(make_block(p[2][0], p[2][1]))
15181518
p[0] = p[1]
15191519

15201520

@@ -1544,7 +1544,7 @@ def p_for_sentence(p):
15441544
p[0] = p[1]
15451545
if is_null(p[0]):
15461546
return
1547-
p[1].appendChild(make_block(p[2], p[3]))
1547+
p[1].append_child(make_block(p[2], p[3]))
15481548
gl.LOOPS.pop()
15491549

15501550

@@ -2020,18 +2020,18 @@ def p_print_list(p):
20202020
p[0].eol = (p[3] is not None)
20212021

20222022
if p[3] is not None:
2023-
p[0].appendChild(p[3])
2023+
p[0].append_child(p[3])
20242024

20252025

20262026
def p_print_list_comma(p):
20272027
""" print_list : print_list COMMA print_elem
20282028
"""
20292029
p[0] = p[1]
20302030
p[0].eol = (p[3] is not None)
2031-
p[0].appendChild(make_sentence(p.lineno(2), 'PRINT_COMMA'))
2031+
p[0].append_child(make_sentence(p.lineno(2), 'PRINT_COMMA'))
20322032

20332033
if p[3] is not None:
2034-
p[0].appendChild(p[3])
2034+
p[0].append_child(p[3])
20352035

20362036

20372037
def p_print_list_at(p):
@@ -2943,7 +2943,7 @@ def p_function_header_pre(p):
29432943
forwarded = p[1].entry.forwarded
29442944

29452945
p[0] = p[1]
2946-
p[0].appendChild(p[2])
2946+
p[0].append_child(p[2])
29472947
p[0].params_size = p[2].size
29482948
lineno = p.lineno(3)
29492949

0 commit comments

Comments
 (0)