diff options
| author | nsfisis <nsfisis@gmail.com> | 2025-09-13 00:05:12 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2025-09-13 01:38:56 +0900 |
| commit | 8de7fa9da5fd8015f4fcc826b9270061b7b89478 (patch) | |
| tree | ec9c1e56f179be207c31a113a0a96210f7509431 /src/main.c | |
| parent | d41a97e957ef616d194f60b9b79820cd0162d920 (diff) | |
| download | ducc-8de7fa9da5fd8015f4fcc826b9270061b7b89478.tar.gz ducc-8de7fa9da5fd8015f4fcc826b9270061b7b89478.tar.zst ducc-8de7fa9da5fd8015f4fcc826b9270061b7b89478.zip | |
feat: implement -E flag (preprocess only)
Diffstat (limited to 'src/main.c')
| -rw-r--r-- | src/main.c | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -22,6 +22,16 @@ int main(int argc, char** argv) { strings_init(&included_files); TokenArray* pp_tokens = preprocess(source, &included_files); + + if (cli_args->preprocess_only) { + FILE* output_file = cli_args->output_filename ? fopen(cli_args->output_filename, "w") : stdout; + if (!output_file) { + fatal_error("Cannot open output file: %s", cli_args->output_filename); + } + print_token_to_file(output_file, pp_tokens); + return 0; + } + TokenArray* tokens = tokenize(pp_tokens); Program* prog = parse(tokens); |
