title: How do I do nested parenthesis in antlr4?
body: <p>I have the following grammar</p>
  
  <pre><code>query
      : unquoted_str+
      | '(' query ')'
      ;
  
  unquoted_str
      : UNQUOTED_STR
      ;
  
  UNQUOTED_STR
      : [A-Za-z_][A-Za-z0-9_-]*
      ;
  WS
      :   [ \t\r\n]+ -&gt; skip
      ;
  </code></pre>
  
  <p>I want to be able to execute the following query:</p>
  
  <blockquote>
    <p><code>abc (def (hij))</code></p>
  </blockquote>
  
  <p>But I keep getting the error:</p>
  
  <pre><code>line 1:4 extraneous input '(' expecting {&lt;EOF&gt;, UNQUOTED_STR}
  line 1:8 extraneous input ')' expecting {&lt;EOF&gt;, UNQUOTED_STR}
  </code></pre>
  
  <p>Have tried to fix the issue by adding EOF to various places but to no avail.  Any help would be great.</p>