title: How to know which alternative rule ANTLR parser is currently in during visit without changing the grammar
body: <p>I looked at these and they don't seem to solve the problem:</p>
  <p><a href="https://stackoverflow.com/questions/70360275/is-there-a-way-to-know-which-alternative-rule-antlr-parser-is-currently-in">Is there a way to know which alternative rule ANTLR parser is currently in?</a></p>
  <p><a href="https://stackoverflow.com/questions/70148460/how-to-know-which-alternative-rule-antlr-parser-is-currently-in-during-visit">How to know which alternative rule ANTLR parser is currently in during visit</a></p>
  <p>For example:</p>
  <pre><code>oC_ListOperatorExpression : 
  ( SP IN SP? oC_PropertyOrLabelsExpression ) 
  | ( SP? '[' oC_Expression ']' ) 
  | ( SP? '[' oC_Expression? '..' oC_Expression? ']' ) ; 
  </code></pre>
  <p>In this particular case, alternative 2 and alternative 3 have no special tokens or tokens in a fixed position I can leverage to differentiate them.</p>
  <p>How can I tell which alternative am I using in the following without changing the grammar?</p>
  <pre><code>antlrcpp::Any visitOC_ListOperatorExpression( 
   CypherParser::OC_ListOperatorExpressionContext* ctx) override {
  } 
  </code></pre>
  <p>I am using the c++ runtime of ANTLR4 4.9.3.1.</p>
  <p>The full grammar:
  <a href="https://s3.amazonaws.com/artifacts.opencypher.org/M18/Cypher.g4" rel="nofollow noreferrer">https://s3.amazonaws.com/artifacts.opencypher.org/M18/Cypher.g4</a></p>