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

Function first_leaf_identifier

internal/cbm/extract_calls.c:810–825  ·  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

808// grammar wrappers (Verilog tf_call -> simple_identifier; SystemVerilog
809// tf_call -> hierarchical_identifier -> simple_identifier).
810static char *first_leaf_identifier(CBMArena *a, TSNode node, const char *source) {
811 TSNode cur = node;
812 for (int depth = 0; depth < 8 && !ts_node_is_null(cur); depth++) {
813 const char *k = ts_node_type(cur);
814 if (strcmp(k, "simple_identifier") == 0 || strcmp(k, "identifier") == 0 ||
815 strcmp(k, "word") == 0 || strcmp(k, "name") == 0 || strcmp(k, "qid") == 0) {
816 char *t = cbm_node_text(a, cur, source);
817 return (t && t[0]) ? t : NULL;
818 }
819 if (ts_node_named_child_count(cur) == 0) {
820 return NULL;
821 }
822 cur = ts_node_named_child(cur, 0);
823 }
824 return NULL;
825}
826
827// Verilog / SystemVerilog: a function_subroutine_call wraps
828// subroutine_call -> tf_call -> [hierarchical_identifier ->] simple_identifier.

Callers 4

extract_hdl_calleeFunction · 0.85
extract_nasm_calleeFunction · 0.85
extract_llvm_calleeFunction · 0.85
extract_agda_calleeFunction · 0.85

Calls 1

cbm_node_textFunction · 0.85

Tested by

no test coverage detected