コード例 #1
0
        public bool Read()
        {
            if (0 == _workers.Count)
            {
                return(false);
            }
            _workerIndex = (_workerIndex + 1) % _workers.Count;
            _worker      = _workers[_workerIndex];
            while (!_worker.Read())
            {
                _workers.RemoveAt(_workerIndex);
                if (_workerIndex == _workers.Count)
                {
                    _workerIndex = 0;
                }
                if (0 == _workers.Count)
                {
                    return(false);
                }
                _worker = _workers[_workerIndex];
            }
            var min = int.MaxValue;
            var ic  = _workers.Count;

            for (var i = 0; i < ic; ++i)
            {
                GlrWorker w = _workers[i];
                if (0 < i && w.ErrorCount > _maxErrorCount)
                {
                    _workers.RemoveAt(i);
                    --i;
                    --ic;
                }
                if (min > w.Index)
                {
                    min = w.Index;
                }
                if (0 == min)
                {
                    i = ic;                     // break
                }
            }
            var j = min;

            while (j > 0)
            {
                _tokenEnum.MoveNext();
                --j;
            }
            for (j = 0; j < ic; ++j)
            {
                GlrWorker w = _workers[j];
                w.Index -= min;
            }

            return(true);
        }
コード例 #2
0
 public GlrWorker(GlrTableParser outer, GlrWorker worker, int tupleIndex)
 {
     _Outer          = outer;
     _parseTable     = worker._parseTable;
     _errorId        = worker._errorId;
     _eosId          = worker._eosId;
     _errorSentinels = worker._errorSentinels;
     ErrorTokens     = new Queue <Token>(worker.ErrorTokens);
     _tokenEnum      = worker._tokenEnum;
     _stack          = new List <int>(worker._stack.Count);
     _stack.AddRange(worker._stack);
     Index        = worker.Index;
     _tupleIndex  = tupleIndex;
     NodeType     = worker.NodeType;
     Id           = outer.NextWorkerId;
     CurrentToken = worker.CurrentToken;
     ++outer.NextWorkerId;
     _continuation = true;
     _workers      = worker._workers;
 }