public abstract void Visit(BinaryExpression expression);
private Expression ParseMultiplicativeBinary() { Expression expr = ParseRelationalBinary(); while (!_scanner.IsEof() && (_current.Type == TokenType.Multiply || _current.Type == TokenType.Divide || _current.Type == TokenType.Modulo)) { var binaryMulDiv = new BinaryExpression { Operator = ((PunctuatorToken)_current).ToOperatorType(), Left = expr }; Expect(MiddleGroupMultiplicative); binaryMulDiv.Right = ParseRelationalBinary(); expr = binaryMulDiv; } return expr; }
private Expression ParseRelationalBinary() { Expression expr = ParseIdentifier(); while (!_scanner.IsEof() && (_current.Type == TokenType.Equality || _current.Type == TokenType.Inequality || _current.Type == TokenType.LessThan || _current.Type == TokenType.GreaterThan || _current.Type == TokenType.LessThanOrEqual || _current.Type == TokenType.GreaterThanOrEqual)) { var binaryExp = new BinaryExpression { Operator = ((PunctuatorToken) _current).ToOperatorType(), Left = expr }; Expect(MiddleGroupAdditiveRelational); binaryExp.Right = ParseIdentifier(); expr = binaryExp; } return expr; }
private Expression ParseAdditiveBinary() { Expression expr = ParseMultiplicativeBinary(); while (!_scanner.IsEof() && (_current.Type == TokenType.Plus || _current.Type == TokenType.Minus)) { var binaryAddSub = new BinaryExpression { Operator = ((PunctuatorToken)_current).ToOperatorType(), Left = expr }; Expect(MiddleGroupAdditiveRelational); binaryAddSub.Right = ParseMultiplicativeBinary(); expr = binaryAddSub; } return expr; }