// --------------------------------------------------------------------------- // BlockRangeFactory: Range creation methods // --------------------------------------------------------------------------- void BlockRangeFactory::buildRanges() { if (fRangesCreated) return; if (!fKeywordsInitialized) { initializeKeywordMap(); } RangeTokenMap* rangeTokMap = RangeTokenMap::instance(); TokenFactory* tokFactory = rangeTokMap->getTokenFactory(); //for performance, once the desired specials and private use are found //don't need to compareString anymore bool foundSpecial = false; bool foundPrivate = false; for (int i=0; i < BLOCKNAMESIZE; i++) { RangeToken* tok = tokFactory->createRange(); tok->addRange(blockRanges[i*2], blockRanges[(i*2)+1]); if (!foundSpecial && XMLString::equals((XMLCh*)fgBlockNames[i] , (XMLCh*) fgBlockIsSpecials)) { tok->addRange(0xFFF0, 0xFFFD); foundSpecial = true; } if (!foundPrivate && XMLString::equals((XMLCh*)fgBlockNames[i] , (XMLCh*) fgBlockIsPrivateUse)) { tok->addRange(0xF0000, 0xFFFFD); tok->addRange(0x100000, 0x10FFFD); foundPrivate = true; } rangeTokMap->setRangeToken(fgBlockNames[i], tok); } fRangesCreated = true; }
// --------------------------------------------------------------------------- // ASCIIRangeFactory: Range creation methods // --------------------------------------------------------------------------- void ASCIIRangeFactory::buildRanges() { if (fRangesCreated) return; if (!fKeywordsInitialized) { initializeKeywordMap(); } RangeTokenMap* rangeTokMap = RangeTokenMap::instance(); TokenFactory* tokFactory = rangeTokMap->getTokenFactory(); // Create space ranges RangeToken* tok = tokFactory->createRange(); tok->addRange(chHTab, chHTab); tok->addRange(chLF, chLF); tok->addRange(chFF, chFF); tok->addRange(chCR, chCR); tok->addRange(chSpace, chSpace); rangeTokMap->setRangeToken(fgASCIISpace, tok); // Create digits ranges tok = tokFactory->createRange(); tok->addRange(chDigit_0, chDigit_9); rangeTokMap->setRangeToken(fgASCIIDigit, tok); // Create word ranges tok = tokFactory->createRange(); tok->addRange(chDigit_0, chDigit_9); tok->addRange(chLatin_A, chLatin_Z); tok->addRange(chUnderscore, chUnderscore); tok->addRange(chLatin_a, chLatin_z); rangeTokMap->setRangeToken(fgASCIIWord, tok); // Create xdigit ranges tok = tokFactory->createRange(); tok->addRange(chDigit_0, chDigit_9); tok->addRange(chLatin_A, chLatin_F); tok->addRange(chLatin_a, chLatin_a); rangeTokMap->setRangeToken(fgASCIIXDigit, tok); // Create ascii ranges tok = tokFactory->createRange(); tok->addRange(0x00, 0x7F); rangeTokMap->setRangeToken(fgASCII, tok); fRangesCreated = true; }