title: Skip general rule enter/exit listener method in favor of more specific one? (ANTLR4)
body: <p>I have generated a grammar in ANTLR4. A sample excerpt is shown below:</p>
  
  <pre><code>list    : defunExpr            # defun
          : lambdaExpr           # lambda
          : condExpr             # cond
  
          ...
  
          : items                # other
          ;
  </code></pre>
  
  <p>The rules are listed in order of priority and are called as appropriate when testing the grammar. All higher priority rules of #defun, #lambda, #cond, etc. would also match items (#other) if they did not match higher up (expected behavior of placing higher-priority rules before lower).</p>
  
  <p>I then implemented a simple listener-based application in Java, which simply formats the parsed code and prints it back out the the console. I have overridden the appropriate enter/exit methods for #defun, #lambda, #cond, etc. I would like to implement a generalized catch-all for items which do not match the more specific rule. However, when I implement enter/exit methods for #other, it executes for every matched rule further up the priority as well, effectively outputting formatted code twice for rules such as #defun, #lambda, #cond, etc.</p>
  
  <p>Is there some way to achieve this behavior? I have a handful of specific rules I want to implement, and then have a general case catch the others. The grammar parses properly (test rig shows expected behavior over numerous test cases), but the catch-all method (enterOther) seems to act upon the specific rules as well.</p>
  
  <p>EDIT: Wow, after all this time and posting this question, I now actually believe it is a grammar error. I will leave the question open until I verify, however.</p>