Exemplo n.º 1
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);
        }
Exemplo n.º 2
0
        public override SymParserWorker.TTokenConsumptionType OfferToken(SymToken aToken)
        {
            TTokenConsumptionType ret = TTokenConsumptionType.ETokenNotConsumed;

            System.Diagnostics.Debug.Assert(WorkerContext.Document.CurrentNode is SymNodePreProcessorInclude);

            // Only consume tokens whilst we're unsure of the include type (system vs user).
            if (iIncludeNode.IncludeDefinition.Type == SymIncludeDefinition.TType.ETypeUndefined)
            {
                if (aToken.Class == SymToken.TClass.EClassQuotation)
                {
                    // Must be a user include if its a quotation that we're handling
                    iIncludeNode.IncludeDefinition.Type = SymIncludeDefinition.TType.ETypeUser;
                    ret = TTokenConsumptionType.ETokenConsumed;
                }
                else if (aToken.Class == SymToken.TClass.EClassSymbol && aToken.Value == "<")
                {
                    // Consume it, but don't absorb it
                    iIncludeNode.IncludeDefinition.Type = SymIncludeDefinition.TType.ETypeSystem;
                    ret = TTokenConsumptionType.ETokenConsumed;
                }
            }
            else if (iIncludeNode.IncludeDefinition.Type != SymIncludeDefinition.TType.ETypeUndefined)
            {
                // Only consume the tokens whilst we've not yet identified the include
                // definition location.
                if (iIncludeNode.IncludeDefinition.Location.Length == 0)
                {
                    if (iIncludeNode.IncludeDefinition.Type == SymIncludeDefinition.TType.ETypeSystem && aToken.Class == SymToken.TClass.EClassSymbol && aToken.Value == ">")
                    {
                        iIncludeNode.IncludeDefinition.Location = iWorkingIncludePath.ToString();
                    }
                    else if (iIncludeNode.IncludeDefinition.Type == SymIncludeDefinition.TType.ETypeUser && aToken.Class == SymToken.TClass.EClassQuotation && aToken.Type != SymToken.TType.ETypeUnidentified)
                    {
                        iIncludeNode.IncludeDefinition.Location = iWorkingIncludePath.ToString();
                    }
                    else
                    {
                        iWorkingIncludePath.Append(aToken.Value);
                    }
                }
            }

            // Base class will dequeue us once we reach the new line
            ret = base.OfferToken(aToken);
            return(ret);
        }
Exemplo n.º 3
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 SymParserWorker.TTokenConsumptionType OfferToken(SymToken aToken)
        {
            System.Diagnostics.Debug.Assert(WorkerContext.Document.CurrentNode is SymNodeCondition);
            //
            TTokenConsumptionType ret = TTokenConsumptionType.ETokenNotConsumed;

            if (aToken.Class != SymToken.TClass.EClassNewLine)
            {
                if (iTokenBalancer.OfferToken(aToken))
                {
                    ret = TTokenConsumptionType.ETokenConsumed;
                }
            }

            // Try offering to base class....
            // Base class will dequeue us once we reach the new line
            if (ret != TTokenConsumptionType.ETokenConsumed)
            {
                ret = base.OfferToken(aToken);
            }

            return(ret);
        }