Extract content of [...] after keyword, handling nested brackets.
(text, keyword)
| 36 | issues.append(f"TYPE_MISMATCH: {node} -> FE:{fe_type} BE:{be_type}") |
| 37 | |
| 38 | def extract_bracket_content(text, keyword): |
| 39 | """Extract content of [...] after keyword, handling nested brackets.""" |
| 40 | idx = text.find(keyword) |
| 41 | if idx == -1: |
| 42 | return None |
| 43 | start = text.find('[', idx) |
| 44 | if start == -1: |
| 45 | return None |
| 46 | depth = 0 |
| 47 | for i in range(start, len(text)): |
| 48 | if text[i] == '[': |
| 49 | depth += 1 |
| 50 | elif text[i] == ']': |
| 51 | depth -= 1 |
| 52 | if depth == 0: |
| 53 | return text[start+1:i] |
| 54 | return None |
| 55 | |
| 56 | # --- Extract FE inputs --- |
| 57 | inputs_content = extract_bracket_content(fe, 'defaultInputs') |