Exemple #1
0
        bool ParseAndTypeCheck()
        {
            Dafny.ModuleDecl module      = new Dafny.LiteralModuleDecl(new Dafny.DefaultModuleDecl(), null);
            Dafny.BuiltIns   builtIns    = new Dafny.BuiltIns();
            Dafny.Errors     parseErrors = new VSErrors(this);
            int    errorCount            = Dafny.Parser.Parse(_snapshot.GetText(), _filename, module, builtIns, parseErrors);
            string errString             = Dafny.Main.ParseIncludes(module, builtIns, new List <string>(), parseErrors);

            if (errorCount != 0 || errString != null)
            {
                return(false);
            }
            Dafny.Program program = new Dafny.Program(_filename, module, builtIns);

            var r = new VSResolver(program, this);

            r.ResolveProgram(program);
            if (r.ErrorCount != 0)
            {
                return(false);
            }

            program.AdditionalInformation.AddRange(r.AdditionalInformation);
            _program = program;
            return(true); // success
        }
Exemple #2
0
        bool ParseAndTypeCheck(bool runResolver)
        {
            Tuple <ITextSnapshot, Dafny.Program, List <DafnyError> > parseResult;

            Dafny.Program program;
            var           errorReporter = new VSErrorReporter(this);

            if (_buffer.Properties.TryGetProperty(bufferDafnyKey, out parseResult) &&
                (parseResult.Item1 == _snapshot))
            {
                // already parsed;
                program = parseResult.Item2;
                _errors = parseResult.Item3;
                if (program == null)
                {
                    runResolver = false;
                }
            }
            else
            {
                Dafny.ModuleDecl module   = new Dafny.LiteralModuleDecl(new Dafny.DefaultModuleDecl(), null);
                Dafny.BuiltIns   builtIns = new Dafny.BuiltIns();
                var parseErrors           = new Dafny.Errors(errorReporter);
                int errorCount            = Dafny.Parser.Parse(_snapshot.GetText(), _filename, _filename, null, module, builtIns, parseErrors);
                /* (_snapshot.GetText(), _filename, _filename, module, builtIns, parseErrors);*/
                string errString = Dafny.Main.ParseIncludes(module, builtIns, new List <string>(), parseErrors);

                if (errorCount != 0 || errString != null)
                {
                    runResolver = false;
                    program     = null;
                }
                else
                {
                    program = new Dafny.Program(_filename, module, builtIns, errorReporter);
                }
                _buffer.Properties[bufferDafnyKey] = new Tuple <ITextSnapshot, Dafny.Program, List <DafnyError> >(_snapshot, program, _errors);
            }
            if (!runResolver)
            {
                return(false);
            }
            program.Raw = _snapshot.GetText();
            var r = new Resolver(program);

            r.ResolveProgram(program);
            MostRecentResolver = r;
            if (errorReporter.Count(ErrorLevel.Error) != 0)
            {
                return(false);
            }

            _program = program;
            return(true); // success
        }
Exemple #3
0
    bool ParseAndTypeCheck() {
      Dafny.ModuleDecl module = new Dafny.LiteralModuleDecl(new Dafny.DefaultModuleDecl(), null);
      Dafny.BuiltIns builtIns = new Dafny.BuiltIns();
      Dafny.Errors parseErrors = new VSErrors(this);
      int errorCount = Dafny.Parser.Parse(_snapshot.GetText(), _filename, module, builtIns, parseErrors);
      string errString = Dafny.Main.ParseIncludes(module, builtIns, new List<string>(), parseErrors);
      if (errorCount != 0 || errString != null)
        return false;
      Dafny.Program program = new Dafny.Program(_filename, module, builtIns);

      var r = new VSResolver(program, this);
      r.ResolveProgram(program);
      if (r.ErrorCount != 0)
        return false;

      program.AdditionalInformation.AddRange(r.AdditionalInformation);
      _program = program;
      return true;  // success
    }
        bool ParseAndTypeCheck(bool runResolver)
        {
            Tuple<ITextSnapshot, Dafny.Program, List<DafnyError>> parseResult;
              Dafny.Program program;
              var errorReporter = new VSErrorReporter(this);
              if (_buffer.Properties.TryGetProperty(bufferDafnyKey, out parseResult) &&
             (parseResult.Item1 == _snapshot)) {
            // already parsed;
            program = parseResult.Item2;
            _errors = parseResult.Item3;
            if (program == null)
              runResolver = false;
              } else {
            Dafny.ModuleDecl module = new Dafny.LiteralModuleDecl(new Dafny.DefaultModuleDecl(), null);
            Dafny.BuiltIns builtIns = new Dafny.BuiltIns();
            var parseErrors = new Dafny.Errors(errorReporter);
            int errorCount = Dafny.Parser.Parse(_snapshot.GetText(), _filename, _filename, module, builtIns, parseErrors);
            string errString = Dafny.Main.ParseIncludes(module, builtIns, new List<string>(), parseErrors);

            if (errorCount != 0 || errString != null) {
              runResolver = false;
              program = null;
            } else {
              program = new Dafny.Program(_filename, module, builtIns, errorReporter);
            }
            _buffer.Properties[bufferDafnyKey] = new Tuple<ITextSnapshot, Dafny.Program, List<DafnyError>>(_snapshot, program, _errors);
              }
              if (!runResolver) {
            return false;
              }

              var r = new Resolver(program);
              r.ResolveProgram(program);
              if (errorReporter.Count(ErrorLevel.Error) != 0)
            return false;

              _program = program;
              return true;  // success
        }
Exemple #5
0
        bool ParseAndTypeCheck()
        {
            Dafny.ModuleDecl module = new Dafny.LiteralModuleDecl(new Dafny.DefaultModuleDecl(), null);
              Dafny.BuiltIns builtIns = new Dafny.BuiltIns();

              var errorReporter = new VSErrorReporter(this);
              var parseErrors = new Dafny.Errors(errorReporter);

              int errorCount = Dafny.Parser.Parse(_snapshot.GetText(), _filename, _filename, module, builtIns, parseErrors);
              string errString = Dafny.Main.ParseIncludes(module, builtIns, new List<string>(), parseErrors);
              if (errorCount != 0 || errString != null)
            return false;
              Dafny.Program program = new Dafny.Program(_filename, module, builtIns, errorReporter);

              var r = new Resolver(program);
              r.ResolveProgram(program);
              if (errorReporter.Count(ErrorLevel.Error) != 0)
            return false;

              _program = program;
              return true;  // success
        }