MCPcopy Create free account
hub / github.com/MrNeRF/LichtFeld-Studio / UpdateSyntax

Method UpdateSyntax

external/zep/src/syntax_python.cpp:123–307  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

121 }
122
123 void ZepSyntax_Python::UpdateSyntax() {
124 auto& buffer = m_buffer.GetWorkingBuffer();
125 auto itrCurrent = buffer.begin();
126 const auto itrEnd = buffer.end();
127
128 assert(std::distance(itrCurrent, itrEnd) <= int(m_syntax.size()));
129 assert(m_syntax.size() == buffer.size());
130
131 auto mark = [&](GapBuffer<uint8_t>::const_iterator itrA,
132 GapBuffer<uint8_t>::const_iterator itrB,
133 ThemeColor type,
134 ThemeColor background) {
135 std::fill(m_syntax.begin() + (itrA - buffer.begin()),
136 m_syntax.begin() + (itrB - buffer.begin()),
137 SyntaxData{type, background});
138 };
139
140 auto mark_single = [&](GapBuffer<uint8_t>::const_iterator itr,
141 ThemeColor type,
142 ThemeColor background) {
143 (m_syntax.begin() + (itr - buffer.begin()))->foreground = type;
144 (m_syntax.begin() + (itr - buffer.begin()))->background = background;
145 };
146
147 auto scan_string = [&](auto start, auto quote_begin) {
148 auto itr = quote_begin;
149 const uint8_t quote = *quote_begin;
150 bool triple = false;
151 if ((itrEnd - quote_begin) >= 3 && *(quote_begin + 1) == quote &&
152 *(quote_begin + 2) == quote) {
153 triple = true;
154 itr += 3;
155 } else {
156 ++itr;
157 }
158
159 while (itr != itrEnd) {
160 if (!triple && *itr == '\\') {
161 if ((itrEnd - itr) > 1) {
162 itr += 2;
163 } else {
164 ++itr;
165 }
166 continue;
167 }
168
169 if (*itr == quote) {
170 if (triple) {
171 if ((itrEnd - itr) >= 3 && *(itr + 1) == quote && *(itr + 2) == quote) {
172 itr += 3;
173 break;
174 }
175 } else {
176 ++itr;
177 break;
178 }
179 }
180

Callers

nothing calls this directly

Calls 10

markFunction · 0.85
is_identifier_startFunction · 0.85
is_identifier_continueFunction · 0.85
is_python_string_prefixFunction · 0.85
string_tolowerFunction · 0.85
distanceFunction · 0.50
beginMethod · 0.45
endMethod · 0.45
sizeMethod · 0.45
findMethod · 0.45

Tested by

no test coverage detected