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 SymPreProcessorWorkerConditionalExpression(SymParserWorkerContext aContext) : base(aContext) { System.Diagnostics.Debug.Assert(aContext.Document.CurrentNode is SymNodeConditionalExpression); // Inform the parser about the conditional expression node. It will use this // as a means of identifying whether to skip tokens until a positive branch is identified. SymPreProcessorParser parser = (SymPreProcessorParser)aContext.Parser; parser.ConditionalExpressionPush(aContext.Document.CurrentNode as SymNodeConditionalExpression); }