From 43f8f0f62aebdc08702ae346944a7063c8fc123d Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Mon, 21 Apr 2025 18:21:56 -0400 Subject: Switch from XML to s-expressions and add --parse flag for printing them --- src/tomo.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/tomo.c') diff --git a/src/tomo.c b/src/tomo.c index b230319c..1c4f39f9 100644 --- a/src/tomo.c +++ b/src/tomo.c @@ -55,6 +55,7 @@ static OptionalList_t files = NONE_LIST, libraries = NONE_LIST; static OptionalBool_t verbose = false, quiet = false, + show_parse_tree = false, stop_at_transpile = false, stop_at_obj_compilation = false, compile_exe = false, @@ -149,6 +150,7 @@ int main(int argc, char *argv[]) "\x1b[1mOther flags:\x1b[m\n" " --verbose|-v: verbose output\n" " --quiet|-q: quiet output\n" + " --parse|-p: show parse tree\n" " --install|-I: install the executable or library\n" " --c-compiler : the C compiler to use (default: "DEFAULT_C_COMPILER")\n" " --optimization|-O : set optimization level\n" @@ -161,6 +163,8 @@ int main(int argc, char *argv[]) {"args", true, List$info(&Text$info), &args}, {"verbose", false, &Bool$info, &verbose}, {"v", false, &Bool$info, &verbose}, + {"parse", false, &Bool$info, &show_parse_tree}, + {"p", false, &Bool$info, &show_parse_tree}, {"quiet", false, &Bool$info, &quiet}, {"q", false, &Bool$info, &quiet}, {"transpile", false, &Bool$info, &stop_at_transpile}, @@ -254,6 +258,12 @@ int main(int argc, char *argv[]) for (int64_t i = 0; i < files.length; i++) { Path_t path = *(Path_t*)(files.data + i*files.stride); + if (show_parse_tree) { + ast_t *ast = parse_file(Path$as_c_string(path), NULL); + print(ast_to_sexp_str(ast)); + continue; + } + Path_t exe_path = compile_exe ? Path$with_extension(path, Text(""), true) : build_file(Path$with_extension(path, Text(""), true), ""); -- cgit v1.2.3