Changing how Antlr4 prints a tree
<p>I am using Antlr4 in IntelliJ to make a small compiler for arithmetic expressions.
I want to print the tree and use this code snippet to do so.</p>

<pre><code>    JFrame frame = new JFrame("Tree");
    JPanel panel = new JPanel();
    TreeViewer viewr = new TreeViewer(Arrays.asList(
    parser.getRuleNames()),tree);
    viewr.setScale(2);//scale a little
    panel.add(viewr);
    frame.add(panel);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setSize(400,400);
    frame.setVisible(true);
</code></pre>

<p>This makes a tree which looks like this, for the input <code>3*5\n</code></p>

<p><a href="https://i.stack.imgur.com/xn8DY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xn8DY.png" alt="enter image description here"></a></p>

<p>Is there a way to adjust this so it reads from top to bottom</p>

<pre><code>                    Statement

              Expression         /n
         INT      *     INT 
          3              5
</code></pre>

<p>instead?
My grammar is defined as:</p>

<pre><code>grammar Expression;

statement:   expression ENDSTATEMENT           # printExpr
        |   ID '=' expression ENDSTATEMENT     # assign
        |   ENDSTATEMENT                       # blank
        ;

expression:   expression MULTDIV expression      # MulDiv
          |   expression ADDSUB expression       # AddSub
          |   INT                                # int
          |   FLOAT                              # float
          |   ID                                 # id
          |   '(' expression ')'                 # parens
          ;

ID  :   [a-zA-Z]+ ;      // match identifiers
INT :   [0-9]+ ;         // match integers
MULTDIV : ('*' | '/');   //match multiply or divide
ADDSUB  : ('+' | '-');   //match add or subtract
FLOAT:  INT '.' INT;     //match a floating point number
ENDSTATEMENT:'\r'? '\n' ;     // return newlines to parser (is end-statement signal)
WHITESPACE  :   [ \t]+ -&gt; skip ; // ignore whitespace
</code></pre>