Handle Wolfram Needs["package`"] — apply where head is builtin_symbol "Needs".
| 1668 | |
| 1669 | // Handle Wolfram Needs["package`"] — apply where head is builtin_symbol "Needs". |
| 1670 | static void process_wolfram_needs(CBMExtractCtx *ctx, TSNode node) { |
| 1671 | CBMArena *a = ctx->arena; |
| 1672 | if (ts_node_named_child_count(node) < MIN_WOLFRAM_CHILDREN) { |
| 1673 | return; |
| 1674 | } |
| 1675 | TSNode head = ts_node_named_child(node, 0); |
| 1676 | if (strcmp(ts_node_type(head), "builtin_symbol") != 0) { |
| 1677 | return; |
| 1678 | } |
| 1679 | char *name = cbm_node_text(a, head, ctx->source); |
| 1680 | if (!name || strcmp(name, "Needs") != 0) { |
| 1681 | return; |
| 1682 | } |
| 1683 | TSNode arg = ts_node_named_child(node, SECOND_IDX); |
| 1684 | char *text = cbm_node_text(a, arg, ctx->source); |
| 1685 | if (text && text[0]) { |
| 1686 | char *path = strip_quotes(a, text); |
| 1687 | CBMImport imp = {.local_name = path_last(a, path), .module_path = path}; |
| 1688 | cbm_imports_push(&ctx->result->imports, a, imp); |
| 1689 | } |
| 1690 | } |
| 1691 | |
| 1692 | static void walk_wolfram_imports(CBMExtractCtx *ctx, TSNode root) { |
| 1693 | TSNodeStack stack; |
no test coverage detected