コード例 #1
0
        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);
        }
コード例 #2
0
ファイル: DafnyDriver.cs プロジェクト: mnsamad/dafny-1
        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);
        }
コード例 #3
0
ファイル: DafnyDriver.cs プロジェクト: ggrov/tacny
        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);
        }