title: How to properly locate unbalanced parenthesis in source code?
body: <p>Recently I learned some text editor has functions to check whether all parentheses are balanced inside a file. (e.g. check-parens in Emacs). It may even be able to highlight the 1st unbalanced parenthesis if there is any. However I am not clear whether there is a way to properly locate it instead of always highlight the 1st unbalanced occurrence. </p>
  
  <p>Consider below code:</p>
  
  <pre><code>void foo()
  {
    int some_num0 = 0;
    {
      int some_num1 = 1;
      {
        int some_num2 = 2;
        { 
          int some_num3 = 3;  
          //ops I forgot to close this block.
      }   
    }
  }
  </code></pre>
  
  <p>A simple balance check, (e.g. check-parens in Emacs) will bring me to the opening brace of <code>foo</code>'s definition. However a more reasonable indication should bring me to somewhere around the innermost level, the one near some_num3. Is there a way to achieve this?</p>