コード例 #1
0
        internal RecursionPoint replace(LinkedListNode <Symbol> linkedListNode)
        {
            var            rule          = Data.getRule(linkedListNode);
            RecursionPoint todo          = new RecursionPoint();
            var            pointsToCheck = new HashSet <LinkedListNode <Symbol> >();

            if (rule == null)
            {
                rule = new Rule(Data.NextId, this);
#if DEBUG
                Rules.Add(rule);
#endif

                Debug.Print("New rule created:" + rule.ID);

                todo.UnionWith(Data.newRule(linkedListNode, rule));
            }
            else
            {
                Debug.Print("using old rule:" + rule.ID);
            }

            todo.UnionWith(Data.setRule(linkedListNode, rule));



            Data.removeDigrams(todo.RemovedDigrams);
            todo.RemovedDigrams.Clear();


            return(todo);
        }
コード例 #2
0
        public void Evaluate(List <String> items)
        {
            foreach (var item in items)
            {
                Debug.Print("read:'" + item + "'");
                _StartRule.Symbols.AddLast(new TerminalInstance(item));
                RecursionPoint todo = _StartRule.CheckTail();
                while (todo != null && !todo.Empty)
                {
                    while (todo.DigramsToCheck.Count > 1)
                    {
                        RecursionPoint newtodo = new RecursionPoint();

                        foreach (var tocheck in todo.DigramsToCheck)
                        {
                            if (tocheck == null)
                            {
                                continue;
                            }

                            OverlapInfo result = findOccurence(tocheck);
                            if (result == OverlapInfo.Found)
                            {
                                newtodo.UnionWith(replace(tocheck));
                            }
                            else if (result == OverlapInfo.NotFound)
                            {
                                noteDigram(tocheck);
                            }
                            //otherwise overlaps
                        }
                        todo = newtodo;
                    }

                    Data.removeDigrams(todo.RemovedDigrams);
                    todo.RemovedDigrams.Clear();

                    todo.UnionWith(_StartRule.CheckTail());
                }
            }
        }
コード例 #3
0
        public void Evaluate(List<String> items)
        {
            foreach (var item in items)
            {
                Debug.Print("read:'" + item + "'");
                _StartRule.Symbols.AddLast(new TerminalInstance(item));
                RecursionPoint todo = _StartRule.CheckTail();
                while (todo != null && !todo.Empty )
                {
                    while(todo.DigramsToCheck.Count > 1)
                    {

                        RecursionPoint newtodo = new RecursionPoint();

                        foreach (var tocheck in todo.DigramsToCheck)
                        {
                            if (tocheck == null)
                                continue;

                            OverlapInfo result = findOccurence(tocheck) ;
                            if (result == OverlapInfo.Found)
                            {
                                newtodo.UnionWith(replace(tocheck));
                            }
                            else if( result == OverlapInfo.NotFound)
                            {
                                noteDigram(tocheck);
                            }
                            //otherwise overlaps
                        }
                        todo = newtodo;
                    }

                    Data.removeDigrams(todo.RemovedDigrams);
                    todo.RemovedDigrams.Clear();

                    todo.UnionWith(_StartRule.CheckTail());
                }
            }
        }
コード例 #4
0
        internal RecursionPoint replace(LinkedListNode<Symbol> linkedListNode)
        {
            var rule = Data.getRule(linkedListNode);
            RecursionPoint todo = new RecursionPoint();
            var pointsToCheck = new HashSet<LinkedListNode<Symbol>>();
            if (rule == null)
            {
                rule = new Rule(Data.NextId, this);
            #if DEBUG
                Rules.Add(rule);
            #endif

                Debug.Print("New rule created:" + rule.ID);

                todo.UnionWith(Data.newRule(linkedListNode, rule));
            }
            else
            {
                Debug.Print("using old rule:" + rule.ID );
            }

            todo.UnionWith(Data.setRule(linkedListNode, rule));

            Data.removeDigrams(todo.RemovedDigrams);
            todo.RemovedDigrams.Clear();

            return todo;
        }