| 1734 | } |
| 1735 | |
| 1736 | void Pattern::compile( |
| 1737 | DFA::State *start, |
| 1738 | Follow& followpos, |
| 1739 | const Lazypos& lazypos, |
| 1740 | const Mods modifiers, |
| 1741 | const Map& lookahead) |
| 1742 | { |
| 1743 | DBGLOG("BEGIN compile()"); |
| 1744 | // init timers |
| 1745 | timer_type vt, et; |
| 1746 | timer_start(vt); |
| 1747 | // construct the DFA |
| 1748 | acc_.resize(end_.size(), false); |
| 1749 | trim_lazy(start, lazypos); |
| 1750 | // hash table with 64K pointer entries uint16_t indexed |
| 1751 | DFA::State **table = new DFA::State*[65536]; |
| 1752 | for (int i = 0; i < 65536; ++i) |
| 1753 | table[i] = NULL; |
| 1754 | // start state should only be discoverable (to possibly cycle back to) if no tree DFA was constructed |
| 1755 | if (start->tnode == NULL) |
| 1756 | table[hash_pos(start)] = start; |
| 1757 | // last added state |
| 1758 | DFA::State *last_state = start; |
| 1759 | for (DFA::State *state = start; state != NULL; state = state->next) |
| 1760 | { |
| 1761 | Moves moves; |
| 1762 | timer_start(et); |
| 1763 | // use the tree DFA accept state, if present |
| 1764 | if (state->tnode != NULL && state->tnode->accept > 0) |
| 1765 | state->accept = state->tnode->accept; |
| 1766 | compile_transition( |
| 1767 | state, |
| 1768 | followpos, |
| 1769 | lazypos, |
| 1770 | modifiers, |
| 1771 | lookahead, |
| 1772 | moves); |
| 1773 | if (state->tnode != NULL) |
| 1774 | { |
| 1775 | #ifdef WITH_TREE_DFA |
| 1776 | // merge tree DFA transitions into the final DFA transitions to target states |
| 1777 | if (moves.empty()) |
| 1778 | { |
| 1779 | // no DFA transitions: the final DFA transitions are the tree DFA transitions to target states |
| 1780 | if (opt_.i) |
| 1781 | { |
| 1782 | for (DFA::State::Edges::iterator t = state->tnode->edges.begin(); t != state->tnode->edges.end(); ++t) |
| 1783 | { |
| 1784 | Char c = t->first; |
| 1785 | DFA::State *target_state = last_state = last_state->next = dfa_.state(t->second.second); |
| 1786 | state->edges[c] = DFA::State::Edge(c, target_state); |
| 1787 | if (islowercase(c)) |
| 1788 | { |
| 1789 | state->edges[uppercase(c)] = DFA::State::Edge(uppercase(c), target_state); |
| 1790 | ++eno_; |
| 1791 | } |
| 1792 | ++eno_; |
| 1793 | } |
nothing calls this directly
no test coverage detected