title: ANTLR4: Cannot find symbol op
body: <p>I am doing the Calc/Labeled Expression tutorial from the ANTLRv4 book and when I compile I get this:</p>
  
  <pre><code>EvalVisitor.java:33: error: cannot find symbol
          if ( ctx.op.getType() == CalcParser.MUL || ctx.op.getType() == CalcParser.MIDDOT ) {
                  ^
    symbol:   variable op
    location: variable ctx of type MulDivContext
  </code></pre>
  
  <p>In fairness, I have modified it a bit playing around. My grammar looks like this:</p>
  
  <pre><code>expr    : expr ( STAR | FSLASH | DIVIDE | MIDDOT ) expr     # MulDiv
  </code></pre>
  
  <p>And those are defined in a CommonLexer file like so:</p>
  
  <pre><code>lexer grammar CommonLexerRules;
  
      ID                      :   [a-zAZ]+ ;
      INT                     :   [0-9]+ ;
      STAR                    :   '*';
  </code></pre>
  
  <p>This works fine with grun and a test file is lexed correctly. However, I think I have changed how it's working by defining some alternatives for *. That is, I don't want * to always mean Multiplication, I also want to parse MIDDOT '·' as multiplication.</p>
  
  <p>My problem is, there doesn't seem to be any '.op' in the generated code? </p>
  
  <p>What this looks like is something like this:</p>
  
  <pre><code>  *
   / \
  a   b
  </code></pre>
  
  <p>Where a,b,and * are expr. So what I want, is to get access to * as some kind of token that I can compare angainst CalcParser.MUL and CalcParser.MIDDOT etc.</p>
  
  <p>Any help would be appreciated.</p>
  
  <p>/Jason</p>