| 2611 | } |
| 2612 | |
| 2613 | void Pattern::transition( |
| 2614 | Moves& moves, |
| 2615 | Chars& chars, |
| 2616 | const Positions& follow) const |
| 2617 | { |
| 2618 | Moves::iterator i = moves.begin(); |
| 2619 | Moves::iterator end = moves.end(); |
| 2620 | while (i != end) |
| 2621 | { |
| 2622 | if (i->second == follow) |
| 2623 | { |
| 2624 | chars += i->first; |
| 2625 | moves.erase(i++); |
| 2626 | } |
| 2627 | else |
| 2628 | { |
| 2629 | ++i; |
| 2630 | } |
| 2631 | } |
| 2632 | Chars common; |
| 2633 | for (i = moves.begin(); i != end; ++i) |
| 2634 | { |
| 2635 | common = chars & i->first; |
| 2636 | if (common.any()) |
| 2637 | { |
| 2638 | if (common == i->first) |
| 2639 | { |
| 2640 | chars -= common; |
| 2641 | pos_insert(i->second, follow); |
| 2642 | } |
| 2643 | else |
| 2644 | { |
| 2645 | moves.push_back(Move(common, i->second)); |
| 2646 | Move& back = moves.back(); |
| 2647 | pos_insert(back.second, follow); |
| 2648 | chars -= back.first; |
| 2649 | i->first -= back.first; |
| 2650 | } |
| 2651 | if (!chars.any()) |
| 2652 | return; |
| 2653 | } |
| 2654 | } |
| 2655 | if (chars.any()) |
| 2656 | moves.push_back(Move(chars, follow)); |
| 2657 | } |
| 2658 | |
| 2659 | void Pattern::compile_list(Location loc, Chars& chars, const Mods modifiers) const |
| 2660 | { |