private boolean isTermiteFree(String aTree){
  int bracketCount=0;
  boolean justOpened=false;
  if (aTree.isEmpty() || aTree.charAt(0) != '(') {
    return false;
  }
  for (int idx=0; idx < aTree.length(); idx++) {
    char c=aTree.charAt(idx);
switch (c) {
case '(':
      bracketCount++;
    if (justOpened) {
      return false;
    }
  justOpened=true;
break;
case ' ':
break;
case ')':
bracketCount--;
if (justOpened) {
return false;
}
if (bracketCount < 0) {
return false;
}
justOpened=false;
break;
default :
justOpened=false;
break;
}
}
return bracketCount == 0;
}

private boolean isTermiteFree ( String aTree ) { int bracketCount = 0 ; boolean justOpened = false ; if ( aTree . isEmpty ( ) || aTree . charAt ( 0 ) != '(' ) { return false ; } for ( int idx = 0 ; idx < aTree . length ( ) ; idx ++ ) { char c = aTree . charAt ( idx ) ; switch ( c ) { case '(' : bracketCount ++ ; if ( justOpened ) { return false ; } justOpened = true ; break ; case ' ' : break ; case ')' : bracketCount -- ; if ( justOpened ) { return false ; } if ( bracketCount < 0 ) { return false ; } justOpened = false ; break ; default : justOpened = false ; break ; } } return bracketCount == 0 ; }
check if a given penn tree will be rejected by tgrep2 .
