title: Antlr Tree Grammar
body: <p>I am having trouble moving from parser grammar to tree grammar, the problem comes when i use tree operators (^,!) instead of rewrite rules (->)</p>
  
  <pre><code>where_clause
      :   'where'! condition_or
      ;
  
  condition_or
      :   condition_and ( 'or'^ condition_and )*
      ;
  
  condition_and
      :   condition_expr ( 'and'^ condition_expr )*
      ;
  
  condition_expr
      :   condition_comparision
  //  |   condition_in
  //  |   condition_like
      ;
  
  condition_comparision
      :   column_identifier ('=' | '!=' | '&gt;' | '&lt;')^ sql_element
      ;
  </code></pre>
  
  <p>For the above parser grammar, how would the tree grammer look like ? Since this isn't recursive I wont be able to collapse this into a single rule in the tree grammar.</p>
  
  <p>The other alternative to forcefully rewrite the parser grammar using rewrite syntax</p>
  
  <pre><code>condition_or
      :   condition_and -&gt; condition_and 
       ( 'or' x=condition_and -&gt; ^('or' condition_or $x))*
      ;
  </code></pre>
  
  <p>Is there any simpler way to do this ?</p>
  
  <p>Thanks</p>