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

Function cbm_parse_source

internal/cbm/cbm.c:534–552  ·  view source on GitHub ↗

#2078: parse every file as if its last line were terminated. * * Many grammars treat the line terminator as part of the construct it ends -- * a markdown fence, heading or list marker, a Makefile recipe, a Dockerfile * instruction. A file whose last byte is not "\n" leaves that construct * unterminated: at best a zero-width MISSING token (#1610/#1746 excuse those at * EOF), at worst a WIDTH-

Source from the content-addressed store, hash-verified

532 *
533 * A file that is empty or already ends in "\n" is parsed exactly as before. */
534TSTree *cbm_parse_source(TSParser *parser, const char *source, uint32_t source_len,
535 TSParseOptions opts) {
536 CBMStringInput input = {source, source_len, source_len > 0 && source[source_len - 1] != '\n'};
537 TSInput ts_input = {&input, cbm_string_read, TSInputEncodingUTF8, NULL};
538 TSTree *tree = ts_parser_parse_with_options(parser, NULL, ts_input, opts);
539 if (tree && input.virtual_newline) {
540 TSPoint end = cbm_source_end_point(source, source_len);
541 TSInputEdit drop_virtual_newline = {
542 .start_byte = source_len,
543 .old_end_byte = source_len + 1,
544 .new_end_byte = source_len,
545 .start_point = end,
546 .old_end_point = {end.row + 1, 0},
547 .new_end_point = end,
548 };
549 ts_tree_edit(tree, &drop_virtual_newline);
550 }
551 return tree;
552}
553
554// --- Parse timeout callback ---
555

Calls 1

cbm_source_end_pointFunction · 0.85

Tested by

no test coverage detected