aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main.c
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2025-09-13 00:05:12 +0900
committernsfisis <nsfisis@gmail.com>2025-09-13 01:38:56 +0900
commit8de7fa9da5fd8015f4fcc826b9270061b7b89478 (patch)
treeec9c1e56f179be207c31a113a0a96210f7509431 /src/main.c
parentd41a97e957ef616d194f60b9b79820cd0162d920 (diff)
downloadducc-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.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/main.c b/src/main.c
index b064f39..5a9fd56 100644
--- a/src/main.c
+++ b/src/main.c
@@ -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);