예제 #1
0
        public ParseResult Run([NotNull] string code, [CanBeNull] string gold)
        {
            if (_parserHost == null)
            {
                _parserHost       = new ParserHost();
                _compositeGrammar = _parserHost.MakeCompositeGrammar(SynatxModules);
            }
            var source = new SourceSnapshot(code);

            if (StartRule == null)
            {
                return(null);
            }

            var timer = System.Diagnostics.Stopwatch.StartNew();

            try
            {
                var res = _parserHost.DoParsing(source, _compositeGrammar, StartRule);
                this.Exception = null;
                this.TestTime  = timer.Elapsed;
                return(res);
            }
            catch (Exception ex)
            {
                this.Exception = ex;
                this.TestTime  = timer.Elapsed;
                return(null);
            }
        }
예제 #2
0
        public ParseResult Run([NotNull] string code, [CanBeNull] string gold, RecoveryStrategy recoveryStrategy)
        {
            if (_parserHost == null)
            {
                _parserHost       = new ParserHost();
                _compositeGrammar = _parserHost.MakeCompositeGrammar(SynatxModules);
            }
            var source = new SourceSnapshot(code);

            if (StartRule == null)
            {
                return(null);
            }

            try
            {
                var res = _parserHost.DoParsing(source, _compositeGrammar, StartRule, recoveryStrategy);
                this.Exception = null;
                return(res);
            }
            catch (Exception ex)
            {
                this.Exception = ex;
                return(null);
            }
        }
예제 #3
0
파일: TestSuitVm.cs 프로젝트: hwwang/Nitra
        public ParseResult Run([NotNull] string code, [CanBeNull] string gold, RecoveryStrategy recoveryStrategy)
        {
            if (_parserHost == null)
              {
            _parserHost = new ParserHost();
            _compositeGrammar = _parserHost.MakeCompositeGrammar(SynatxModules);
              }
              var source = new SourceSnapshot(code);

              if (StartRule == null)
            return null;

              try
              {
            var res = _parserHost.DoParsing(source, _compositeGrammar, StartRule, recoveryStrategy);
            this.Exception = null;
            return res;
              }
              catch (Exception ex)
              {
            this.Exception = ex;
            return null;
              }
        }
예제 #4
0
파일: TestSuitVm.cs 프로젝트: lhsail/Nitra
        public ParseResult Run([NotNull] string code, [CanBeNull] string gold)
        {
            if (_parserHost == null)
              {
            _parserHost = new ParserHost();
            _compositeGrammar = _parserHost.MakeCompositeGrammar(SynatxModules);
              }
              var source = new SourceSnapshot(code);

              if (StartRule == null)
            return null;

              var timer = System.Diagnostics.Stopwatch.StartNew();
              try
              {
            var res = _parserHost.DoParsing(source, _compositeGrammar, StartRule, parseToEndOfString: true);
            this.Exception = null;
            this.TestTime = timer.Elapsed;
            return res;
              }
              catch (Exception ex)
              {
            this.Exception = ex;
            this.TestTime = timer.Elapsed;
            return null;
              }
        }