Exemplo n.º 1
0
    void intersect (equivset &rhs_, equivset &overlap_)
    {
        intersect_indexes (rhs_._index_vector, overlap_._index_vector);

        if (!overlap_._index_vector.empty ())
        {
            overlap_._id = _id;

            // LHS abstemious transitions have priority.
            if (_greedy < rhs_._greedy)
            {
                overlap_._greedy = _greedy;
            }
            else
            {
                overlap_._greedy = _greedy;
            }

            // Note that the LHS takes priority in order to
            // respect rule ordering priority in the lex spec.
            overlap_._followpos = _followpos;

            node_vector::const_iterator overlap_begin_ =
                overlap_._followpos.begin ();
            node_vector::const_iterator overlap_end_ =
                overlap_._followpos.end ();
            node_vector::const_iterator rhs_iter_ =
                rhs_._followpos.begin ();
            node_vector::const_iterator rhs_end_ =
                rhs_._followpos.end ();

            for (; rhs_iter_ != rhs_end_; ++rhs_iter_)
            {
                node *node_ = *rhs_iter_;

                if (std::find (overlap_begin_, overlap_end_, node_) ==
                    overlap_end_)
                {
                    overlap_._followpos.push_back (node_);
                    overlap_begin_ = overlap_._followpos.begin ();
                    overlap_end_ = overlap_._followpos.end ();
                }
            }

            if (_index_vector.empty ())
            {
                _followpos.clear ();
            }

            if (rhs_._index_vector.empty ())
            {
                rhs_._followpos.clear ();
            }
        }
    }
Exemplo n.º 2
0
    void intersect(basic_equivset &rhs_, basic_equivset &overlap_)
    {
        intersect_indexes(rhs_._index_vector, overlap_._index_vector);

        if (!overlap_._index_vector.empty())
        {
            // Note that the LHS takes priority in order to
            // respect rule ordering priority in the lex spec.
            overlap_._id = _id;
            overlap_._greedy = _greedy;
            overlap_._followpos = _followpos;

            typename node_vector::const_iterator overlap_begin_ =
                overlap_._followpos.begin();
            typename node_vector::const_iterator overlap_end_ =
                overlap_._followpos.end();
            typename node_vector::const_iterator rhs_iter_ =
                rhs_._followpos.begin();
            typename node_vector::const_iterator rhs_end_ =
                rhs_._followpos.end();

            for (; rhs_iter_ != rhs_end_; ++rhs_iter_)
            {
                node *node_ = *rhs_iter_;

                if (std::find(overlap_begin_, overlap_end_, node_) ==
                    overlap_end_)
                {
                    overlap_._followpos.push_back(node_);
                    overlap_begin_ = overlap_._followpos.begin();
                    overlap_end_ = overlap_._followpos.end();
                }
            }

            if (_index_vector.empty())
            {
                _followpos.clear();
            }

            if (rhs_._index_vector.empty())
            {
                rhs_._followpos.clear();
            }
        }
    }