Пример #1
0
XMLCh ReaderMgr::skipUntilIn(const XMLCh* const listToSkip)
{
    XMLCh nextCh;
    // If we get an end of file char, then return
    while ((nextCh = peekNextChar())!=0)
    {
        if (XMLString::indexOf(listToSkip, nextCh) != -1)
            break;

        // Its one of ours so eat it
        getNextChar();
    }
    return nextCh;
}
Пример #2
0
// check if a specific line position contains a keyword.
bool ASBase::findKeyword(const string& line, int i, const string& keyword) const
{
    assert(isCharPotentialHeader(line, i));
    // check the word
    const size_t keywordLength = keyword.length();
    const size_t wordEnd = i + keywordLength;
    if(wordEnd > line.length()) return false;
    if(line.compare(i, keywordLength, keyword) != 0) return false;
    // check that this is not part of a longer word
    if(wordEnd == line.length()) return true;
    if(isLegalNameChar(line[wordEnd])) return false;
    // is not a keyword if part of a definition
    const char peekChar = peekNextChar(line, wordEnd - 1);
    if(peekChar == ',' || peekChar == ')') return false;
    return true;
}
Пример #3
0
/**
 * check if a specific line position contains a keyword.
 *
 * @return    true if the word was found. false if the word was not found.
 */
bool ASEnhancer::findKeyword(const string &line, int i, const char *keyword) const
{
	if (line.compare(i, strlen(keyword), keyword) == 0)
	{
		// check that this is a header and not a part of a longer word
		// (e.g. not at its beginning, not at its middle...)

		int lineLength = line.length();
		int wordEnd = i + strlen(keyword);
		char startCh = keyword[0];      // first char of header
		char endCh = 0;                // char just after header
		char prevCh = 0;               // char just before header

		if (wordEnd < lineLength)
		{
			endCh = line[wordEnd];
		}
		if (i > 0)
		{
			prevCh = line[i-1];
		}

		if (prevCh != 0
		        && isLegalNameCharX(startCh)
		        && isLegalNameCharX(prevCh))
		{
			return false;
		}
		else if (wordEnd >= lineLength
		         || !isLegalNameCharX(startCh)
		         || !isLegalNameCharX(endCh))
		{
			// is not a keyword if part of a definition
			char peekChar = peekNextChar(line, wordEnd - 1);
			if (peekChar == ',' || peekChar == ')')
				return false;
			return true;
		}
		else
		{
			return false;
		}
	}

	return false;
}
Пример #4
0
XMLCh ReaderMgr::skipUntilIn(const XMLCh* const listToSkip)
{
    XMLCh nextCh;
    while (true)
    {
        nextCh = peekNextChar();

        if (!nextCh)
            break;

        if (XMLString::indexOf(listToSkip, nextCh) != -1)
            break;

        // Its one of ours so eat it
        getNextChar();
    }
    return nextCh;
}
Пример #5
0
// check if a specific line position contains a header.
const string* ASBase::findHeader(const string& line, int i,
                                 const vector<const string*>* possibleHeaders) const
{
	assert(isCharPotentialHeader(line, i));
	// check the word
	size_t maxHeaders = possibleHeaders->size();
	for (size_t p = 0; p < maxHeaders; p++)
	{
		const string* header = (*possibleHeaders)[p];
		const size_t wordEnd = i + header->length();
		if (wordEnd > line.length())
			continue;
		int result = (line.compare(i, header->length(), *header));
		if (result > 0)
			continue;
		if (result < 0)
			break;
		// check that this is not part of a longer word
		if (wordEnd == line.length())
			return header;
		if (isLegalNameChar(line[wordEnd]))
			continue;
		const char peekChar = peekNextChar(line, wordEnd - 1);
		// is not a header if part of a definition
		if (peekChar == ',' || peekChar == ')')
			break;
		// the following accessor definitions are NOT headers
		// goto default; is NOT a header
		// default(int) keyword in C# is NOT a header
		if ((header == &AS_GET
		        || header == &AS_SET
		        || header == &AS_DEFAULT)
		        && (peekChar == ';' || peekChar == '(' || peekChar == '='))
			break;
		return header;
	}
	return nullptr;
}
Пример #6
0
void CodeDocument::Iterator::skipWhitespace()
{
    while (CharacterFunctions::isWhitespace (peekNextChar()))
        skip();
}