src/Generic/reader/SGMLTag.cpp
/**
 * @param source the input text.
 * @param start the position just after the tag name.
 * @param max the position of the closing angle bracket.
 */
@param source the input text.
@param start the position just after the tag name.
@param max the position of the closing angle bracket.
@param source the input text . @param start the position just after the tag name . @param max the position of the closing angle bracket .
LocatedString* SGMLTag::getTagCorefID(const LocatedString& source, int start, int max) {
	if (source.charAt(start) == L':') {
		start++;
		int end = start;
		while (end < max && iswdigit(source.charAt(end)))
			end++;
		return source.substring(start, end);
	} 
	else {
		start++;
		while ((start < max) && iswspace(source.charAt(start))) {
			start++;
		}
		if ((start + 8) >= max) {
			return NULL;
		}
		if ((towupper(source.charAt(start)) == L'C') &&
			(towupper(source.charAt(start + 1)) == L'O') &&
			(towupper(source.charAt(start + 2)) == L'R') &&
			(towupper(source.charAt(start + 3)) == L'E') &&
			(towupper(source.charAt(start + 4)) == L'F') &&
			(towupper(source.charAt(start + 5)) == L'I') &&
			(towupper(source.charAt(start + 6)) == L'D') &&
			(!iswalnum(source.charAt(start + 7))))
		{
			start += 7;
			while ((start < max) && iswspace(source.charAt(start))) {
				start++;
			}
			if ((start >= max) || (source.charAt(start) != L'=')) {
				return NULL;
			}
			start++;
			while ((start < max) && iswspace(source.charAt(start))) {
				start++;
			}
			if (start >= max) {
				return NULL;
			}
			wchar_t first_char = source.charAt(start);
			if ((first_char == L'\'') || (first_char == L'"')) {
				start++;
				int end = start;
				while ((end < max) && (source.charAt(end) != first_char)) {
					if (!iswdigit(source.charAt(end)))	
					{
						throw UnexpectedInputException("SGMLTag::getTagCorefID()",
														"non-numeric COREFID attribute");
					}
					end++;
				}
				if (end >= max) {
					throw UnexpectedInputException(
						"SGMLTag::getTagCorefID()",
						"unterminated COREFID attribute");
				}
				return source.substring(start, end);
			}
			else {
				int end = start;
				while ((end < max) && !iswspace(source.charAt(end))) {
					if (!iswdigit(source.charAt(end)))	
					{
						throw UnexpectedInputException("SGMLTag::getTagCorefID()",
														"non-numeric COREFID attribute");
					}
					end++;
				}
				return source.substring(start, end);
			}
		}
		else {
			return NULL;
		}
	}
}
LocatedString * SGMLTag :: getTagCorefID ( const LocatedString & source , int start , int max ) { if ( source . charAt ( start ) == L' ' ) { start ++ ; int end = start ; while ( end < max && iswdigit ( source . charAt ( end ) ) ) end ++ ; return source . substring ( start , end ) ; } else { start ++ ; while ( ( start < max ) && iswspace ( source . charAt ( start ) ) ) { start ++ ; } if ( ( start + 8 ) >= max ) { return NULL ; } if ( ( towupper ( source . charAt ( start ) ) == L' ' ) && ( towupper ( source . charAt ( start + 1 ) ) == L' ' ) && ( towupper ( source . charAt ( start + 2 ) ) == L' ' ) && ( towupper ( source . charAt ( start + 3 ) ) == L' ' ) && ( towupper ( source . charAt ( start + 4 ) ) == L' ' ) && ( towupper ( source . charAt ( start + 5 ) ) == L' ' ) && ( towupper ( source . charAt ( start + 6 ) ) == L' ' ) && ( ! iswalnum ( source . charAt ( start + 7 ) ) ) ) { start += 7 ; while ( ( start < max ) && iswspace ( source . charAt ( start ) ) ) { start ++ ; } if ( ( start >= max ) || ( source . charAt ( start ) != L' ' ) ) { return NULL ; } start ++ ; while ( ( start < max ) && iswspace ( source . charAt ( start ) ) ) { start ++ ; } if ( start >= max ) { return NULL ; } wchar_t first_char = source . charAt ( start ) ; if ( ( first_char == L' \' ' ) || ( first_char == L' ' ) ) { start ++ ; int end = start ; while ( ( end < max ) && ( source . charAt ( end ) != first_char ) ) { if ( ! iswdigit ( source . charAt ( end ) ) ) { throw UnexpectedInputException ( " " , " " ) ; } end ++ ; } if ( end >= max ) { throw UnexpectedInputException ( " " , " " ) ; } return source . substring ( start , end ) ; } else { int end = start ; while ( ( end < max ) && ! iswspace ( source . charAt ( end ) ) ) { if ( ! iswdigit ( source . charAt ( end ) ) ) { throw UnexpectedInputException ( " " , " " ) ; } end ++ ; } return source . substring ( start , end ) ; } } else { return NULL ; } } }
@param source the input text.
@param source the input text .
// check for Arabic style coref (GPE:CITY:3)
 // Return the substring between the quote characters.
 // check for Chinese style coref ("GPE:CITY" COREFID=3)
 // Skip past whitespace.
 // Must be at least long enough for "COREFID=X".
 // Match the word COREFID.
 // Skip past "COREFID".
 // Skip past whitespace.
 // Skip past the '=' sign.
 // Skip past whitespace.
 // Read the attribute value.
 // Don't include the quote character in the type string.
 // Search for the closing quote character.
 // If there wasn't a closing quote character before the
 // closing angle bracket, throw an exception.
 // Return the substring between the quote characters.
 // HACK: this allows all kinds of punctuation that it shouldn't
 // Return the word terminated by whitespace or the closing angle bracket.
