private Token PeekToken(int depth = 0) { Debug.Assert(depth >= 0); // depth can not be negative return(depth == 0 ? TokensToProcess.Peek() // for 0 depth take crrent context : TokensProcessed.Skip(depth - 1).First()); // otherwise dig through processed tokens }
private Token PeekToken(int depth = 0) { if (depth < 0) { throw new ArgumentOutOfRangeException("depth", "Depth can not be negative, surprisingly."); } return(depth == 0 ? TokensToProcess.Peek() // for 0 depth take crrent context : TokensProcessed.Skip(depth - 1).First()); // otherwise dig through processed tokens }
private ParseState PeekContext(int depth = 0) { if (depth < 0) { throw new ArgumentOutOfRangeException("depth", "Depth can not be negative, surprisingly."); } return(depth == 0 ? TokensToProcess.Peek().Context // for 0 depth take crrent context : TokensProcessed.Skip(depth - 1).Take(1).Single().Context); // otherwise dig through processed tokens }
private void ReadToken() { TokensProcessed.Push(TokensToProcess.Pop()); }