diff options
Diffstat (limited to 'p9kcc.py')
| -rw-r--r-- | p9kcc.py | 14 |
1 files changed, 10 insertions, 4 deletions
@@ -207,7 +207,9 @@ class Ds9kCCompiler: argv = sys.argv[1:] self.options = self.arg_parser.parse_args(argv) if not self.options.output: - if self.options.compile_to_obj: + if self.options.preprocess_only: + self.options.output = '-' + elif self.options.compile_to_obj: self.options.output = self.options.sourcefiles[-1].removesuffix(".c") + ".o" else: self.options.output = "a.out" @@ -852,13 +854,17 @@ class Ds9kCCompiler: def run(self): self.predefines() if self.options.preprocess_only: - # TODO write to output (-o) - print(format(self.all_tokens())) + preprocessed_code = format(self.all_tokens()) + if self.options.output == '-': + outfile = sys.stdout + else: + outfile = open(self.options.output, 'w') + print(preprocessed_code, file=outfile) return - # TODO it = self.all_tokens() while self.parse_decl_or_expr(None, it): pass + # TODO generate output code def yield_tokens(self, s): it = iter(s) |
