|
3 | 3 |
|
4 | 4 | import re |
5 | 5 | import sys |
| 6 | +from argparse import Namespace |
6 | 7 | from io import StringIO |
7 | 8 |
|
8 | 9 | import src.api.optimize |
@@ -61,7 +62,12 @@ def output(memory, ofile=None): |
61 | 62 | ofile.write("%s\n" % m) |
62 | 63 |
|
63 | 64 |
|
64 | | -def main(args=None, emitter=None): |
| 65 | +def save_config(options: Namespace) -> None: |
| 66 | + if not gl.has_errors and options.save_config: |
| 67 | + src.api.config.save_config_into_file(options.save_config, src.api.config.ConfigSections.ZXBC) |
| 68 | + |
| 69 | + |
| 70 | +def main(args=None, emitter=None) -> int: |
65 | 71 | """Entry point when executed from command line. |
66 | 72 | zxbc can be used as python module. If so, bear in mind this function |
67 | 73 | won't be executed unless explicitly called. |
@@ -124,6 +130,10 @@ def main(args=None, emitter=None): |
124 | 130 | debug.__DEBUG__("exiting due to errors.") |
125 | 131 | return 1 # Exit with errors |
126 | 132 |
|
| 133 | + if options.parse_only: |
| 134 | + save_config(options) |
| 135 | + return gl.has_errors |
| 136 | + |
127 | 137 | # Emits data lines |
128 | 138 | translator.emit_data_blocks() |
129 | 139 | # Emits default constant strings |
@@ -216,8 +226,7 @@ def main(args=None, emitter=None): |
216 | 226 | with open_file(OPTIONS.memory_map, "wt", "utf-8") as f: |
217 | 227 | f.write(asmparse.MEMORY.memory_map) |
218 | 228 |
|
219 | | - if not gl.has_errors and options.save_config: |
220 | | - src.api.config.save_config_into_file(options.save_config, src.api.config.ConfigSections.ZXBC) |
| 229 | + save_config(options) |
221 | 230 |
|
222 | 231 | return gl.has_errors # Exit success |
223 | 232 |
|
|
0 commit comments