lexer_utils.hpp

A set of utilities to convert between NFAs and DFAs.

Note

Status: BETA

Functions

static inline const DFA &to_DFA(const DFA &dfa)

Converting DFA to DFA — no change needed.

static inline const NFA &to_NFA(const NFA &nfa)

Converting NFA to MFA — no change needed.

static inline DFA to_DFA(const NFA &nfa, int keep_invalid = false)

Systematic conversion of NFA to DFA…

static inline NFA to_NFA(const DFA &dfa)

Systematic up-conversion of DFA to NFA…

template<typename T1>
static NFA MergeNFA(T1 &&in)

Merge multiple automata into one NFA (base case, single conversion)

template<typename T1, typename T2, typename ...Ts>
static NFA MergeNFA(T1 &&in1, T2 &&in2, Ts&&... others)

Merge multiple automata (DFA, NFA, RegEx) into one NFA.

template<typename T1, typename T2, typename ...Ts>
static DFA MergeDFA(T1 &&in1, T2 &&in2, Ts&&... others)

Merge multiple automata (DFA, NFA, RegEx) into one DFA.

std::string FindExample(const DFA &dfa, const size_t min_size = 1)

Method to find an example string that satisfies a DFA.

struct DFAStatus
#include <lexer_utils.hpp>

Structure to track the current status of a DFA.

Public Functions

inline DFAStatus(size_t _state, const std::string &_seq)

Public Members

size_t state
std::string sequence