title: If statement to tree representation in ANTLR
body: <p>I have the following if statement that parses correctly:</p>
  
  <pre><code>ifStatement
      : 'IF' expression 'THEN' statementBlock 
          (options {greedy=true;} 
              : 'ELSE' statementBlock)?
  
      ;
  </code></pre>
  
  <p>Now, I want to parse this into an AST. This is how I did it:</p>
  
  <pre><code>ifStatement
      : 'IF'^ expression 'THEN'! statementBlock 
          (options {greedy=true;} 
              : 'ELSE'! statementBlock)?
  
      ;
  </code></pre>
  
  <p>Added <code>!</code> and <code>^</code>, as <code>-&gt;</code> building instruction didn't seem to work.</p>
  
  <p>My result is an AST with 3 children: 1 is the conditional, 2 and 3 are the statement blocks. The else part is optional: if there is no else, node 3 is missing.</p>
  
  <p>The problem is that the statement blocks are always empty. How to fix that?</p>