15struct Regex2NfaConverter {
24 auto lb = lit0->as<
Lit>()->
get();
25 auto ub = lit1->as<
Lit>()->
get();
26 add_range_transitions(from, to, lb, ub);
31 auto middle = nfa_->add_state();
35 add_range_transitions(start, end, 0, 255);
37 add_range_transitions(start, end,
range->arg(0),
range->arg(1));
38 if (
error) add_range_transitions(start,
error, 0, 255);
40 auto first = nfa_->add_state();
41 auto error = nfa_->add_state();
42 error->set_erroring(
true);
51 convert(opt->arg(), start, end);
53 auto m1 = nfa_->add_state();
54 auto m2 = nfa_->add_state();
61 auto m0 = nfa_->add_state();
62 auto m1 = nfa_->add_state();
63 auto m2 = nfa_->add_state();
74 auto start = nfa_->add_state();
75 nfa_->set_start(start);
76 auto end = nfa_->add_state();
81 std::unique_ptr<automaton::NFA> nfa() {
return std::move(nfa_); }
84 std::unique_ptr<automaton::NFA> nfa_;
90 Regex2NfaConverter converter;
91 converter.convert(regex);
92 return converter.nfa();
void set_accepting(bool accepting)
void add_transition(const NFANode *to, std::uint16_t c)
Helper class to retrieve Infer::arg if present.
void * get(void *handle, const char *symbol_name)
const Sigma * convert(const TBound< up > *b)
std::unique_ptr< automaton::NFA > regex2nfa(Ref regex)
void error(Loc loc, const char *f, Args &&... args)
automaton::NFA * regex2nfa(Ref regex)
You can dl::get this function.