|
13 | 13 |
|
14 | 14 | import os |
15 | 15 |
|
| 16 | +from typing import Any |
16 | 17 | from typing import List |
17 | 18 | from typing import Optional |
18 | 19 | from typing import Tuple |
| 20 | +from typing import NamedTuple |
19 | 21 |
|
20 | 22 | import src.ply.yacc as yacc |
21 | 23 | import src.api.utils |
@@ -192,15 +194,11 @@ def argval(self): |
192 | 194 | return super(Asm, self).argval() |
193 | 195 |
|
194 | 196 |
|
195 | | -class Container(object): |
| 197 | +class Container(NamedTuple): |
196 | 198 | """ Single class container |
197 | 199 | """ |
198 | | - |
199 | | - def __init__(self, item, lineno): |
200 | | - """ Item to store |
201 | | - """ |
202 | | - self.item = item |
203 | | - self.lineno = lineno |
| 200 | + item: Any |
| 201 | + lineno: int |
204 | 202 |
|
205 | 203 |
|
206 | 204 | class Expr(Ast): |
@@ -329,7 +327,7 @@ def makenode(cls, symbol, *nexts): |
329 | 327 | return result |
330 | 328 |
|
331 | 329 |
|
332 | | -class Label(object): |
| 330 | +class Label: |
333 | 331 | """ A class to store Label information (NAME, linenumber and Address) |
334 | 332 | """ |
335 | 333 |
|
@@ -384,7 +382,7 @@ def name(self): |
384 | 382 | return self._name |
385 | 383 |
|
386 | 384 |
|
387 | | -class Memory(object): |
| 385 | +class Memory: |
388 | 386 | """ A class to describe memory |
389 | 387 | """ |
390 | 388 |
|
@@ -763,13 +761,13 @@ def p_LOCAL(p): |
763 | 761 | def p_idlist(p): |
764 | 762 | """ id_list : ID |
765 | 763 | """ |
766 | | - p[0] = ((p[1], p.lineno(1)),) |
| 764 | + p[0] = (Container(p[1], p.lineno(1)),) |
767 | 765 |
|
768 | 766 |
|
769 | 767 | def p_idlist_id(p): |
770 | 768 | """ id_list : id_list COMMA ID |
771 | 769 | """ |
772 | | - p[0] = p[1] + ((p[3], p.lineno(3)),) |
| 770 | + p[0] = p[1] + (Container(p[3], p.lineno(3)),) |
773 | 771 |
|
774 | 772 |
|
775 | 773 | def p_DEFB(p): # Define bytes |
@@ -1531,7 +1529,7 @@ def p_preprocessor_line_line_file(p): |
1531 | 1529 | def p_preproc_line_init(p): |
1532 | 1530 | """ preproc_line : _INIT STRING |
1533 | 1531 | """ |
1534 | | - INITS.append((p[2].strip('"'), p.lineno(2))) |
| 1532 | + INITS.append(Container(p[2].strip('"'), p.lineno(2))) |
1535 | 1533 |
|
1536 | 1534 |
|
1537 | 1535 | # --- YYERROR |
|
0 commit comments