MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ matches_context()

bool MayaFlux::Nodes::Network::RewriteOperator::matches_context ( const Replacement & replacement,
const Environment & environment ) const
nodiscardprivate

Definition at line 110 of file RewriteOperator.cpp.

111{
112 const auto ignored = [this](const Symbol& symbol) {
113 return std::ranges::find(m_ignore, symbol.id) != m_ignore.end();
114 };
115
116 const auto word = environment.word;
117 size_t cursor = environment.position;
118 for (const auto expected : replacement.left | std::views::reverse) {
119 do {
120 if (cursor == 0) {
121 return false;
122 }
123 --cursor;
124 } while (ignored(word[cursor]));
125
126 if (word[cursor].id != expected) {
127 return false;
128 }
129 }
130
131 cursor = environment.position;
132 for (const auto expected : replacement.right) {
133 do {
134 ++cursor;
135 if (cursor >= word.size()) {
136 return false;
137 }
138 } while (ignored(word[cursor]));
139
140 if (word[cursor].id != expected) {
141 return false;
142 }
143 }
144
145 return true;
146}

References MayaFlux::Nodes::Network::RewriteOperator::Replacement::left, m_ignore, matches_context(), MayaFlux::Nodes::Network::RewriteOperator::Environment::position, MayaFlux::Nodes::Network::RewriteOperator::Replacement::right, and MayaFlux::Nodes::Network::RewriteOperator::Environment::word.

Referenced by matches_context(), and select_replacement().

Here is the call graph for this function:
Here is the caller graph for this function: