mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-19 13:03:36 +00:00
committed by
Konstantin Pastbin
parent
c9cbb64f12
commit
76ffc99abd
40
libs/base/uni_string_dfa.cpp
Normal file
40
libs/base/uni_string_dfa.cpp
Normal file
@@ -0,0 +1,40 @@
|
||||
#include "base/uni_string_dfa.hpp"
|
||||
|
||||
#include "base/assert.hpp"
|
||||
|
||||
namespace strings
|
||||
{
|
||||
// UniStringDFA::Iterator --------------------------------------------------------------------------
|
||||
UniStringDFA::Iterator::Iterator(UniString const & s) : m_s(s), m_pos(0), m_rejected(false) {}
|
||||
|
||||
UniStringDFA::Iterator & UniStringDFA::Iterator::Move(UniChar c)
|
||||
{
|
||||
if (Accepts())
|
||||
{
|
||||
m_rejected = true;
|
||||
return *this;
|
||||
}
|
||||
|
||||
if (Rejects())
|
||||
return *this;
|
||||
|
||||
ASSERT_LESS(m_pos, m_s.size(), ());
|
||||
if (m_s[m_pos] != c)
|
||||
{
|
||||
m_rejected = true;
|
||||
return *this;
|
||||
}
|
||||
|
||||
++m_pos;
|
||||
return *this;
|
||||
}
|
||||
|
||||
// UniStringDFA::UniStringDFA ----------------------------------------------------------------------
|
||||
UniStringDFA::UniStringDFA(std::string const & s) : UniStringDFA(MakeUniString(s)) {}
|
||||
|
||||
std::string DebugPrint(UniStringDFA const & dfa)
|
||||
{
|
||||
return DebugPrint(dfa.m_s);
|
||||
}
|
||||
|
||||
} // namespace strings
|
||||
Reference in New Issue
Block a user