예제 #1
0
bool CFile::ConsumeComment()
{
    if (m_buffer[m_pos] == '/' && m_buffer[m_pos + 1] == '*')
    {
        m_pos += 2;
        while (m_buffer[m_pos] != '*' && m_buffer[m_pos + 1] != '/')
        {
            if (m_buffer[m_pos] == 0)
                return false;
            if (!ConsumeNewline())
                m_pos++;
        }
        m_pos += 2;
        return true;
    }
    else if (m_buffer[m_pos] == '/' && m_buffer[m_pos + 1] == '/')
    {
        m_pos += 2;
        while (!ConsumeNewline())
        {
            if (m_buffer[m_pos] == 0)
                return false;
            m_pos++;
        }
        return true;
    }

    return false;
}
/**
 * This method is repeatedly called by the tokenizer. 
 * Each time, we determine the kind of token we're about to 
 * read, and then we call the appropriate method to handle
 * that token type.
 *  
 * @param  aScanner The source of our input.
 * @param  aFlushTokens An OUT parameter to tell the caller whether it should
 *                      process our queued tokens up to now (e.g., when we
 *                      reach a <script>).
 * @return Success or error
 */
nsresult
nsHTMLTokenizer::ConsumeToken(nsScanner& aScanner, bool& aFlushTokens)
{
  PRUnichar theChar;
  CToken* theToken = nullptr;

  nsresult result = aScanner.Peek(theChar);

  switch(result) {
    case kEOF:
      // Tell our caller that'we finished.
      return result;

    case NS_OK:
    default:
      if (!(mFlags & NS_IPARSER_FLAG_PLAIN_TEXT)) {
        if (kLessThan == theChar) {
          return ConsumeTag(theChar, theToken, aScanner, aFlushTokens);
        } else if (kAmpersand == theChar) {
          return ConsumeEntity(theChar, theToken, aScanner);
        }
      }

      if (kCR == theChar || kLF == theChar) {
        return ConsumeNewline(theChar, theToken, aScanner);
      } else {
        if (!nsCRT::IsAsciiSpace(theChar)) {
          if (theChar != '\0') {
            result = ConsumeText(theToken, aScanner);
          } else {
            // Skip the embedded null char. Fix bug 64098.
            aScanner.GetChar(theChar);
          }
          break;
        }
        result = ConsumeWhitespace(theChar, theToken, aScanner);
      }
      break;
  }

  return result;
}
예제 #3
0
void CFile::SkipWhitespace()
{
    while (ConsumeHorizontalWhitespace() || ConsumeNewline())
        ;
}