public static String convert(String prefix){
  StringBuilder sb=new StringBuilder();
  prefix=prefix.replace('\n',';');
  String[] lines=prefix.split("[;]");
  for (  String line : lines) {
    List<String> tokens=new ArrayList<String>();
    char[] c=UnsafeString.getChars(line);
    int lastidx=0;
    int idx=0;
    while (idx < c.length) {
      while (c[idx] != '(' && c[idx] != ')' && c[idx] != ',') {
        idx++;
      }
      if (idx != lastidx) {
        tokens.add(new String(c,lastidx,idx - lastidx));
      }
      idx++;
      lastidx=idx;
    }
    Collections.reverse(tokens);
    for (    String token : tokens) {
      sb.append(token);
      sb.append("\n");
    }
  }
  return sb.toString();
}

public static String convert ( String prefix ) { StringBuilder sb = new StringBuilder ( ) ; prefix = prefix . replace ( '\n' , ';' ) ; String [ ] lines = prefix . split ( "[;]" ) ; for ( String line : lines ) { List < String > tokens = new ArrayList < String > ( ) ; char [ ] c = UnsafeString . getChars ( line ) ; int lastidx = 0 ; int idx = 0 ; while ( idx < c . length ) { while ( c [ idx ] != '(' && c [ idx ] != ')' && c [ idx ] != ',' ) { idx ++ ; } if ( idx != lastidx ) { tokens . add ( new String ( c , lastidx , idx - lastidx ) ) ; } idx ++ ; lastidx = idx ; } Collections . reverse ( tokens ) ; for ( String token : tokens ) { sb . append ( token ) ; sb . append ( "\n" ) ; } } return sb . toString ( ) ; }
converts prefix to postfix , considering the arguments of the prefix notation are in the order they will be popped out of the stack
