Esempio n. 1
0
        protected virtual void PerformEndLevelBehaviour(SymNode aLevel, SymTokenBalancerMatchCriteria aCriteria)
        {
            #region Example step (11a) from LevelFinished method
            //
            // We then add the closing bracket to level |1| which means
            // that we can attempt to simplify level |2| entirely. This is the
            // situation prior to simplification.
            //
            //  |0|                                 [ROOT]
            //                                         |
            //  |1|                  [TEST]   [(]     [@] [)]
            //                                         |
            //  |2|             [(] [*] [)]           [+] [(] [*] [)]
            //                       |                         |
            //  |3|     [ ] [B] [ ] [+] [ ] [C] [ ]           [E]
            //
            // aLevel would be the @ node at level |1|.
            //
            // We remove redundant bracketing from our children, i.e. those on level |2|, not from our own level.
            // Our parent takes care of removing this level's redundant bracketing (when it's level is completed)
            // or then when an argument separator token is handled.
            //
            // We must iterate through level |1|'s children to find other level nodes. We check whether each
            // child level node can be simplified by checking its children (i.e. our grandchildren).
            //
            #endregion

            if (aCriteria.IsAssociatedBehaviourRemoveRedundantBracketing)
            {
                int    index = 0;
                object childLevelNodeObject = aLevel.ChildByType(typeof(SymTokenBalancerMarkerLevelNode), ref index);
                while (childLevelNodeObject != null)
                {
                    SymTokenBalancerMarkerLevelNode childLevelNode = (SymTokenBalancerMarkerLevelNode)childLevelNodeObject;
                    if (childLevelNode.CanBeSubsumed)
                    {
                        childLevelNode.Subsume();
                    }

                    // Try to find next level node
                    ++index;
                    childLevelNodeObject = aLevel.ChildByType(typeof(SymTokenBalancerMarkerLevelNode), ref index);
                }
            }
        }
        public virtual SymArgument MakeArgument()
        {
            SymNode levelNodeToObtainArgumentsFrom = CurrentNode;

            // Try to work out whether we have a leve node at the current
            // scope which should be preferred t
            object levelNodeObject = levelNodeToObtainArgumentsFrom.ChildByType(typeof(SymTokenBalancerMarkerLevelNode));

            if (levelNodeObject != null)
            {
                levelNodeToObtainArgumentsFrom = (SymNode)levelNodeObject;
            }

            return(MakeArgument(levelNodeToObtainArgumentsFrom));
        }