Exemplo n.º 1
0
        private Node ParseTerm(ITokenizer tokenizer)
        {
            var factor = ParseFactor(tokenizer);

            while ((tokenizer.CurrentToken & TokenType.IsMultiplicativeOperator) != TokenType.None)
            {
                factor = new BinaryNode(tokenizer.GetCurrentAndForward(), factor, ParseFactor(tokenizer));
            }

            return(factor);
        }
Exemplo n.º 2
0
        private Node ParseExpression(ITokenizer tokenizer)
        {
            var expression = ParseTerm(tokenizer);

            while ((tokenizer.CurrentToken & TokenType.IsAdditiveOperator) != TokenType.None)
            {
                expression = new BinaryNode(tokenizer.GetCurrentAndForward(), expression, ParseTerm(tokenizer));
            }

            return(expression);
        }