DFA.hpp
A Deterministic Finite Automata simulator.
This file is part of Empirical, https://github.com/devosoft/Empirical Copyright (C) 2016-2024 Michigan State University MIT Software license; see doc/LICENSE.md
Note
Status: BETA
Defines
-
INCLUDE_EMP_COMPILER_DFA_HPP_GUARD
Typedefs
-
template<int NUM_SYMBOLS = 128, typename STOP_T = uint8_t>
class tDFA - #include <DFA.hpp>
Public Functions
-
inline size_t GetSize() const
How many states is this DFA using?
-
inline void Resize(size_t new_size)
Add Additional empty states.
-
inline size_t AddState()
Add a single new, empty state and return its position.
-
inline const array<int, NUM_SYMBOLS> &GetTransitions(size_t from) const
Return an array of all transitions associated with a specified state.
-
inline void SetTransition(size_t from, size_t to, size_t sym)
Add a specific transition associated with an input symbol.
-
inline void SetStop(size_t state, stop_t stop_val = 1)
Set the stop value (no matter what it currently is)
-
inline void AddStop(size_t state, stop_t stop_val = 1)
Set the stop value only if it’s higher than the current stop value.
-
inline bool IsActive(int state) const
Test if a state is still valid.
-
inline bool IsStop(int state) const
Test if a state has a stop.
-
inline bool IsActive(size_t) const
-
inline bool IsStop(size_t state) const
-
inline int Next(int state, size_t sym) const
Return the new state after a symbol occurs.
-
inline bool UsesSymbol(size_t symbol_id) const
Public Static Attributes
-
static constexpr size_t SYMBOL_START = 2
Symbol to indicate a start of line.
-
static constexpr size_t SYMBOL_STOP = 3
Symbol to indicate an end of line.
-
static constexpr size_t SYMBOL_MIN_INPUT = 9
All symbols below this are control symbols.
Private Types
-
using this_t = tDFA<NUM_SYMBOLS, STOP_T>
-
inline size_t GetSize() const