Beispiel #1
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);
        }
Beispiel #2
0
        public override SymParserWorker.TTokenConsumptionType OfferToken(SymToken aToken)
        {
            // Offer the token to the base class first. If it doesn't want it, we'll
            // check it.
            TTokenConsumptionType ret = base.OfferToken(aToken);

            if (ret == TTokenConsumptionType.ETokenNotConsumed)
            {
                if (aToken.Class != SymToken.TClass.EClassComment)
                {
                    // Try to find a new child worker to handle this kind
                    // of data.
                    SymParserWorker worker = CreateWorkerByTokenType(aToken);
                    if (worker != null)
                    {
                        System.Diagnostics.Debug.WriteLine("SymWorkerBuildFileMain.OfferToken() - FOUND HANDLER FOR: " + aToken.Value);

                        AddChild(worker);
                        ret = TTokenConsumptionType.ETokenConsumed;
                    }
                }
            }
            //
            return(ret);
        }
Beispiel #3
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);
        }
Beispiel #4
0
        public override SymParserWorker.TTokenConsumptionType OfferToken(SymToken aToken)
        {
            TTokenConsumptionType ret = TTokenConsumptionType.ETokenNotConsumed;

            #region Identify preprocessor tokens
            if (aToken.Class == SymToken.TClass.EClassPreProcessor)
            {
                if (ChildCount == 0)
                {
                    if (aToken.Value == "#")
                    {
                        // Always consume initial preprocessor tokens...
                        ret = TTokenConsumptionType.ETokenConsumed;
                    }
                    else
                    {
                        // Try to find a new child worker to handle this kind
                        // of data.
                        SymParserWorker worker = CreateWorkerByTokenType(aToken);
                        //
                        if (worker != null)
                        {
                            System.Diagnostics.Debug.WriteLine("SymPreProcessorWorker.OfferToken() - FOUND HANDLER FOR: " + aToken.Value);

                            AddChild(worker);
                            ret = TTokenConsumptionType.ETokenConsumed;
                        }
                    }
                }
            }
            #endregion

            // Give it to the children
            if (ret == TTokenConsumptionType.ETokenNotConsumed)
            {
                // Check whether we're inside a conditional expression skip state.
                bool allowedToOffer = Parser.ConditionalExpressionValue;
                if (allowedToOffer)
                {
                    ret = base.OfferToken(aToken);
                }
            }
            //
            return(ret);
        }
 public override void RemoveChild(SymParserWorker aWorker)
 {
     base.RemoveChild(aWorker);
     RemoveSelf();
 }