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

Function cx_rescript_lex_work

tests/test_complexity.c:1292–1311  ·  view source on GitHub ↗

Bytes pulled while parsing `len` copies of `fill` as ReScript; 0 on failure. */

Source from the content-addressed store, hash-verified

1290
1291/* Bytes pulled while parsing `len` copies of `fill` as ReScript; 0 on failure. */
1292static uint64_t cx_rescript_lex_work(unsigned char fill, uint32_t len) {
1293 char *src = malloc(len);
1294 TSParser *parser = ts_parser_new();
1295 uint64_t work = 0;
1296 if (src && parser && ts_parser_set_language(parser, cbm_ts_language(CBM_LANG_RESCRIPT))) {
1297 memset(src, fill, len);
1298 CxLexInput in = {src, len, 0};
1299 TSInput input = {&in, cx_lex_read, TSInputEncodingUTF8, NULL};
1300 TSTree *tree = ts_parser_parse(parser, NULL, input);
1301 if (tree) {
1302 work = in.bytes_pulled;
1303 ts_tree_delete(tree);
1304 }
1305 }
1306 if (parser) {
1307 ts_parser_delete(parser);
1308 }
1309 free(src);
1310 return work;
1311}
1312
1313TEST(complexity_rescript_error_recovery_lexing_is_linear) {
1314 /* 0xFF: the reporter's binary bytes (invalid UTF-8). '~': plain ASCII text

Callers 1

test_complexity.cFile · 0.85

Calls 1

cbm_ts_languageFunction · 0.85

Tested by

no test coverage detected