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

Function make_rule_sets_variable

internal/cbm/extract_defs.c:6420–6470  ·  view source on GitHub ↗

A `rule` node that is a target-specific variable: after the targets' * colon(s) come [export|override|private|unexport]... NAME and an * assignment operator (= := ::= :::= += ?= !=). */

Source from the content-addressed store, hash-verified

6418 * colon(s) come [export|override|private|unexport]... NAME and an
6419 * assignment operator (= := ::= :::= += ?= !=). */
6420static bool make_rule_sets_variable(TSNode rule, const char *src) {
6421 static const char *const kws[] = {"export", "override", "private", "unexport", NULL};
6422 TSNode targets = cbm_find_child_by_kind(rule, "targets");
6423 if (ts_node_is_null(targets)) {
6424 return false;
6425 }
6426 uint32_t p = ts_node_end_byte(targets);
6427 uint32_t end = ts_node_end_byte(rule);
6428 while (p < end && (src[p] == ' ' || src[p] == '\t')) {
6429 p++;
6430 }
6431 if (p >= end || src[p] != ':') {
6432 return false;
6433 }
6434 while (p < end && src[p] == ':') {
6435 p++;
6436 }
6437 for (bool kw = true; kw;) {
6438 while (p < end && (src[p] == ' ' || src[p] == '\t')) {
6439 p++;
6440 }
6441 kw = false;
6442 for (int i = 0; kws[i]; i++) {
6443 size_t n = strlen(kws[i]);
6444 if (p + n < end && strncmp(src + p, kws[i], n) == 0 &&
6445 (src[p + n] == ' ' || src[p + n] == '\t')) {
6446 p += (uint32_t)n;
6447 kw = true;
6448 break;
6449 }
6450 }
6451 }
6452 uint32_t name = p;
6453 while (p < end && make_name_char(src[p])) {
6454 p++;
6455 }
6456 if (p == name) {
6457 return false;
6458 }
6459 while (p < end && (src[p] == ' ' || src[p] == '\t')) {
6460 p++;
6461 }
6462 if (p < end && src[p] == ':') {
6463 while (p < end && src[p] == ':') {
6464 p++;
6465 }
6466 return p < end && src[p] == '=';
6467 }
6468 return p < end && (src[p] == '=' ||
6469 (strchr("+?!", src[p]) && p + SKIP_ONE < end && src[p + SKIP_ONE] == '='));
6470}
6471
6472/* Make: a rule names several targets (`up down: deps`), each a goal
6473 * `make <target>` runs. The rule's definition carries the first target;

Callers 1

extract_func_defFunction · 0.85

Calls 2

cbm_find_child_by_kindFunction · 0.85
make_name_charFunction · 0.85

Tested by

no test coverage detected