public SymPreProcessorWorkerEndif(SymParserWorkerContext aContext)
            : base(aContext)
        {
            // When the endif token is reached, we must work back up the tree
            // looking for the previous (i.e. most recent) conditional expression
            // node.
            SymNodeConditionalExpression condExpNode = SymParserWorkerConditionalExpression.FindMostRecentConditionalExpression(aContext.Document.CurrentNode);

            if (condExpNode == null)
            {
                throw new Exception("Unable to locate most recent condition expression during ENDIF handling");
            }

            // There must always be a positive condition node and some kind of condition
            if (condExpNode.ChildTypeExists(typeof(SymNodeCondition)) == false)
            {
                throw new Exception("No child condition node found during ENDIF handling");
            }

            // We change the current node to be the parent of the conditional expression.
            // Any new tokens will appear as siblings
            aContext.Document.CurrentNode = condExpNode.Parent;

            // Make sure we tell the parser that it can pop off this conditional expression node.
            SymPreProcessorParser        parser           = (SymPreProcessorParser)aContext.Parser;
            SymNodeConditionalExpression poppedExpression = parser.ConditionalExpressionPop();

            System.Diagnostics.Debug.Assert(poppedExpression == condExpNode);

            // Job done - dequeue
            RemoveSelf();
        }
        public SymPreProcessorWorkerElseIf(SymParserWorkerContext aContext)
            : base(aContext)
        {
            // When the else token is reached, we must work back up the tree
            // looking for the previous (i.e. most recent) conditional expression
            // node.
            SymNodeConditionalExpression condExpNode = SymParserWorkerConditionalExpression.FindMostRecentConditionalExpression(aContext.Document.CurrentNode);

            if (condExpNode == null)
            {
                throw new Exception("Unable to locate most recent condition expression during ELSE IF handling");
            }

            // There must always be a positive condition node and some kind of condition
            if (condExpNode.ChildTypeExists(typeof(SymNodeCondition)) == false)
            {
                throw new Exception("No child condition node found during ELSE IF handling");
            }

            // Make the conditional expression the current node
            aContext.Document.CurrentNode = condExpNode;

            // Make a new condition worker. The condition worker creates a new condition node
            // which becomes the new current node.
            SymParserWorkerContext   context         = new SymParserWorkerContext(aContext.Document.Context, this);
            SymParserWorkerCondition conditionWorker = new SymParserWorkerCondition(context, new SymNodePreProcessorCondition(aContext.CurrentToken.Value));

            AddChild(conditionWorker);
        }
        public void MakeConditionalArgumentCurrent(SymParserDocument aDocument)
        {
            SymNodeConditionalExpression condExpNode = SymParserWorkerConditionalExpression.FindMostRecentConditionalExpression(this);

            if (condExpNode == null)
            {
                throw new Exception("Unable to locate conditional expression. Document is corrupt");
            }

            aDocument.CurrentNode = condExpNode;
        }