Exemplo n.º 1
0
        public void AssertPeekIsTypeOf_AdditionToken_ThrowsException()
        {
            Tokens tokens = new Tokens(new List <Token> {
                new Token(TokenType.Addition)
            });

            Assert.Throws <UnexpectedTokenException>(() => tokens.AssertPeekIsTypeOf(TokenType.Subtraction));
        }
Exemplo n.º 2
0
        private List <SyntaxNode> ReadFactorOperands(SyntaxNode firstTerm)
        {
            List <SyntaxNode> operands = new List <SyntaxNode> {
                firstTerm
            };

            while (NextTokenIsExponentOperator())
            {
                tokens.AssertCanRead();
                tokens.AssertPeekIsTypeOf(TokenType.Exponent);
                tokens.Next();

                operands.Add(ReadFormal());
            }
            return(operands);
        }