public static int ThreadMain(string[] args) { Contract.Requires(cce.NonNullElements(args)); ErrorReporter reporter = new ConsoleErrorReporter(); ExecutionEngine.printer = new DafnyConsolePrinter(); // For boogie errors DafnyOptions.Install(new DafnyOptions(reporter)); List<string> dafnyFiles; List<string> otherFiles; ExitValue exitValue = ProcessCommandLineArguments(args, out dafnyFiles, out otherFiles); if (exitValue == ExitValue.VERIFIED) { exitValue = ProcessFiles(dafnyFiles, otherFiles.AsReadOnly(), reporter); } if (CommandLineOptions.Clo.XmlSink != null) { CommandLineOptions.Clo.XmlSink.Close(); } if (CommandLineOptions.Clo.Wait) { Console.WriteLine("Press Enter to exit."); Console.ReadLine(); } if (!DafnyOptions.O.CountVerificationErrors && exitValue != ExitValue.PREPROCESSING_ERROR) { return 0; } //Console.ReadKey(); return (int)exitValue; }
public static int ThreadMain(string[] args) { Contract.Requires(cce.NonNullElements(args)); ErrorReporter reporter = new ConsoleErrorReporter(); ExecutionEngine.printer = new DafnyConsolePrinter(); // For boogie errors DafnyOptions.Install(new DafnyOptions(reporter)); CommandLineArgumentsResult cliArgumentsResult = ProcessCommandLineArguments(args, out var dafnyFiles, out var otherFiles); ExitValue exitValue; switch (cliArgumentsResult) { case CommandLineArgumentsResult.OK: exitValue = ProcessFiles(dafnyFiles, otherFiles.AsReadOnly(), reporter); break; case CommandLineArgumentsResult.PREPROCESSING_ERROR: exitValue = ExitValue.PREPROCESSING_ERROR; break; case CommandLineArgumentsResult.OK_EXIT_EARLY: exitValue = ExitValue.SUCCESS; break; default: throw new ArgumentOutOfRangeException(); } if (CommandLineOptions.Clo.XmlSink != null) { CommandLineOptions.Clo.XmlSink.Close(); if (DafnyOptions.O.VerificationLoggerConfig != null) { BoogieXmlConvertor.RaiseTestLoggerEvents(DafnyOptions.O.BoogieXmlFilename, DafnyOptions.O.VerificationLoggerConfig); } } if (CommandLineOptions.Clo.Wait) { Console.WriteLine("Press Enter to exit."); Console.ReadLine(); } if (!DafnyOptions.O.CountVerificationErrors) { return(0); } //Console.ReadKey(); return((int)exitValue); }
public Program ParseAndTypeCheck(bool runResolver) { var errorReporter = new ConsoleErrorReporter(); var module = new LiteralModuleDecl(new DefaultModuleDecl(), null); var builtIns = new BuiltIns(); var parseErrors = new Errors(errorReporter); var errorCount = Parser.Parse(_snapshot.GetText(), _filename, _filename, module, builtIns, parseErrors); var errString = Main.ParseIncludes(module, builtIns, new List<string>(), parseErrors); if (errorCount != 0 || errString != null) return null; var program = new Program(_filename, module, builtIns, errorReporter); if (!runResolver) return program; var r = new Resolver(program); r.ResolveProgram(program); return errorReporter.Count(ErrorLevel.Error) == 0 ? program : null; }
public static int ThreadMain(string[] args, Dafny.ModuleDecl module, Dafny.BuiltIns builtIns) { Contract.Requires(cce.NonNullElements(args)); Contract.Requires(module != null); Contract.Requires(builtIns != null); Dafny.ErrorReporter reporter = new Dafny.ConsoleErrorReporter(); ExecutionEngine.printer = new DafnyConsolePrinter(); // For boogie errors Dafny.DafnyOptions.Install(new Dafny.DafnyOptions(reporter)); // Temporarily change .vad to .dfy var valeFileName = args[args.Length - 1]; args[args.Length - 1] = valeFileName.Replace(".vad", ".dfy"); List <Microsoft.Dafny.DafnyFile> valeFile; List <string> otherFiles; ExitValue exitValue = Dafny.DafnyDriver.ProcessCommandLineArguments(args, out valeFile, out otherFiles); // Replace .dfy with .vad var fileNames = valeFile.ConvertAll(f => f.FilePath); fileNames[0] = valeFileName; if (exitValue == ExitValue.VERIFIED) { exitValue = ProcessFile(fileNames, module, builtIns, reporter); } if (CommandLineOptions.Clo.XmlSink != null) { CommandLineOptions.Clo.XmlSink.Close(); } if (CommandLineOptions.Clo.Wait) { Console.WriteLine("Press Enter to exit."); Console.ReadLine(); } if (!Dafny.DafnyOptions.O.CountVerificationErrors && exitValue != ExitValue.PREPROCESSING_ERROR) { return(0); } return((int)exitValue); }
public static int Parse_Verbatim_Block(string verbatim_block, string filename, int line, Dafny.ModuleDecl module, Dafny.BuiltIns builtIns, bool verifyThisFile = true) { Contract.Requires(verbatim_block != null); Contract.Requires(filename != null); Contract.Requires(module != null); Dafny.ErrorReporter reporter = new Dafny.ConsoleErrorReporter(); Dafny.Errors errors = new Dafny.Errors(reporter); byte[] buffer = cce.NonNull(System.Text.UTF8Encoding.Default.GetBytes(verbatim_block)); MemoryStream ms = new MemoryStream(buffer, false); string fullFilename = Path.GetFullPath(filename); Dafny.Scanner scanner = new Dafny.Scanner(ms, errors, fullFilename, filename, line); Dafny.Parser parser = new Dafny.Parser(scanner, errors, null, module, builtIns, verifyThisFile); parser.Parse(); return(parser.errors.ErrorCount); }
public static int ThreadMain(string[] args) { Contract.Requires(cce.NonNullElements(args)); ErrorReporter reporter = new ConsoleErrorReporter(); ExecutionEngine.printer = new DafnyConsolePrinter(); // For boogie errors DafnyOptions.Install(new DafnyOptions(reporter)); List <DafnyFile> dafnyFiles; List <string> otherFiles; ExitValue exitValue = ProcessCommandLineArguments(args, out dafnyFiles, out otherFiles); if (exitValue == ExitValue.VERIFIED) { exitValue = ProcessFiles(dafnyFiles, otherFiles.AsReadOnly(), reporter); } if (CommandLineOptions.Clo.XmlSink != null) { CommandLineOptions.Clo.XmlSink.Close(); } if (CommandLineOptions.Clo.Wait) { Console.WriteLine("Press Enter to exit."); Console.ReadLine(); } if (!DafnyOptions.O.CountVerificationErrors && exitValue != ExitValue.PREPROCESSING_ERROR) { return(0); } //Console.ReadKey(); return((int)exitValue); }
public static int ThreadMain(string[] args) { Contract.Requires(cce.NonNullElements(args)); ErrorReporter reporter = new ConsoleErrorReporter(); ExecutionEngine.printer = new DafnyConsolePrinter(); // For boogie errors DafnyOptions.Install(new DafnyOptions(reporter)); ExitValue exitValue = ExitValue.VERIFIED; CommandLineOptions.Clo.RunningBoogieFromCommandLine = true; if (!CommandLineOptions.Clo.Parse(args)) { exitValue = ExitValue.PREPROCESSING_ERROR; goto END; } //CommandLineOptions.Clo.Files = new List<string> { @"C:\dafny\Test\dafny0\Trait\TraitExtend.dfy" }; if (CommandLineOptions.Clo.Files.Count == 0) { ExecutionEngine.printer.ErrorWriteLine(Console.Out, "*** Error: No input files were specified."); exitValue = ExitValue.PREPROCESSING_ERROR; goto END; } if (CommandLineOptions.Clo.XmlSink != null) { string errMsg = CommandLineOptions.Clo.XmlSink.Open(); if (errMsg != null) { ExecutionEngine.printer.ErrorWriteLine(Console.Out, "*** Error: " + errMsg); exitValue = ExitValue.PREPROCESSING_ERROR; goto END; } } if (!CommandLineOptions.Clo.DontShowLogo) { Console.WriteLine(CommandLineOptions.Clo.Version); } if (CommandLineOptions.Clo.ShowEnv == CommandLineOptions.ShowEnvironment.Always) { Console.WriteLine("---Command arguments"); foreach (string arg in args) { Contract.Assert(arg != null); Console.WriteLine(arg); } Console.WriteLine("--------------------"); } var dafnyFiles = new List <string>(); var otherFiles = new List <string>(); foreach (string file in CommandLineOptions.Clo.Files) { Contract.Assert(file != null); string extension = Path.GetExtension(file); if (extension != null) { extension = extension.ToLower(); } if (extension == ".dfy" || extension == ".tacny") { dafnyFiles.Add(file); } else if ((extension == ".cs") || (extension == ".dll")) { otherFiles.Add(file); } else { ExecutionEngine.printer.ErrorWriteLine(Console.Out, "*** Error: '{0}': Filename extension '{1}' is not supported. Input files must be Dafny programs (.dfy) or C# files (.cs) or managed DLLS (.dll)", file, extension == null ? "" : extension); exitValue = ExitValue.PREPROCESSING_ERROR; goto END; } } exitValue = ProcessFiles(dafnyFiles, otherFiles.AsReadOnly(), reporter); END: if (CommandLineOptions.Clo.XmlSink != null) { CommandLineOptions.Clo.XmlSink.Close(); } if (CommandLineOptions.Clo.Wait) { Console.WriteLine("Press Enter to exit."); Console.ReadLine(); } if (!DafnyOptions.O.CountVerificationErrors && exitValue != ExitValue.PREPROCESSING_ERROR) { return(0); } //Console.ReadKey(); return((int)exitValue); }
public static int ThreadMain(string[] args) { Contract.Requires(cce.NonNullElements(args)); ErrorReporter reporter = new ConsoleErrorReporter(); ExecutionEngine.printer = new DafnyConsolePrinter(); // For boogie errors DafnyOptions.Install(new DafnyOptions(reporter)); ExitValue exitValue = ExitValue.VERIFIED; CommandLineOptions.Clo.RunningBoogieFromCommandLine = true; if (!CommandLineOptions.Clo.Parse(args)) { exitValue = ExitValue.PREPROCESSING_ERROR; goto END; } //CommandLineOptions.Clo.Files = new List<string> { @"C:\dafny\Test\dafny0\Trait\TraitExtend.dfy" }; if (CommandLineOptions.Clo.Files.Count == 0) { ExecutionEngine.printer.ErrorWriteLine(Console.Out, "*** Error: No input files were specified."); exitValue = ExitValue.PREPROCESSING_ERROR; goto END; } if (CommandLineOptions.Clo.XmlSink != null) { string errMsg = CommandLineOptions.Clo.XmlSink.Open(); if (errMsg != null) { ExecutionEngine.printer.ErrorWriteLine(Console.Out, "*** Error: " + errMsg); exitValue = ExitValue.PREPROCESSING_ERROR; goto END; } } if (!CommandLineOptions.Clo.DontShowLogo) { Console.WriteLine(CommandLineOptions.Clo.Version); } if (CommandLineOptions.Clo.ShowEnv == CommandLineOptions.ShowEnvironment.Always) { Console.WriteLine("---Command arguments"); foreach (string arg in args) {Contract.Assert(arg != null); Console.WriteLine(arg); } Console.WriteLine("--------------------"); } var dafnyFiles = new List<string>(); var otherFiles = new List<string>(); foreach (string file in CommandLineOptions.Clo.Files) { Contract.Assert(file != null); string extension = Path.GetExtension(file); if (extension != null) { extension = extension.ToLower(); } if (extension == ".dfy" || extension == ".tacny") { dafnyFiles.Add(file); } else if ((extension == ".cs") || (extension == ".dll")) { otherFiles.Add(file); } else { ExecutionEngine.printer.ErrorWriteLine(Console.Out, "*** Error: '{0}': Filename extension '{1}' is not supported. Input files must be Dafny programs (.dfy) or C# files (.cs) or managed DLLS (.dll)", file, extension == null ? "" : extension); exitValue = ExitValue.PREPROCESSING_ERROR; goto END; } } exitValue = ProcessFiles(dafnyFiles, otherFiles.AsReadOnly(), reporter); END: if (CommandLineOptions.Clo.XmlSink != null) { CommandLineOptions.Clo.XmlSink.Close(); } if (CommandLineOptions.Clo.Wait) { Console.WriteLine("Press Enter to exit."); Console.ReadLine(); } if (!DafnyOptions.O.CountVerificationErrors && exitValue != ExitValue.PREPROCESSING_ERROR) { return 0; } //Console.ReadKey(); return (int)exitValue; }