Add some runtime assertions for state zero being final
I'm using this invariant to save work finding the final state so it makes sense to test it.
This commit is contained in:
parent
c58cabd2e6
commit
007cddc292
@ -33,6 +33,8 @@ static void construct_term(const regex_term_t *term, fsa_t *out)
|
|||||||
case REGEX_TERM_CLASS:
|
case REGEX_TERM_CLASS:
|
||||||
assert(false);
|
assert(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
assert(out->states[0].final);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void concat_fsas(fsa_t *base, const fsa_t *other)
|
static void concat_fsas(fsa_t *base, const fsa_t *other)
|
||||||
@ -65,6 +67,8 @@ static void concat_fsas(fsa_t *base, const fsa_t *other)
|
|||||||
|
|
||||||
free(other->states[0].rules);
|
free(other->states[0].rules);
|
||||||
free(other->states);
|
free(other->states);
|
||||||
|
|
||||||
|
assert(base->states[0].final);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void construct_sequence(const regex_sequence_t *seq, fsa_t *out)
|
static void construct_sequence(const regex_sequence_t *seq, fsa_t *out)
|
||||||
@ -77,6 +81,8 @@ static void construct_sequence(const regex_sequence_t *seq, fsa_t *out)
|
|||||||
construct_term(&seq->contents[i], &term_fsa);
|
construct_term(&seq->contents[i], &term_fsa);
|
||||||
concat_fsas(out, &term_fsa);
|
concat_fsas(out, &term_fsa);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
assert(out->states[0].final);
|
||||||
}
|
}
|
||||||
|
|
||||||
void construct(const regex_t *regex, fsa_t *out)
|
void construct(const regex_t *regex, fsa_t *out)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user