diff --git a/Source/DafnyCore/DafnyOptions.cs b/Source/DafnyCore/DafnyOptions.cs index e6c6b0a3c4..40f29a3b3b 100644 --- a/Source/DafnyCore/DafnyOptions.cs +++ b/Source/DafnyCore/DafnyOptions.cs @@ -320,7 +320,6 @@ public enum ContractTestingMode { public PrintModes PrintMode = PrintModes.Everything; // Default to printing everything public bool DafnyVerify = true; public string DafnyPrintResolvedFile = null; - public string BoogieExtractionTargetFile = null; public List DafnyPrintExportedViews = new List(); public bool Compile = true; public List MainArgs = new List(); diff --git a/Source/DafnyCore/Prelude/Makefile b/Source/DafnyCore/Prelude/Makefile index 94e8c4b834..2010229bbe 100644 --- a/Source/DafnyCore/Prelude/Makefile +++ b/Source/DafnyCore/Prelude/Makefile @@ -15,6 +15,6 @@ DafnyPrelude.bpl: PreludeCore.bpl Sequences.bpl sed -e "s|PRIME|'|g" -i "" PreludeCore.bpl Sequences.bpl DafnyPrelude.bpl Sequences.bpl: Lists.dfy Boxes.dfy Sequences.dfy - $(DAFNY) verify Lists.dfy Boxes.dfy Sequences.dfy --extract:Sequences.bpl + $(DAFNY) extract Sequences.bpl Lists.dfy Boxes.dfy Sequences.dfy # Remove trailing spaces that the Boogie pretty printer emits sed -e "s| *$$||" -i "" Sequences.bpl diff --git a/Source/DafnyCore/Backends/BoogieExtractor.cs b/Source/DafnyDriver/Commands/BoogieExtractor.cs similarity index 100% rename from Source/DafnyCore/Backends/BoogieExtractor.cs rename to Source/DafnyDriver/Commands/BoogieExtractor.cs diff --git a/Source/DafnyDriver/Commands/ExtractCommand.cs b/Source/DafnyDriver/Commands/ExtractCommand.cs new file mode 100644 index 0000000000..b8f12a5c7a --- /dev/null +++ b/Source/DafnyDriver/Commands/ExtractCommand.cs @@ -0,0 +1,59 @@ +#nullable enable +using System.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Threading.Tasks; +using DafnyDriver.Commands; +using Microsoft.Boogie; +using Microsoft.Dafny.Compilers; + +namespace Microsoft.Dafny; + +public static class ExtractCommand { + public static Command Create() { + + var result = new Command("extract", "Can be used to generate DafnyPrelude.bpl. Uses the ':extract_boogie_name' attribute to rename symbols. Turns lemmas into universally quantified axioms, as opposed to verify which turns them into Boogie procedures. When translating Dafny expressions to Boogie ones, no well-formedness checks are created."); + + result.IsHidden = true; + result.AddArgument(Target); + result.AddArgument(DafnyCommands.FilesArgument); + foreach (var option in ExtractOptions) { + result.AddOption(option); + } + DafnyNewCli.SetHandlerUsingDafnyOptionsContinuation(result, (options, _) => HandleExtraction(options)); + return result; + } + + private static readonly Argument Target = new("The path of the extracted file."); + + private static IReadOnlyList