Performance improvement - do not alloc new instances of std::string in CommonToken::getText()
Debug print
SQL AST start
SQL AST
SQL AST
SQL AST
next node partial fix
nextNode nextTree fixes (but still has a leak)
AST creation
rewrites having predicates
AST generation
s004 start rule
AST generation
AST generation
AST generation - SEGFAULT fix
AST generation - standard_function fixes
Segfault fix

Explanation:
For code(using labels e1, e2) like this:

sample_clause
    :    sample_key block_key?
        LEFT_PAREN e1=expression (COMMA e2=expression)? RIGHT_PAREN
        seed_part?
        -> ^(sample_key block_key? ^(EXPR $e1) ^(EXPR $e2)? seed_part?)
    ;

ANTLR generates code like this:
	e1=expression();
	...
	if ( this->get_backtracking()==0 ) stream_expression.add(e1.tree);
	...
	...
        // AST REWRITE
        // elements: e1, e2, block_key, sample_key, seed_part
        // token labels:
        // rule labels: retval, e1, e2
        // token list labels:
        // rule list labels:
        // wildcard labels:
        if ( this->get_backtracking()==0 ) {
            retval.tree = std::move(root_0);
            RewriteRuleSubtreeStream<ImplTraits> stream_retval(get_psrstate()->get_treeAdaptor(), "rule retval",retval.tree); // retval
            RewriteRuleSubtreeStream<ImplTraits> stream_e1(get_psrstate()->get_treeAdaptor(), "rule e1",e1.tree); // rewrite alias
            RewriteRuleSubtreeStream<ImplTraits> stream_e2(get_psrstate()->get_treeAdaptor(), "rule e2",e2.tree); // rewrite alias
	...

The variable e1 of type expression_return is assigned into two different SubTreeStreams.
Since destructive copying is used(unique_ptr) the second assignment inserts NULL ptr into stream_e1.

This fix changes the behaviour. RewriteRuleSubtreeStream no mode holds instances of unique_ptr but instances of reference_wrapper<TreeTypePtr>
AST generation fixes (model)
Revert for commit 999394b01c46e59836d7599b8b7c0354e5de113a + fix.

RewriteRuleSubtreeStream now contains cloned trees.
Fix fixes this case:

unpivot_in_elements
    :   (    column_name
        |    LEFT_PAREN column_name (COMMA column_name)* RIGHT_PAREN
        )
        (     as_key
         (    constant
         |    (LEFT_PAREN)=> LEFT_PAREN constant (COMMA constant)* RIGHT_PAREN
         )
        )?
        -> column_name+ ^(PIVOT_ALIAS constant+)?
    ;

The AST tree contains multiple instances of "column_name".
RewriteRuleSubtreeStream can not contain reference into matched tree as it would get overwritten
in every "loop". Parse tree value can not be moved into RewriteRuleSubtreeStream as this could be also
used in rewrite allias (also instance of the RewriteRuleSubtreeStream).
a006