public List <string> Execute(ExoFilter exo)
        {
            var results = new List <string>();

            ProcessBranch(exo.RootEntry);
            return(results);

            void ProcessBranch(ExoBlock entry)
            {
                ProcessBlock(entry);
                foreach (var item in entry.Scopes)
                {
                    ProcessBranch(item);
                }
            }

            void ProcessBlock(ExoBlock entry)
            {
                results.AddRange(entry.Debug_GetSummary());
                results.AddRange(new List <string>());
            }
        }
Beispiel #2
0
        public List <FilterEntry> Execute(ExoFilter exoFilter)
        {
            List <FilterEntry> results = new List <FilterEntry>();

            ProcessTreeStep(exoFilter.RootEntry);

            // DO WORK;
            void ProcessTreeStep(ExoBlock cursor)
            {
                foreach (var readChild in cursor.Scopes)
                {
                    if (readChild.Commands.Count > 0)
                    {
                        DoWorkOnReadChild(readChild);
                    }

                    if (readChild.Scopes.Count > 0)
                    {
                        ProcessTreeStep(readChild);
                    }
                }
            }

            void DoWorkOnReadChild(ExoBlock readChild)
            {
                var entry = FilterEntry.CreateDataEntry("Show");

                foreach (var comm in readChild.ResolveAndSerialize())
                {
                    var line = comm.ToFilterLine();
                    entry.Content.Add(line);
                }

                results.Add(entry);
            }

            return(results);
        }
        public ExoFilter Execute(StructureExpr tree)
        {
            var result = new ExoFilter();

            // transformation process definition
            ReadCursor  = tree.GoToRoot();
            WriteCursor = new ExoBlock()
            {
                Type = FilterExoConfig.ExoFilterType.root
            };

            // builder information
            var builder = new ExpressionBuilder(this);

            // call
            ProcessTreeStep(ReadCursor);
            result.RootEntry = WriteCursor;

            // LOCAL: process the tree
            void ProcessTreeStep(StructureExpr cursor)
            {
                foreach (var readChild in cursor.Children)
                {
                    DoWorkOnReadChild(readChild);

                    if (readChild.Children.Count > 0)
                    {
                        ProcessTreeStep(readChild);
                    }
                }

                this.ReadCursor = cursor;
                PerformClosingScopeResolution(cursor);
            }

            void PerformClosingScopeResolution(StructureExpr cursor)
            {
                var success = builder.Execute();

                if (cursor.IsSection())
                {
                    WriteCursor = WriteCursor.GetParent();
                }

                if (success)
                {
                    builder = new ExpressionBuilder(this);
                }
            }

            // LOCAL: Perform work on write branch, by reading current step
            void DoWorkOnReadChild(StructureExpr readChild)
            {
                if (readChild.Mode == FilterExoConfig.StructurizerMode.atom)
                {
                    return;
                }

                // identify the line type
                if (readChild?.PrimitiveValue?.type == FilterExoConfig.TokenizerMode.comment)
                {
                    // treat it as comment
                    return;
                }

                // explicit scope handling
                if (readChild.ScopeType == FilterExoConfig.StructurizerScopeType.expl)
                {
                    if (readChild.IsSection())
                    {
                        var child = new ExoBlock();
                        child.Parent = this.WriteCursor;
                        WriteCursor.Scopes.Add(child);
                        WriteCursor = child;
                    }

                    return;
                }

                // implicit scope handling
                if (readChild.ScopeType == FilterExoConfig.StructurizerScopeType.impl)
                {
                    builder.AddNewPage();

                    foreach (var item in readChild.Children)
                    {
                        if (item.Mode == FilterExoConfig.StructurizerMode.atom)
                        {
                            builder.AddKeyWord(item);
                        }
                    }
                }
            }

            return(result);
        }