|
1 | 1 | #!/usr/bin/python |
2 | 2 | # -*- coding: utf-8 -*- |
3 | | -# vim: ts=4:et:sw=4: |
4 | 3 |
|
5 | 4 | # ---------------------------------------------------------------------- |
6 | 5 | # Copyleft (K), Jose M. Rodriguez-Rosa (a.k.a. Boriel) |
7 | 6 | # |
8 | 7 | # This program is Free Software and is released under the terms of |
9 | 8 | # the GNU General License |
10 | 9 | # ---------------------------------------------------------------------- |
| 10 | +from __future__ import annotations |
| 11 | + |
| 12 | +from typing import Iterable |
11 | 13 |
|
12 | 14 | from src.symbols.argument import SymbolARGUMENT |
13 | 15 | from src.symbols.symbol_ import Symbol |
14 | 16 |
|
15 | 17 |
|
16 | | -class SymbolARGLIST(Symbol): |
| 18 | +class SymbolARGLIST(Symbol, Iterable[SymbolARGUMENT]): |
17 | 19 | """Defines a list of arguments in a function call or array access""" |
18 | 20 |
|
19 | 21 | @property |
@@ -42,15 +44,17 @@ def __repr__(self): |
42 | 44 | def __len__(self): |
43 | 45 | return len(self.args) |
44 | 46 |
|
| 47 | + def __iter__(self): |
| 48 | + return iter(self.args) |
| 49 | + |
45 | 50 | @classmethod |
46 | | - def make_node(cls, node, *args): |
| 51 | + def make_node(cls, node: SymbolARGLIST | None, *args: SymbolARGUMENT): |
47 | 52 | """This will return a node with an argument_list.""" |
48 | 53 | if node is None: |
49 | 54 | node = cls() |
50 | 55 |
|
51 | 56 | assert isinstance(node, SymbolARGUMENT) or isinstance(node, cls) |
52 | | - |
53 | | - if not isinstance(node, cls): |
| 57 | + if isinstance(node, SymbolARGUMENT): |
54 | 58 | return cls.make_node(None, node, *args) |
55 | 59 |
|
56 | 60 | for arg in args: |
|
0 commit comments