diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2017-09-11 19:38:29 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2017-09-11 19:38:29 -0700 |
commit | 6417918274d7d7d8d5b7bb675906f8e38d25c073 (patch) | |
tree | b0cae1edde45ba238214b8f64fcb335f5883feca /gencadr.txr | |
parent | fd47bc4ae6bb9f6a4dab2cf12e8c5cb7459675e2 (diff) | |
download | txr-6417918274d7d7d8d5b7bb675906f8e38d25c073.tar.gz txr-6417918274d7d7d8d5b7bb675906f8e38d25c073.tar.bz2 txr-6417918274d7d7d8d5b7bb675906f8e38d25c073.zip |
regex: remove nfa_reject representation.
Reject states are no longer explicitly represented in the NFA
graph. Any transition that previously would have led to a
reject state is just a null pointer now: no transition.
This just means we have to check one place for a null pointer.
This change fixes a flaw in nfa_closure: the function was
propagating nfa_reject states to the closure set. When
the input set consisted only of reject states (or rather
exactly one reject state in that special case), it would
add it to the output set and return 1, making it seem as
if the regex is one that can potentially match something.
* regex.c (nfa_kind_t): Enum member nfa_reject removed.
(nfa_state_reject): Static function removed.
(nfa_compile_regex): Compile a t regex (match nothing)
to a NFA graph with no transition at all into any start
state; effectively an empty graph with no state nodes.
(nfa_map_states): Remove nfa_reject case from switch. Also,
stylistic change; state pointers are tested as Booleans
elsewhere rather than by comparison to null pointer.
(nfa_count_states, nfa_handle_wraparound): Handle null state
pointer.
(nfa_move_closure): Test the mov transition for null;
anything can potentially now have a null transition,
not only epsilon nodes.
(nfa_run, regex_machine_reset): Handle nfa.start being null
indicating an empty NFA graph. In that case we don't have to
calculate the closure; we just have an empty set of states and
set nfa.nclos to zero. The visited disambiguation counter is
irrelevant since there are no states to visit.
(regex_machine_feed): Don't try to propagate visited counter
stored in regex machine to empty NFA graph which has no states.
Diffstat (limited to 'gencadr.txr')
0 files changed, 0 insertions, 0 deletions