示例#1
0
        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
        }
示例#2
0
        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
        }
示例#3
0
        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
        }
示例#4
0
 private void ReadToken()
 {
     TokensProcessed.Push(TokensToProcess.Pop());
 }
示例#5
0
 private string PeekRawValue() // to be displayed in error messages, e.g. instead of converted 0.1 gets raw .1
 {
     return(TokensToProcess.Peek().RawValue);
 }
示例#6
0
 private object PeekValue()
 {
     return(TokensToProcess.Peek().Value);
 }
示例#7
0
 private TokenType PeekType()
 {
     return(TokensToProcess.Peek().Type);
 }