public void StructurizerCorrectTreeGenTest()
        {
            var input = new List <string>()
            {
                "Section Incubators : IncubatorBase",
                "{",
                "Rule leveledex { ItemLevel >= 81; BaseType<>; };",
                "Rule T1 { BaseType<>; };",
                "Rule T2 { BaseType<>; };",
                "Rule T3 { BaseType<>; };",
                "Rule T4 { BaseType<>; };",
                "Rule error;",
                "}"
            };

            var result   = Structurize(input);
            var treeDict = StructurizerDebugger.SelectOnTree(result, x => x.Mode.ToString() + x.ScopeType.ToString());

            Assert.IsNotNull(treeDict);
            Assert.IsTrue(treeDict["r"] == "rootnone");
            Assert.IsTrue(treeDict["r.0.0"] == "scopexpl");
            Assert.IsTrue(treeDict["r.0.0.4.0"] == "scopexpl");
            Assert.IsTrue(treeDict.Count > 30);
        }
Пример #2
0
        public Dictionary <string, string> Execute()
        {
            var results = new Dictionary <string, string>();

            // tokenize
            var tokenizer = new ExoTokenizer();

            tokenizer.Execute(this.RawMetaFilterText);

            // load style information

            // todo

            // 1) BUILD STRUCTURE FROM TOKENIZED EXPRESSION
            var structurizer   = new Structurizer();
            var expressionTree = structurizer.Execute(tokenizer.Results);

            if (Debug)
            {
                var structureDebugger = new StructurizerDebugger();
                var treeDict          = structureDebugger.SelectOnTree(expressionTree, x => x.Mode);
                var treeDictString    = string.Join(System.Environment.NewLine, treeDict.Select(x => $"{x.Key}, {x.Value}"));
                results.Add("structurizer_debug_view", treeDictString);
                results.Add("structurizer_debug_nodenames", structureDebugger.CreateTreeString(expressionTree));
            }

            // 1.5) BUILD -LOGICAL- CONCRETE STRUCTURE

            // 2) RESOLVE DEPEDENCIES

            var exoPreProc = new ExoPreProcessor();
            var exoFilter  = exoPreProc.Execute(expressionTree);

            results.Add("ExoPreProcessor", string.Join(System.Environment.NewLine, new ExoPreProcessorDebugger().Execute(exoFilter)));

            // 3) COMPILE INTO SEEDFILTER

            var exoProcessor         = new ExoProcessor();
            var seedFilter           = exoProcessor.Execute(exoFilter);
            var serializedSeedFilter = seedFilter.SelectMany(x => x.Serialize()).ToList();

            results.Add("ExoOutput", string.Join(System.Environment.NewLine, serializedSeedFilter));

            return(results);
        }