what would be a quick way to do nested splitting of brackets in python?
<p>I have a file of the following format:</p>

<pre><code>ID1 { some text }
ID2 { some text }
</code></pre>

<p>They don't have to come line by line format, so that we can have:</p>

<pre><code>ID1 { some [crlf]
text [crlf]
}

ID2 [crlf] { some t [crlf]
ex [crlf]
t}
</code></pre>

<p>and so on, meaning <code>some text</code> can be more than one line and there could be a <code>CRLF</code> immediately following <code>ID</code>. The main invariant is that all IDs are enclosed by <code>{</code> <code>}</code>.
The thing is that <code>some text</code> itself could have <code>{</code> and <code>}</code> in it.</p>

<p>What would be a quick way to take such a file and separate it into a list of strings, each being <code>ID { text }</code>, while taking into account nested brackets?</p>

<p>Taking into account some error analysis, in case brackets are not balanced, would be great.</p>
