Пример #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);
            }
        }