Bytes pulled while parsing `len` copies of `fill` as ReScript; 0 on failure. */
| 1290 | |
| 1291 | /* Bytes pulled while parsing `len` copies of `fill` as ReScript; 0 on failure. */ |
| 1292 | static 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 | |
| 1313 | TEST(complexity_rescript_error_recovery_lexing_is_linear) { |
| 1314 | /* 0xFF: the reporter's binary bytes (invalid UTF-8). '~': plain ASCII text |
no test coverage detected