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

Function dg_flow_statement

internal/cbm/diagram.c:570–620  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

568}
569
570static void dg_flow_statement(dg_t *dg, dg_str_t s, uint32_t line) {
571 if (dg_starts(s, "click ")) {
572 dg_mermaid_click(dg, s, line);
573 return;
574 }
575 static const char *const skip[] = {"classDef ", "class ", "style ", "linkStyle ",
576 "click ", "direction ", "end", NULL};
577 for (int k = 0; skip[k]; k++) {
578 if (dg_starts(s, skip[k])) {
579 return;
580 }
581 }
582 if (dg_starts(s, "subgraph")) {
583 /* `subgraph id [title]`, `subgraph id[title]`, or `subgraph Some title`
584 * (the title is its id too) */
585 dg_str_t rest = dg_trim(dg_s(s.p + CBM_SZ_8, s.n - CBM_SZ_8));
586 dg_str_t id;
587 dg_str_t label;
588 size_t j = dg_flow_node(rest, 0, &id, &label);
589 if (j == 0) {
590 return;
591 }
592 size_t k = dg_skip_ws(rest, j);
593 if (!label.n && k < rest.n && rest.p[k] == '[') {
594 dg_shape(rest, k, &label);
595 } else if (!label.n && k < rest.n) {
596 id = rest; /* a title of several words */
597 label = rest;
598 }
599 dg_element(dg, id, label, "subgraph", line);
600 return;
601 }
602 dg_group_t left;
603 size_t i = dg_flow_group(dg, s, 0, line, &left);
604 while (i < s.n && left.n) {
605 const char *style = NULL;
606 dg_str_t label;
607 size_t j = dg_flow_edge(s, i, &style, &label);
608 if (j == i) {
609 return;
610 }
611 dg_group_t right;
612 i = dg_flow_group(dg, s, j, line, &right);
613 for (int a = 0; a < left.n; a++) {
614 for (int b = 0; b < right.n; b++) {
615 dg_arrow(dg, left.ids[a], right.ids[b], label, style, line);
616 }
617 }
618 left = right;
619 }
620}
621
622static void dg_flowchart(dg_t *dg, dg_lines_t *it) {
623 dg_str_t ln;

Callers 1

dg_flowchartFunction · 0.85

Calls 11

dg_startsFunction · 0.85
dg_mermaid_clickFunction · 0.85
dg_trimFunction · 0.85
dg_sFunction · 0.85
dg_flow_nodeFunction · 0.85
dg_skip_wsFunction · 0.85
dg_shapeFunction · 0.85
dg_elementFunction · 0.85
dg_flow_groupFunction · 0.85
dg_flow_edgeFunction · 0.85
dg_arrowFunction · 0.85

Tested by

no test coverage detected