private String quoteTerminals(String words){
  StringBuilder quotedWords=new StringBuilder();
  for (  String word : words.split("\\s+"))   if (word.startsWith("[") && word.endsWith("]"))   quotedWords.append(String.format("%s ",word));
 else   quotedWords.append(String.format("\"%s\" ",word));
  return quotedWords.substring(0,quotedWords.length() - 1);
}

private String quoteTerminals ( String words ) { StringBuilder quotedWords = new StringBuilder ( ) ; for ( String word : words . split ( "\\s+" ) ) if ( word . startsWith ( "[" ) && word . endsWith ( "]" ) ) quotedWords . append ( String . format ( "%s " , word ) ) ; else quotedWords . append ( String . format ( "\"%s\" " , word ) ) ; return quotedWords . substring ( 0 , quotedWords . length ( ) - 1 ) ; }
quotes just the terminals in the yield of a tree , represented as a string . this is to force compliance with the tree class , which interprets all non - quoted strings as nonterminals .
