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();
        }
Ejemplo n.º 2
0
        private SymParserWorker CreateWorkerByTokenType(SymToken aToken)
        {
            // Find a worker to handle the token type
            SymParserWorkerContext context = new SymParserWorkerContext(WorkerContext.Document.Context, this, aToken);
            //
            SymParserWorker worker = null;

            switch (aToken.Value.ToLower())
            {
            // Simple preprocessor operations
            case "prj_platforms":
                break;

            case "prj_exports":
                break;

            case "prj_testexports":
                break;

            case "prj_mmpfiles":
                break;

            case "prj_testmmpfiles":
                break;

            // Skip unhandled preprocessor directives
            default:
                break;
            }
            //
            return(worker);
        }
        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);
        }
Ejemplo n.º 4
0
 public SymPreProcessorWorkerInclude(SymParserWorkerContext aContext)
     : base(aContext, SymToken.TClass.EClassNewLine, SymParserWorkerConsumer.TDyingAction.EWhenDyingMakeAbsoluteParentNodeCurrent)
 {
     // Make a new child node for the include
     iIncludeNode = new SymNodePreProcessorInclude();
     aContext.Document.CurrentNode.Add(iIncludeNode);
     aContext.Document.CurrentNode = iIncludeNode;
 }
Ejemplo n.º 5
0
        protected override void PrepareInitialWorkers()
        {
            SymParserWorkerContext context    = new SymParserWorkerContext(Document.Context);
            SymWorkerBuildFileMain mainWorker = new SymWorkerBuildFileMain(context);

            //
            QueueWorker(mainWorker);

            // Make a base call
            base.PrepareInitialWorkers();
        }
Ejemplo n.º 6
0
        public SymPreProcessorWorkerIfndef(SymParserWorkerContext aContext)
            : base(aContext)
        {
            // The base class will make a new conditional expression node at the current document position.
            // It will change the parent node to be this new node. We must make a new condition worker
            // that will handle reading the condition arguments.
            SymParserWorkerContext   context         = new SymParserWorkerContext(WorkerContext.Document.Context, this);
            SymParserWorkerCondition conditionWorker = new SymParserWorkerCondition(context, new SymNodePreProcessorCondition(aContext.CurrentToken.Value));

            AddChild(conditionWorker);
        }
        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);
        }
Ejemplo n.º 8
0
        private SymParserWorker CreateWorkerByTokenType(SymToken aToken)
        {
            // Find a worker to handle the token type
            SymParserWorker        worker  = null;
            SymParserWorkerContext context = new SymParserWorkerContext(WorkerContext, this, aToken);

            //
            switch (aToken.Value)
            {
            // Simple preprocessor operations
            case "define":
                worker = new SymPreProcessorWorkerDefine(context);
                break;

            case "undef":
                break;

            case "include":
                worker = new SymPreProcessorWorkerInclude(context);
                break;

            // Conditionality
            case "if":
                worker = new SymPreProcessorWorkerIf(context);
                break;

            case "ifdef":
                worker = new SymPreProcessorWorkerIfdef(context);
                break;

            case "ifndef":
                worker = new SymPreProcessorWorkerIfndef(context);
                break;

            case "else":
                worker = new SymPreProcessorWorkerElse(context);
                break;

            case "elif":
                worker = new SymPreProcessorWorkerElseIf(context);
                break;

            case "endif":
                worker = new SymPreProcessorWorkerEndif(context);
                break;

            // Skip unhandled preprocessor directives
            default:
                worker = new SymParserWorkerConsumer(context, SymToken.TClass.EClassNewLine);
                break;
            }
            //
            return(worker);
        }
        protected override void PrepareInitialWorkers()
        {
            SymParserWorkerContext context = new SymParserWorkerContext(Document.Context);

            iMainWorker = new SymPreProcessorWorker(context);
            //
            QueueWorker(iMainWorker);

            // Make a base call
            base.PrepareInitialWorkers();
        }
        public SymPreProcessorWorkerDefine(SymParserWorkerContext aContext)
            : base(aContext, SymToken.TClass.EClassNewLine)
        {
            iFunctionParser.RegisterFunctionParserTokens();

            // Set up event handlers
            iFunctionParser.EventArgumentAvailableHandler += new SymBuildParsingLib.Parser.Framework.Utils.SymFunctionParser.ArgumentAvailable(FunctionParserEventArgumentAvailableHandler);
            iFunctionParser.EventLevelStarted             += new SymBuildParsingLib.Token.SymTokenBalancer.LevelChangeEventHandler(TokenBalancerEventLevelStarted);
            iFunctionParser.EventLevelFinished            += new SymBuildParsingLib.Token.SymTokenBalancer.LevelChangeEventHandler(TokenBalancerEventLevelFinished);
            iFunctionParser.EventLevelsBalanced           += new SymBuildParsingLib.Token.SymTokenBalancer.LevelsBalancedEventHandler(TokenBalancerEventLevelsBalanced);
            iFunctionParser.EventLevelsImbalanced         += new SymBuildParsingLib.Token.SymTokenBalancer.LevelsImbalancedEventHandler(TokenBalancerEventLevelsImbalanced);
        }
Ejemplo n.º 11
0
 public SymWorkerBuildFileMain(SymParserWorkerContext aContext)
     : base(aContext)
 {
 }
 public SymWorkerBuildFilePlatforms(SymParserWorkerContext aContext)
     : base(aContext, SymToken.TClass.EClassNewLine)
 {
 }
Ejemplo n.º 13
0
 public SymPreProcessorWorker(SymParserWorkerContext aContext)
     : base(aContext, 1000)
 {
 }