It doesn&#x27;t have to be fully language aware, but it has to understand most, if not all, of the syntax. As soon as you start trying to match braces, you need to handle strings, comments, and probably a whole bunch of stuff I&#x27;m not thinking of.<p>Here&#x27;s an idea: wouldn&#x27;t it by trivial for &lt;insert your favourite language compiler here&gt; to expose the AST of your code, and solve this problem the easy way?