24#include <rtl/character.hxx>
25#include <unicode/uchar.h>
33 StartIdentifier = 0x0001,
34 InIdentifier = 0x0002,
258 return strcmp(
static_cast<char const *
>(arg1), *
static_cast<char *
const *
>(arg2) );
267 if (rtl::isAsciiAlpha(c))
282 bool getNextToken(std::u16string_view::const_iterator& pos, std::u16string_view::const_iterator end,
TokenType& reType,
283 std::u16string_view::const_iterator& rpStartPos, std::u16string_view::const_iterator& rpEndPos)
const;
294 std::vector<HighlightPortion>& portions)
const;
295 void setKeyWords(
const char** ppKeyWords, sal_uInt16 nCount );
302 if( c != 0 && c <= 255 )
308 bRet = (( CharFlags::StartIdentifier | CharFlags::InIdentifier ) & nTestFlags)
316 ppListKeyWords = ppKeyWords;
322 std::u16string_view::const_iterator& rpStartPos, std::u16string_view::const_iterator& rpEndPos)
const
336 if ( testCharFlags( c, CharFlags::Space ) )
338 while(
pos !=
end && testCharFlags( *
pos, CharFlags::Space ) )
345 else if ( testCharFlags( c, CharFlags::StartIdentifier ) )
347 bool bIdentifierChar;
354 bIdentifierChar = testCharFlags( c, CharFlags::InIdentifier );
355 if( bIdentifierChar )
358 while( bIdentifierChar );
363 if (ppListKeyWords !=
nullptr)
368 bool bCanBeKeyword =
true;
371 if( rpStartPos[
i] > 255 )
373 bCanBeKeyword =
false;
380 std::u16string_view aKWString(&*rpStartPos,
nCount);
382 RTL_TEXTENCODING_ASCII_US).toAsciiLowerCase();
383 if ( bsearch( aByteStr.getStr(), ppListKeyWords, nKeyWordCount,
sizeof(
char* ),
388 if( aByteStr ==
"rem" )
396 if ( testCharFlags( cPeek, CharFlags::EOL ) )
417 bool bIdentifierChar;
425 if( bIdentifierChar )
428 while( bIdentifierChar );
437 while(
pos !=
end && !testCharFlags( *
pos, CharFlags::EOL ) )
451 while(
pos !=
end && !testCharFlags( *
pos, CharFlags::EOL ) )
470 if (testCharFlags(c, CharFlags::EOL)) {
490 else if( c ==
'.' && (
pos ==
end || *pos < '0' || *pos >
'9' ) )
496 else if( testCharFlags( c, CharFlags::StartNumber ) )
514 while(
pos !=
end && testCharFlags( *
pos, CharFlags::InOctNumber ) )
525 while(
pos !=
end && testCharFlags( *
pos, CharFlags::InHexNumber ) )
538 bool bAfterExpChar =
false;
541 while(
pos !=
end && (testCharFlags( *
pos, CharFlags::InNumber ) ||
542 (bAfterExpChar && *
pos ==
'+' ) ||
543 (bAfterExpChar && *
pos ==
'-' ) ))
547 bAfterExpChar = ( c ==
'e' || c ==
'E' );
553 else if( testCharFlags( c, CharFlags::StartString ) )
561 while(
pos ==
end || *
pos != cEndString )
571 if( testCharFlags( c, CharFlags::EOL ) )
582 if( cEndString ==
']' )
590 else if( testCharFlags( c, CharFlags::EOL ) )
596 if( cNext != c && testCharFlags( cNext, CharFlags::EOL ) )
616 CharFlags nHelpMask = CharFlags::StartIdentifier | CharFlags::InIdentifier;
617 for(
i =
'a' ;
i <=
'z' ;
i++ )
619 for(
i =
'A' ;
i <=
'Z' ;
i++ )
625 nHelpMask = CharFlags::InIdentifier | CharFlags::StartNumber |
626 CharFlags::InNumber | CharFlags::InHexNumber;
627 for(
i =
'0' ;
i <=
'9' ;
i++ )
633 aCharTypeTab[
int(
'.')] |= CharFlags::InNumber | CharFlags::StartNumber;
637 for(
i =
'a' ;
i <=
'f' ;
i++ )
639 for(
i =
'A' ;
i <=
'F' ;
i++ )
643 for(
i =
'0' ;
i <=
'7' ;
i++ )
690 std::vector<HighlightPortion>& portions)
const
693 auto pos = rLine.begin();
697 std::u16string_view::const_iterator pStartPos;
698 std::u16string_view::const_iterator pEndPos;
701 while( getNextToken(
pos, rLine.end(),
eType, pStartPos, pEndPos ) )
703 portions.emplace_back(
704 pStartPos - rLine.begin(), pEndPos - rLine.begin(),
eType);
730 std::vector<HighlightPortion>& portions)
const
732 m_tokenizer->getHighlightPortions( rLine, portions );
const char ** ppListKeyWords
bool getNextToken(std::u16string_view::const_iterator &pos, std::u16string_view::const_iterator end, TokenType &reType, std::u16string_view::const_iterator &rpStartPos, std::u16string_view::const_iterator &rpEndPos) const
CharFlags aCharTypeTab[256]
Tokenizer(HighlighterLanguage aLang)
void getHighlightPortions(std::u16string_view rLine, std::vector< HighlightPortion > &portions) const
HighlighterLanguage const aLanguage
bool testCharFlags(sal_Unicode c, CharFlags nTestFlags) const
void setKeyWords(const char **ppKeyWords, sal_uInt16 nCount)
void getHighlightPortions(std::u16string_view rLine, std::vector< HighlightPortion > &pPortions) const
SyntaxHighlighter(const SyntaxHighlighter &)=delete
std::unique_ptr< Tokenizer > m_tokenizer
HighlighterLanguage GetLanguage() const
bool isAlpha(sal_Unicode c, bool bCompatible)
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)
const wchar_t *typedef int(__stdcall *DllNativeUnregProc)(int
static int compare_strings(const void *arg1, const void *arg2)
static const char * strListSqlKeyWords[]
static const char * strListBasicKeyWords[]