From 809fdf7ceb408768cdd5daa922193446a5029701 Mon Sep 17 00:00:00 2001 From: Franziskus Kiefer Date: Fri, 11 Oct 2024 08:31:39 +0000 Subject: [PATCH] Disable comments by default adds option to enable them --- bin/main.ml | 1 + lib/AstOfLlbc.ml | 2 +- lib/Options.ml | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/bin/main.ml b/bin/main.ml index dcd182a..4c5bf38 100644 --- a/bin/main.ml +++ b/bin/main.ml @@ -24,6 +24,7 @@ Supported options:|} ( "--header", Arg.Set_string Krml.Options.header, " path to a header file to be prepended to the generated C" ); + "--comments", Arg.Set O.comments, " keep inline comments"; "--config", Arg.Set_string O.config, " YAML configuration file"; "-funroll-loops", Arg.Set_int funroll_loops, " unrool loops up to N"; ] diff --git a/lib/AstOfLlbc.ml b/lib/AstOfLlbc.ml index a13dca8..6d6f173 100644 --- a/lib/AstOfLlbc.ml +++ b/lib/AstOfLlbc.ml @@ -1563,7 +1563,7 @@ let rec expression_of_raw_statement (env : env) (ret_var : C.var_id) (s : C.raw_ and expression_of_statement (env: env) (ret_var: C.var_id) (s: C.statement): K.expr = { (expression_of_raw_statement env ret_var s.content) with - meta = List.map (fun x -> K.CommentBefore x) s.comments_before } + meta = if !Options.comments then List.map (fun x -> K.CommentBefore x) s.comments_before else [] } (** Top-level declarations: orchestration *) diff --git a/lib/Options.ml b/lib/Options.ml index dd36298..cf067db 100644 --- a/lib/Options.ml +++ b/lib/Options.ml @@ -1,2 +1,3 @@ let log_level = ref "" let config = ref "" +let comments = ref false