void append(StringBuilder str, String appendStr, Token start, Token stop) {
    String spaces = start.getInputStream().getText(new org.antlr.v4.runtime.misc.Interval(start.getStartIndex(), stop.getStopIndex()));
    spaces = spaces.substring(start.getText().length(), spaces.length() - stop.getText().length());
    str.append(spaces);
    str.append(appendStr);
  }
Append the text preserving the formatting (space symbols) between tokens
hplsql/src/main/java/org/apache/hive/hplsql/Exec.java