title: ANTLR4: Tree construction
body: <p>I am extending the baseClass Listener and am attempting to read in some values, however there doesnt seem to be any hierrarchy in the order.</p>
  
  <p>A cut down version of my grammar is as follows:</p>
  
  <pre><code>start: config_options+
  config_options: (KEY) EQUALS^ (PATH | ALPHANUM) (' '|'\r'|'\n')* ;
  
  KEY: 'key' ;
  EQUALS: '=' ;
  ALPHANUM: [0-9a-zA-Z]+ ;
  </code></pre>
  
  <p>However the parse tree of this implementation is flat at the config_options level (Terminal level) i.e.the rule start has many children of config_options but EQUALS is not the root of subtrees of config_options, all of the TOKENS have the rule config_options as root node. How can I make one of the terminals a root node instead? </p>
  
  <p>In this particular rule I dont want any of the spaces to be captured, I know that there is the -> skip directed for the lexer however there are some cases where I do want the space. i.e. in String '"'(ALPHANUM|' ')'"'</p>
  
  <p>(Note: the ^ does not seem to work)</p>
  
  <p>an example for input is:</p>
  
  <p>key=abcdefg</p>
  
  <p>key=90weata</p>
  
  <p>key=acbefg9</p>
  
  <p>All I want to do is extract the key and value pairs. I would expect that the '=' would be the root and the two children would be the key and the value.</p>