coco-tools 0.17__tar.gz → 0.18__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. {coco-tools-0.17/coco_tools.egg-info → coco-tools-0.18}/PKG-INFO +1 -1
  2. {coco-tools-0.17 → coco-tools-0.18}/coco/__init__.py +1 -1
  3. {coco-tools-0.17 → coco-tools-0.18}/coco/b09/elements.py +9 -2
  4. {coco-tools-0.17 → coco-tools-0.18}/coco/b09/grammar.py +2 -2
  5. {coco-tools-0.17 → coco-tools-0.18}/coco/b09/parser.py +1 -1
  6. {coco-tools-0.17 → coco-tools-0.18}/coco/b09/visitors.py +15 -1
  7. {coco-tools-0.17 → coco-tools-0.18/coco_tools.egg-info}/PKG-INFO +1 -1
  8. {coco-tools-0.17 → coco-tools-0.18}/setup.py +1 -1
  9. {coco-tools-0.17 → coco-tools-0.18}/LICENSE +0 -0
  10. {coco-tools-0.17 → coco-tools-0.18}/README.md +0 -0
  11. {coco-tools-0.17 → coco-tools-0.18}/coco/b09/__init__.py +0 -0
  12. {coco-tools-0.17 → coco-tools-0.18}/coco/b09/compiler.py +0 -0
  13. {coco-tools-0.17 → coco-tools-0.18}/coco/b09/error_handler.py +0 -0
  14. {coco-tools-0.17 → coco-tools-0.18}/coco/b09/procbank.py +0 -0
  15. {coco-tools-0.17 → coco-tools-0.18}/coco/b09/prog.py +0 -0
  16. {coco-tools-0.17 → coco-tools-0.18}/coco/cm3toppm.py +0 -0
  17. {coco-tools-0.17 → coco-tools-0.18}/coco/decb_to_b09.py +0 -0
  18. {coco-tools-0.17 → coco-tools-0.18}/coco/hrstoppm.py +0 -0
  19. {coco-tools-0.17 → coco-tools-0.18}/coco/maxtoppm.py +0 -0
  20. {coco-tools-0.17 → coco-tools-0.18}/coco/mge_viewer2.py +0 -0
  21. {coco-tools-0.17 → coco-tools-0.18}/coco/mgetoppm.py +0 -0
  22. {coco-tools-0.17 → coco-tools-0.18}/coco/pixtopgm.py +0 -0
  23. {coco-tools-0.17 → coco-tools-0.18}/coco/rattoppm.py +0 -0
  24. {coco-tools-0.17 → coco-tools-0.18}/coco/resources/__init__.py +0 -0
  25. {coco-tools-0.17 → coco-tools-0.18}/coco/resources/ecb.b09 +0 -0
  26. {coco-tools-0.17 → coco-tools-0.18}/coco/util.py +0 -0
  27. {coco-tools-0.17 → coco-tools-0.18}/coco/veftopng.py +0 -0
  28. {coco-tools-0.17 → coco-tools-0.18}/coco_tools.egg-info/SOURCES.txt +0 -0
  29. {coco-tools-0.17 → coco-tools-0.18}/coco_tools.egg-info/dependency_links.txt +0 -0
  30. {coco-tools-0.17 → coco-tools-0.18}/coco_tools.egg-info/entry_points.txt +0 -0
  31. {coco-tools-0.17 → coco-tools-0.18}/coco_tools.egg-info/requires.txt +0 -0
  32. {coco-tools-0.17 → coco-tools-0.18}/coco_tools.egg-info/top_level.txt +0 -0
  33. {coco-tools-0.17 → coco-tools-0.18}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: coco-tools
3
- Version: 0.17
3
+ Version: 0.18
4
4
  Summary: TRS-80 Color Computer Tools
5
5
  Home-page: https://github.com/jamieleecho/coco-tools
6
6
  Author: Jamie Cho
@@ -1,2 +1,2 @@
1
1
  # __version__ MUST be defined on line 2
2
- __version__ = "0.17"
2
+ __version__ = "0.18"
@@ -1003,7 +1003,15 @@ class BasicDimStatement(AbstractBasicStatement):
1003
1003
  def default_str_storage(self, val):
1004
1004
  self._default_str_storage = val
1005
1005
 
1006
- def init_text_for_var(self, dim_var):
1006
+ def init_text_for_var(self, dim_var: "BasicArrayRef | BasicVar") -> str:
1007
+ if isinstance(dim_var, BasicVar):
1008
+ return BasicStatements(
1009
+ [
1010
+ BasicAssignment(dim_var, BasicLiteral("" if dim_var.is_str_expr else 0)),
1011
+ ],
1012
+ multi_line=False,
1013
+ ).basic09_text(0)
1014
+
1007
1015
  for_statements = (
1008
1016
  BasicForStatement(
1009
1017
  BasicVar(f"tmp_{ii + 1}"),
@@ -1085,7 +1093,6 @@ class BasicDimStatement(AbstractBasicStatement):
1085
1093
  (
1086
1094
  self.init_text_for_var(dim_var)
1087
1095
  for dim_var in dim_vars
1088
- if isinstance(dim_var, BasicArrayRef)
1089
1096
  )
1090
1097
  )
1091
1098
  init_text = "\n" + init_text if init_text else ""
@@ -214,7 +214,7 @@ KEYWORDS = "|".join(
214
214
 
215
215
  grammar = Grammar(
216
216
  rf"""
217
- aaa_prog = multi_line eol* ~r"\x00?" eof
217
+ aaa_prog = (space* eol+)* multi_line eol* ~r"\x00?" eof
218
218
  multi_line = line space* multi_line_elements
219
219
  multi_line_elements = multi_line_element*
220
220
  multi_line_element = eol+ line space*
@@ -380,7 +380,7 @@ grammar = Grammar(
380
380
  comment_text = ~r".*"
381
381
  comment_token = ~r"(REM|')"
382
382
  eof = ~r"$"
383
- eol = ~r"[\n\r]+"
383
+ eol = ~r"[\n\r]"
384
384
  linenum = ~r"[0-9]+"
385
385
  literal = num_literal
386
386
  hex_literal = ~r"& *H *[0-9A-F][0-9A-F]?[0-9A-F]?[0-9A-F]?[0-9A-F]?[0-9A-F]?"
@@ -134,7 +134,7 @@ class BasicVisitor(NodeVisitor):
134
134
  return node
135
135
 
136
136
  def visit_aaa_prog(self, _, visited_children):
137
- return BasicProg(visited_children[0])
137
+ return BasicProg(visited_children[1])
138
138
 
139
139
  def visit_arr_assign(self, _, visited_children):
140
140
  let_kw, _, array_ref_exp, _, _, _, val_exp = visited_children
@@ -220,11 +220,16 @@ class StatementCollectorVisitor(BasicConstructVisitor):
220
220
 
221
221
 
222
222
  class VarInitializerVisitor(BasicConstructVisitor):
223
+ _vars: Set[str]
224
+ _dimmed_var_names: Set[str]
225
+
223
226
  def __init__(self):
224
227
  self._vars = set()
228
+ self._dimmed_var_names = set()
225
229
 
226
230
  @property
227
231
  def assignment_lines(self) -> List[BasicLine]:
232
+ vars_to_assign = self._vars - self._dimmed_var_names
228
233
  return [
229
234
  BasicLine(
230
235
  None,
@@ -237,7 +242,7 @@ class VarInitializerVisitor(BasicConstructVisitor):
237
242
  is_str_expr=var.endswith("$"),
238
243
  ),
239
244
  )
240
- for var in sorted(self._vars)
245
+ for var in sorted(vars_to_assign)
241
246
  if ((var.endswith("$") and len(var) <= 3) or len(var) <= 2)
242
247
  ]
243
248
  ),
@@ -247,6 +252,15 @@ class VarInitializerVisitor(BasicConstructVisitor):
247
252
  def visit_var(self, var) -> None:
248
253
  self._vars.add(var.name())
249
254
 
255
+ def visit_statement(self, statement: BasicForStatement) -> None:
256
+ if isinstance(statement, BasicDimStatement):
257
+ self._dimmed_var_names.update(
258
+ [
259
+ var.var.name() if isinstance(var, BasicArrayRef) else var.name()
260
+ for var in statement.dim_vars
261
+ ]
262
+ )
263
+
250
264
 
251
265
  class StrVarAllocatorVisitor(BasicConstructVisitor):
252
266
  _vars: Set[str]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: coco-tools
3
- Version: 0.17
3
+ Version: 0.18
4
4
  Summary: TRS-80 Color Computer Tools
5
5
  Home-page: https://github.com/jamieleecho/coco-tools
6
6
  Author: Jamie Cho
@@ -3,7 +3,7 @@
3
3
  import setuptools
4
4
 
5
5
  # VERSION MUST be defined on line 6
6
- VERSION = "0.17"
6
+ VERSION = "0.18"
7
7
 
8
8
  with open("README.md", "r") as fh:
9
9
  long_description = fh.read()
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes