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

Function first_leaf_identifier

internal/cbm/extract_calls.c:1276–1291  ·  view source on GitHub ↗

Descend left-most through wrapper nodes to the first identifier-bearing leaf. Used by HDL call nodes whose callee identifier is nested under one or more grammar wrappers (Verilog tf_call -> simple_identifier; SystemVerilog tf_call -> hierarchical_identifier -> simple_identifier).

Source from the content-addressed store, hash-verified

1274// grammar wrappers (Verilog tf_call -> simple_identifier; SystemVerilog
1275// tf_call -> hierarchical_identifier -> simple_identifier).
1276static char *first_leaf_identifier(CBMArena *a, TSNode node, const char *source) {
1277 TSNode cur = node;
1278 for (int depth = 0; depth < 8 && !ts_node_is_null(cur); depth++) {
1279 const char *k = ts_node_type(cur);
1280 if (strcmp(k, "simple_identifier") == 0 || strcmp(k, "identifier") == 0 ||
1281 strcmp(k, "word") == 0 || strcmp(k, "name") == 0 || strcmp(k, "qid") == 0) {
1282 char *t = cbm_node_text(a, cur, source);
1283 return (t && t[0]) ? t : NULL;
1284 }
1285 if (ts_node_named_child_count(cur) == 0) {
1286 return NULL;
1287 }
1288 cur = ts_node_named_child(cur, 0);
1289 }
1290 return NULL;
1291}
1292
1293// Verilog / SystemVerilog: a function_subroutine_call wraps
1294// subroutine_call -> tf_call -> [hierarchical_identifier ->] simple_identifier.

Callers 3

extract_hdl_calleeFunction · 0.85
extract_nasm_calleeFunction · 0.85
extract_llvm_calleeFunction · 0.85

Calls 1

cbm_node_textFunction · 0.85

Tested by

no test coverage detected