コード例 #1
0
        public GlrTableParser(int[][][][] parseTable, string[] symbolTable, ParseAttribute[][] attributes, int[] errorSentinels, IEnumerable <Token> tokenizer, int maxErrorCount)
        {
            _parseTable  = parseTable;
            _symbolTable = symbolTable;

            _attributes     = attributes;
            _errorSentinels = errorSentinels;
            _eosId          = Array.IndexOf(symbolTable, "#EOS");
            if (0 > _eosId)
            {
                throw new ArgumentException("Error in symbol table", "symbolTable");
            }
            _errorId = Array.IndexOf(symbolTable, "#ERROR");
            if (0 > _errorId)
            {
                throw new ArgumentException("Error in symbol table", "symbolTable");
            }
            _tokenEnum     = new LookAheadEnumerator(tokenizer.GetEnumerator());
            _maxErrorCount = maxErrorCount;
            NextWorkerId   = 1;
            _workerIndex   = 0;
            _workers       = new List <GlrWorker>(8);
            if (_tokenEnum.MoveNext())
            {
                _workers.Add(new GlrWorker(this, NextWorkerId, _parseTable, _errorId, _eosId, _errorSentinels, _workers, _tokenEnum));
                ++NextWorkerId;
            }
        }
コード例 #2
0
 public LookAheadEnumeratorEnumerator(LookAheadEnumerator outer)
 {
     this._outer = outer;
     if (this._outer.IsEnumerating)
     {
         this._current = this._outer.Current;
     }
     this._index = _NotStarted;
 }
コード例 #3
0
 public GlrWorker(GlrTableParser outer, int id, int[][][][] parseTable, int errorId, int eosId, int[] errorSentinels, IList <GlrWorker> workers, LookAheadEnumerator tokenEnum)
 {
     _Outer          = outer;
     Id              = id;
     _parseTable     = parseTable;
     _errorId        = errorId;
     _eosId          = eosId;
     _tokenEnum      = tokenEnum;
     _stack          = new List <int>();
     Index           = 0;
     _tupleIndex     = 0;
     _workers        = workers;
     _errorSentinels = errorSentinels;
     ErrorTokens     = new Queue <Token>();
     _continuation   = false;
     NodeType        = LRNodeType.Initial;
 }
コード例 #4
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;
 }
コード例 #5
0
 public LookAheadEnumeratorEnumerable(LookAheadEnumerator outer)
 {
     this._outer = outer;
 }