MCPcopy Create free account
hub / github.com/URLab-Sim/UnrealRoboticsLab / _check_brace_balance

Function _check_brace_balance

Scripts/codegen/_codegen_inject.py:79–91  ·  view source on GitHub ↗

Emit a diagnostic when an injected block has an obvious brace imbalance.

(body: str, tag: str, source: str)

Source from the content-addressed store, hash-verified

77
78
79def _check_brace_balance(body: str, tag: str, source: str) -> None:
80 """Emit a diagnostic when an injected block has an obvious brace
81 imbalance."""
82 stripped = _strip_cpp_braces_in_strings(body)
83 opens = stripped.count("{")
84 closes = stripped.count("}")
85 if opens != closes:
86 _diag_add(
87 f"[diagnostic] {source}: injected block for tag "
88 f"CODEGEN_{tag} has unbalanced braces (open={opens}, "
89 f"close={closes}). The generated .cpp will not compile.",
90 source=source,
91 )
92
93
94_TAG_PATTERN_CACHE: Dict[str, "re.Pattern[str]"] = {}

Callers 1

inject_between_tagsFunction · 0.85

Calls 2

_diag_addFunction · 0.90

Tested by

no test coverage detected