Ken-Thompson NFA as described here: https://swtch.com/~rsc/regexp/regexp1.html but adjusted to work with teditor environment.
More...
#include <nfa.h>
|
| NFA (const std::string ®) |
| ctor with adding a regex for the NFA More...
|
|
size_t | find (const std::string &str, size_t start=0, size_t end=0) |
| String match function. More...
|
|
size_t | findAny (const std::string &str, size_t &matchStartPos, size_t start=0, size_t end=0) |
| Tries for regex match starting from anywhere in the string. More...
|
|
| ~NFA () |
|
bool | isMatch (bool lastStateRemaining=false) const |
| checks if we have reached match state, indicating a regex match More...
|
|
bool | areActiveStatesEmpty () const |
| Tells if after the current step() whether there are any active states still remaining. So, this can be used to prematurely stop the regex search in the string. More...
|
|
const Point & | getMatchPos () const |
| After the search has finished, use this to know the latest position of the match of the regex in the input string. More...
|
|
bool | step (char c, const Point &pos) |
| Step through the NFA state using the current char. More...
|
|
void | reset () |
| Reset all the variables used during regex search. This needs to be called once before beginning of every search. More...
|
|
|
static const size_t | NoMatch = std::string::npos |
|
Ken-Thompson NFA as described here: https://swtch.com/~rsc/regexp/regexp1.html but adjusted to work with teditor environment.
- Note
- the current design is not thread-safe! Meaning, the same NFA object cannot be used by multiple threads at the same. It will cause corruption of data
◆ NFA()
teditor::parser::NFA::NFA |
( |
const std::string & |
reg | ) |
|
ctor with adding a regex for the NFA
- Parameters
-
◆ ~NFA()
teditor::parser::NFA::~NFA |
( |
| ) |
|
|
inline |
◆ find()
size_t teditor::parser::NFA::find |
( |
const std::string & |
str, |
|
|
size_t |
start = 0 , |
|
|
size_t |
end = 0 |
|
) |
| |
String match function.
- Parameters
-
str | the input string |
start | location from where to start searching |
end | location (minus 1) till where to search |
- Returns
- the location of the longest match, else returns NFA::NoMatch
◆ findAny()
size_t teditor::parser::NFA::findAny |
( |
const std::string & |
str, |
|
|
size_t & |
matchStartPos, |
|
|
size_t |
start = 0 , |
|
|
size_t |
end = 0 |
|
) |
| |
Tries for regex match starting from anywhere in the string.
- Parameters
-
str | the input string |
matchStartPos | will contain the starting location of the longest match, if found, else, NFA::NoMatch |
start | location from where to start searching |
end | location (minus 1) till where to search |
- Returns
- the location of the longest match, else returns NFA::NoMatch
◆ NoMatch
const size_t teditor::parser::NFA::NoMatch = std::string::npos |
|
static |
represents case when regex didn't match anything
The documentation for this struct was generated from the following files: