Example #1
0
 /**
  * Walk the tree post-order and call visit() on each node.
  * @param tree the SafraTree
  */
 public void walkTreePostOrder(SafraTree tree)
 {
     if (tree.getRootNode() == null)
     {
         return;
     }
     walkSubTreePostOrder(tree, tree.getRootNode());
 }
Example #2
0
 /**
    * Walk the tree post-order and call visit() on each node.
    * @param tree the SafraTree
    */
 public void walkTreePostOrder(SafraTree tree)
 {
     if (tree.getRootNode() == null)
     {
         return;
     }
     walkSubTreePostOrder(tree, tree.getRootNode());
 }
Example #3
0
        /**
         * Walk the subtree rooted at *top post-order and call visit() on each node.
         * @param tree the SafraTree
         * @param top the current subroot
         * @param visit_top if true, *top is visited too
         */
        public void walkSubTreePostOrder(SafraTree tree, SafraTreeNode top, bool visit_top)
        {
            if (top.getChildCount() > 0)
            {
                SafraTreeNode it = top.children_begin();
                //SafraTreeNode it = top._oldestChild;
                //while (it._youngestChild != null)
                while (it != top.children_end())
                {
                    SafraTreeNode cur_child = it;

                    // Increment iterator *before* recursion & visit to account
                    // for possible deletion of this child
                    //it = it.getYoungerBrother();
                    it = it.increment();
                    walkSubTreePostOrder(tree, cur_child, true);
                }
            }

            if (visit_top)
            {
                _visitor.visit(tree, top);
            }
        }
Example #4
0
        /**
           * Walk the subtree rooted at *top post-order and call visit() on each node.
           * @param tree the SafraTree
           * @param top the current subroot
           * @param visit_top if true, *top is visited too
           */
        public void walkSubTreePostOrder(SafraTree tree, SafraTreeNode top, bool visit_top)
        {
            if (top.getChildCount() > 0)
            {
                SafraTreeNode it = top.children_begin();
                //SafraTreeNode it = top._oldestChild;
                //while (it._youngestChild != null)
                while (it != top.children_end())
                {
                    SafraTreeNode cur_child = it;

                    // Increment iterator *before* recursion & visit to account
                    // for possible deletion of this child
                    //it = it.getYoungerBrother();
                    it = it.increment();
                    walkSubTreePostOrder(tree, cur_child, true);
                }
            }

            if (visit_top)
            {
                _visitor.visit(tree, top);
            }
        }
Example #5
0
        //typedef typename DA_t::state_type da_state_t;
        //typedef typename Algorithm_t::state_t algo_state_t;
        //typedef typename Algorithm_t::result_t algo_result_t;
        //typedef TreeWithAcceptance<algo_state_t, typename Acceptance::signature_type> stuttered_state_t;
        //typedef typename stuttered_state_t::ptr stuttered_state_ptr_t;

        //typedef std::pair<stuttered_state_ptr_t, da_state_t*> unprocessed_value_t;
        //typedef std::stack<unprocessed_value_t> unprocessed_stack_t;

        /** Convert the NBA to the DA */
        public void convert()
        {
            APSet ap_set = _da_result.getAPSet();

            if (_algo.checkEmpty())
            {
                _da_result.constructEmpty();
                return;
            }

            _algo.prepareAcceptance(_da_result.acceptance());

            TreeWithAcceptance s_start     = new TreeWithAcceptance(_algo.getStartState());
            DA_State           start_state = _da_result.newState();

            s_start.generateAcceptance(start_state.acceptance());
            if (_detailed_states)
            {
                //start_state->setDescription(s_start->toHTML());
                start_state.setDescription("hahahahah");
            }

            _state_mapper.add(s_start, start_state);
            _da_result.setStartState(start_state);

            Stack <KeyValuePair <TreeWithAcceptance, DA_State> > unprocessed;

            _unprocessed.Push(new KeyValuePair <TreeWithAcceptance, DA_State>(s_start, start_state));

            bool   all_insensitive     = _stutter_information.isCompletelyInsensitive();
            BitSet partial_insensitive = _stutter_information.getPartiallyInsensitiveSymbols();

            while (_unprocessed.Count > 0)
            {
                KeyValuePair <TreeWithAcceptance, DA_State> top = _unprocessed.Pop();
                //_unprocessed.pop();

                TreeWithAcceptance from    = top.Key;
                DA_State           da_from = top.Value;

                //for (APSet::element_iterator it_elem=ap_set.all_elements_begin();it_elem!=ap_set.all_elements_end();++it_elem)
                for (int it_elem = ap_set.all_elements_begin(); it_elem != ap_set.all_elements_end(); ++it_elem)
                {
                    APElement elem = new APElement(it_elem);

                    if (da_from.edges().get(elem) == null)
                    {
                        // the edge was not yet calculated...

                        if (!all_insensitive && partial_insensitive.get(it_elem) == null)
                        {
                            // can't stutter for this symbol, do normal step
                            SafraTree          next_tree  = _algo.delta(from.getTree() as SafraTree, elem).getState();
                            TreeWithAcceptance next_state = new TreeWithAcceptance(next_tree);
                            add_transition(da_from, next_state, elem);

                            continue;
                        }

                        // normal stuttering...

                        calc_delta(from, da_from, elem);

                        if (_limit != 0 && _da_result.size() > _limit)
                        {
                            //THROW_EXCEPTION(LimitReachedException, "");
                            throw new Exception("LimitReachedException");
                        }
                    }
                }
            }
        }
Example #6
0
 public void walkSubTreePostOrder(SafraTree tree, SafraTreeNode top)
 {
     walkSubTreePostOrder(tree, top, true);
 }
Example #7
0
 public void walkSubTreePostOrder(SafraTree tree, SafraTreeNode top)
 {
     walkSubTreePostOrder(tree, top, true);
 }