示例#1
0
        private List <SyntaxNode> ReadExpressionOperands(SyntaxNode firstTerm)
        {
            List <SyntaxNode> operands = new List <SyntaxNode> {
                firstTerm
            };

            while (NextTokenIsATermOperator())
            {
                tokens.AssertCanRead();
                tokens.AssertPeekIsTypeOfOne(SyntaxTreeConstants.TermOperatorTypes);

                AddToExpressionOperands(tokens.Next(), operands);
            }
            return(operands);
        }
示例#2
0
        public void AssertPeekIsTypeOfOne_AdditionToken_ThrowsException()
        {
            Tokens tokens = new Tokens(new List <Token> {
                new Token(TokenType.Addition)
            });

            Assert.Throws <UnexpectedTokenException>(() => tokens.AssertPeekIsTypeOfOne(
                                                         new List <TokenType> {
                TokenType.Subtraction
            }
                                                         ));
        }