/// <summary>
        /// The save.
        /// </summary>
        /// <param name="operator">
        /// The operator.
        /// </param>
        private void Save(LogicalExpression.Operator @operator)
        {
            var operatorString = string.Empty;

            switch (@operator)
            {
                case LogicalExpression.Operator.And:
                    operatorString = "&";
                    break;
                case LogicalExpression.Operator.Or:
                    operatorString = "|";
                    break;
                case LogicalExpression.Operator.Xor:
                    operatorString = "^";
                    break;
                default:
                    break;
            }

            this.cppWriter.Write(' ');
            this.cppWriter.Write(operatorString);
            this.cppWriter.Write(' ');
        }
        /// <summary>
        /// Reads a logical expression.
        /// </summary>
        /// <param name="leftHandSide">
        /// The expression on the left hand side of the operator.
        /// </param>
        /// <param name="previousPrecedence">
        /// The precedence of the expression just before this one.
        /// </param>
        /// <param name="parentReference">
        /// The parent code part.
        /// </param>
        /// <param name="unsafeCode">
        /// Indicates whether the code being parsed resides in an unsafe code block.
        /// </param>
        /// <returns>
        /// Returns the expression.
        /// </returns>
        private LogicalExpression GetLogicalExpression(
            Expression leftHandSide, ExpressionPrecedence previousPrecedence, Reference<ICodePart> parentReference, bool unsafeCode)
        {
            Param.AssertNotNull(leftHandSide, "leftHandSide");
            Param.Ignore(previousPrecedence);
            Param.AssertNotNull(parentReference, "parentReference");
            Param.Ignore(unsafeCode);

            LogicalExpression expression = null;
            Reference<ICodePart> expressionReference = new Reference<ICodePart>();

            // Read the details of the expression.
            OperatorSymbol operatorToken = this.PeekOperatorToken(parentReference, expressionReference);
            Debug.Assert(operatorToken.Category == OperatorCategory.Logical, "Expected a logical operator");

            // Check the precedence of the operators to make sure we can gather this statement now.
            ExpressionPrecedence precedence = GetOperatorPrecedence(operatorToken.SymbolType);
            if (CheckPrecedence(previousPrecedence, precedence))
            {
                // Add the operator token to the document and advance the symbol manager up to it.
                this.symbols.Advance();
                this.tokens.Add(operatorToken);

                // Get the expression on the right-hand side of the operator.
                Expression rightHandSide = this.GetOperatorRightHandExpression(precedence, expressionReference, unsafeCode);

                // Create the partial token list for the expression.
                CsTokenList partialTokens = new CsTokenList(this.tokens, leftHandSide.Tokens.First, this.tokens.Last);

                // Get the expression operator type.
                LogicalExpression.Operator type;
                switch (operatorToken.SymbolType)
                {
                    case OperatorType.LogicalAnd:
                        type = LogicalExpression.Operator.And;
                        break;

                    case OperatorType.LogicalOr:
                        type = LogicalExpression.Operator.Or;
                        break;

                    case OperatorType.LogicalXor:
                        type = LogicalExpression.Operator.Xor;
                        break;

                    default:
                        Debug.Fail("Unexpected operator type");
                        throw new InvalidOperationException();
                }

                // Create and return the expression.
                expression = new LogicalExpression(partialTokens, type, leftHandSide, rightHandSide);
                expressionReference.Target = expression;
            }

            return expression;
        }
 /// <summary>
 /// The save.
 /// </summary>
 /// <param name="logicalExpression">
 /// The logical expression.
 /// </param>
 private void Save(LogicalExpression logicalExpression)
 {
     @switch(logicalExpression.LeftHandSide);
     this.Save(logicalExpression.OperatorType);
     @switch(logicalExpression.RightHandSide);
 }