public static int findEndOfString(String str,int loc,int line) throws ParseAlgorithmException {
  int pos=loc + 1;
  boolean found=false;
  while ((!found) && (pos < str.length())) {
    char c=str.charAt(pos);
    if (c == '"') {
      found=true;
    }
 else     if (c == '\\' && (pos < str.length() - 1)) {
      pos++;
    }
    pos++;
  }
  if (!found) {
    throw new ParseAlgorithmException("Unterminated string begun at line " + "\n    line " + (line + 1) + ", column "+ (loc + 1));
  }
  return pos;
}

public static int findEndOfString ( String str , int loc , int line ) throws ParseAlgorithmException { int pos = loc + 1 ; boolean found = false ; while ( ( ! found ) && ( pos < str . length ( ) ) ) { char c = str . charAt ( pos ) ; if ( c == '"' ) { found = true ; } else if ( c == '\\' && ( pos < str . length ( ) - 1 ) ) { pos ++ ; } pos ++ ; } if ( ! found ) { throw new ParseAlgorithmException ( "Unterminated string begun at line " + "\n    line " + ( line + 1 ) + ", column " + ( loc + 1 ) ) ; } return pos ; }
this method assumes that str is a string whose character at position loc is a quote ( " ) . it returns the position immediately after the matching quote that ends a tla + string . if there is no matching quote , then it throws a parsealgorithmexception , reporting the error at line line + 1 , column loc + 1
