MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / pl_code_step

Function pl_code_step

internal/cbm/doclink_perl.c:211–243  ·  view source on GitHub ↗

One lexing step at t[i], i < e (Pod::Simple's treelet tokens). * PL_EV_OPEN a code opened at t[i]; its content starts at *next * PL_EV_CLOSE the innermost code's content ended at i; *next follows its * closing brackets * PL_EV_TEXT t[i, *next) is literal */

Source from the content-addressed store, hash-verified

209 * closing brackets
210 * PL_EV_TEXT t[i, *next) is literal */
211static int pl_code_step(pl_codes_t *st, const char *t, size_t i, size_t e, size_t *next) {
212 char c = t[i];
213 if (pl_upper(c) && i + SKIP_ONE < e && t[i + SKIP_ONE] == '<') {
214 bool pushed = false;
215 *next = pl_code_open(st, t, i, e, &pushed);
216 return pushed ? PL_EV_OPEN : PL_EV_TEXT;
217 }
218 size_t need = st->depth > 0 ? st->width[st->depth - SKIP_ONE] : 0;
219 if (need == SKIP_ONE && c == '>') {
220 st->depth--;
221 *next = i + SKIP_ONE;
222 return PL_EV_CLOSE;
223 }
224 if (need > SKIP_ONE && pl_space(c)) {
225 size_t k = i;
226 while (k < e && pl_space(t[k])) {
227 k++;
228 }
229 size_t m = k;
230 while (m < e && t[m] == '>') {
231 m++;
232 }
233 if (m - k >= need) {
234 st->depth--;
235 *next = k + need;
236 return PL_EV_CLOSE;
237 }
238 *next = m; /* white space and too few brackets: literal */
239 return PL_EV_TEXT;
240 }
241 *next = i + SKIP_ONE;
242 return PL_EV_TEXT;
243}
244
245/* ── Bounded text output ─────────────────────────────────────────── */
246

Callers 3

pl_link_shapeFunction · 0.85
pl_para_linksFunction · 0.85

Calls 3

pl_upperFunction · 0.85
pl_code_openFunction · 0.85
pl_spaceFunction · 0.85

Tested by

no test coverage detected