title: ANTLR Semantic predicates
body: <p>I am trying to use semantic predicates in ANTLR for the following grammar rule </p>
  
  <pre><code>test[n]
         :({n==0}? =&gt; ~('a'))
         |({n==1}? =&gt; ~('b'))
         |({n==2}? =&gt; ~('c'))
         ;
  </code></pre>
  
  <p>However, ANTLR does not let me define the grammar in such a way, requiring that at least one of the alternatives be default. The exact error displayed is a reference error, for the parameter n. </p>
  
  <p>My aim is that I want one, and only one of the alternative to be visible at any given instant of time. Any ideas as to how to go about doing this? </p>
  
  <p>Thanks!</p>