コード例 #1
0
 /// <summary>
 /// Consumes an expected Token
 /// </summary>
 /// <param name="type">Type of the expected Token</param>
 /// <exception cref="UnexpectedTokenException">Thrown when the next Token is not the expected Token</exception>
 public void Expect(Token.EType type)
 {
     if (_nextToken.Type != type)
     {
         throw new UnexpectedTokenException($"{_nextToken.Type}", $"{type}");
     }
     Advance();
 }
コード例 #2
0
        private Token GetToken(Token.EType tokenType, char?expectedChar = null)
        {
            if (expectedChar.HasValue)
            {
                Expect(expectedChar.Value);
            }

            return(new Token(tokenType));
        }