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::getTagType(const LocatedString& source, int start, int& end, int max) {
	while ((start < max) && iswspace(source.charAt(start))) {
		start++;
	}
	if ((start + 6) >= max) {
		return NULL;
	}
	if ((towupper(source.charAt(start)) == L'T') &&
		(towupper(source.charAt(start + 1)) == L'Y') &&
		(towupper(source.charAt(start + 2)) == L'P') &&
		(towupper(source.charAt(start + 3)) == L'E') &&
		(!iswalnum(source.charAt(start + 4))))
	{
		start += 4;
		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++;
			end = start;
			while ((end < max) && (source.charAt(end) != first_char)) {
				end++;
			}
			if (end >= max) {
				throw UnexpectedInputException(
					"SGMLTag::getTagType()",
					"unterminated TYPE attribute");
			}
			int temp_end = end - 1;
			while (iswdigit(source.charAt(temp_end))) {
				temp_end--;
			}
			if (towupper(source.charAt(temp_end)) == L':') 
			{ 
				end = temp_end;
			}
			return source.substring(start, end);
		}
		else {
			end = start;
			while ((end < max) && !iswspace(source.charAt(end))) {
				end++;
			}
			int temp_end = end - 1;
			while (iswdigit(source.charAt(temp_end))) {
				temp_end--;
			}
			if (towupper(source.charAt(temp_end)) == L':') 
			{ 
				end = temp_end;
			}
			return source.substring(start, end);
		}
	}
	else {
		return NULL;
	}
}
LocatedString * SGMLTag :: getTagType ( const LocatedString & source , int start , int & end , int max ) { while ( ( start < max ) && iswspace ( source . charAt ( start ) ) ) { start ++ ; } if ( ( start + 6 ) >= 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' ' ) && ( ! iswalnum ( source . charAt ( start + 4 ) ) ) ) { start += 4 ; 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 ++ ; end = start ; while ( ( end < max ) && ( source . charAt ( end ) != first_char ) ) { end ++ ; } if ( end >= max ) { throw UnexpectedInputException ( " " , " " ) ; } int temp_end = end - 1 ; while ( iswdigit ( source . charAt ( temp_end ) ) ) { temp_end -- ; } if ( towupper ( source . charAt ( temp_end ) ) == L' ' ) { end = temp_end ; } return source . substring ( start , end ) ; } else { end = start ; while ( ( end < max ) && ! iswspace ( source . charAt ( end ) ) ) { end ++ ; } int temp_end = end - 1 ; while ( iswdigit ( source . charAt ( temp_end ) ) ) { temp_end -- ; } if ( towupper ( source . charAt ( temp_end ) ) == L' ' ) { end = temp_end ; } return source . substring ( start , end ) ; } } else { return NULL ; } }
@param source the input text.
@param source the input text .
// Skip past whitespace.
 // Must be at least long enough for "TYPE=X".
 // Match the word TYPE.
 // Skip past "TYPE".
 // 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.
 // HACK: need to get rid of the extra coref info in Arabic (ex: GPE:CITY:3)
 // 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.
 // HACK: need to get rid of the extra coref info in Arabic (ex: GPE:CITY:3)
