From 90e78445822008e99d8c4a53b7251f3a825735d6 Mon Sep 17 00:00:00 2001 From: sdottaka Date: Sun, 8 Sep 2024 20:31:51 +0900 Subject: [PATCH] crystaledit/editlib/parses/*: refactor (cherry picked from commit e867c0df853fb684f862eb81903ed01f71ad1e7f) --- .../crystaledit/editlib/parsers/abap.cpp | 38 ++-- .../crystaledit/editlib/parsers/batch.cpp | 73 +++---- .../crystaledit/editlib/parsers/cplusplus.cpp | 104 ++++------ Externals/crystaledit/editlib/parsers/dcl.cpp | 157 ++++++--------- .../crystaledit/editlib/parsers/dlang.cpp | 103 ++++------ .../crystaledit/editlib/parsers/fortran.cpp | 31 ++- .../crystaledit/editlib/parsers/fsharp.cpp | 105 ++++------- Externals/crystaledit/editlib/parsers/go.cpp | 103 ++++------ Externals/crystaledit/editlib/parsers/ini.cpp | 19 +- .../crystaledit/editlib/parsers/innosetup.cpp | 103 ++++------ Externals/crystaledit/editlib/parsers/is.cpp | 115 +++++------ .../crystaledit/editlib/parsers/lisp.cpp | 154 ++++++--------- Externals/crystaledit/editlib/parsers/lua.cpp | 91 ++++----- .../crystaledit/editlib/parsers/matlab.cpp | 91 ++++----- .../crystaledit/editlib/parsers/nsis.cpp | 103 ++++------ .../crystaledit/editlib/parsers/pascal.cpp | 91 ++++----- .../crystaledit/editlib/parsers/perl.cpp | 91 ++++----- Externals/crystaledit/editlib/parsers/php.cpp | 127 +++++-------- Externals/crystaledit/editlib/parsers/po.cpp | 91 ++++----- .../editlib/parsers/powershell.cpp | 43 ++--- .../crystaledit/editlib/parsers/python.cpp | 115 +++++------ .../crystaledit/editlib/parsers/rexx.cpp | 103 ++++------ .../crystaledit/editlib/parsers/rsrc.cpp | 103 ++++------ .../crystaledit/editlib/parsers/ruby.cpp | 103 ++++------ .../crystaledit/editlib/parsers/rust.cpp | 103 ++++------ Externals/crystaledit/editlib/parsers/sh.cpp | 103 ++++------ .../crystaledit/editlib/parsers/siod.cpp | 178 +++++++----------- .../crystaledit/editlib/parsers/smarty.cpp | 135 +++++-------- Externals/crystaledit/editlib/parsers/sql.cpp | 103 ++++------ Externals/crystaledit/editlib/parsers/tcl.cpp | 91 ++++----- .../crystaledit/editlib/parsers/verilog.cpp | 43 ++--- .../crystaledit/editlib/parsers/vhdl.cpp | 95 ++++------ 32 files changed, 1185 insertions(+), 1923 deletions(-) diff --git a/Externals/crystaledit/editlib/parsers/abap.cpp b/Externals/crystaledit/editlib/parsers/abap.cpp index 4da5cd5c92f..3283960aefd 100644 --- a/Externals/crystaledit/editlib/parsers/abap.cpp +++ b/Externals/crystaledit/editlib/parsers/abap.cpp @@ -1051,6 +1051,19 @@ static bool IsNumber(const tchar_t* pszChars, int nLength) return result; } +static inline void +DefineIdentiferBlock(const tchar_t *pszChars, int nLength, CrystalLineParser::TEXTBLOCK * pBuf, int &nActualItems, int nIdentBegin, int I) +{ + if (IsAbapKeyword(pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK(nIdentBegin, COLORINDEX_KEYWORD); + } + else if (IsNumber(pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK(nIdentBegin, COLORINDEX_NUMBER); + } +} + unsigned CrystalLineParser::ParseLineAbap(unsigned dwCookie, const tchar_t* pszChars, int nLength, TEXTBLOCK* pBuf, int& nActualItems) { @@ -1210,14 +1223,7 @@ CrystalLineParser::ParseLineAbap(unsigned dwCookie, const tchar_t* pszChars, int { if (nIdentBegin >= 0) { - if (IsAbapKeyword(pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK(nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsNumber(pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK(nIdentBegin, COLORINDEX_NUMBER); - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I); bRedefineBlock = true; bDecIndex = true; @@ -1227,23 +1233,9 @@ CrystalLineParser::ParseLineAbap(unsigned dwCookie, const tchar_t* pszChars, int } if (nIdentBegin >= 0) - { - if (IsAbapKeyword(pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK(nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsNumber(pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK(nIdentBegin, COLORINDEX_NUMBER); - } - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I); if (pszChars[nLength - 1] != '\\' || IsMBSTrail(pszChars, nLength - 1)) dwCookie &= COOKIE_EXT_COMMENT; return dwCookie; } - - - - - diff --git a/Externals/crystaledit/editlib/parsers/batch.cpp b/Externals/crystaledit/editlib/parsers/batch.cpp index b88e694a3d3..d27ff45ba3f 100644 --- a/Externals/crystaledit/editlib/parsers/batch.cpp +++ b/Externals/crystaledit/editlib/parsers/batch.cpp @@ -686,6 +686,33 @@ IsUser2Keyword (const tchar_t *pszChars, int nLength) return ISXKEYWORDI (s_apszUser2KeywordList, pszChars, nLength); } +static inline void +DefineIdentiferBlock(const tchar_t *pszChars, int nLength, CrystalLineParser::TEXTBLOCK * pBuf, int &nActualItems, int nIdentBegin, int I, unsigned &dwCookie) +{ + if (IsBatKeyword (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); + if ((I - nIdentBegin ==4 && !tc::tcsnicmp (pszChars + nIdentBegin, _T ("GOTO"), 4)) || + (I - nIdentBegin ==5 && !tc::tcsnicmp (pszChars + nIdentBegin, _T ("GOSUB"), 5)) + ) + { + dwCookie=COOKIE_PREPROCESSOR; + } + } + else if (IsUser1Keyword (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER1); + } + else if (IsUser2Keyword (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER2); + } + else if (CrystalLineParser::IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); + } +} + unsigned CrystalLineParser::ParseLineBatch (unsigned dwCookie, const tchar_t *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems) { @@ -846,28 +873,7 @@ CrystalLineParser::ParseLineBatch (unsigned dwCookie, const tchar_t *pszChars, i } else { - if (IsBatKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - if ((I - nIdentBegin ==4 && !tc::tcsnicmp (pszChars + nIdentBegin, _T ("GOTO"), 4)) || - (I - nIdentBegin ==5 && !tc::tcsnicmp (pszChars + nIdentBegin, _T ("GOSUB"), 5)) - ) - { - dwCookie=COOKIE_PREPROCESSOR; - } - } - else if (IsUser1Keyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER1); - } - else if (IsUser2Keyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER2); - } - else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I, dwCookie); } bRedefineBlock = true; bDecIndex = true; @@ -878,28 +884,7 @@ CrystalLineParser::ParseLineBatch (unsigned dwCookie, const tchar_t *pszChars, i if (nIdentBegin >= 0) { - if (IsBatKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - if ((I - nIdentBegin ==4 && !tc::tcsnicmp (pszChars + nIdentBegin, _T ("GOTO"), 4)) || - (I - nIdentBegin ==5 && !tc::tcsnicmp (pszChars + nIdentBegin, _T ("GOSUB"), 5)) - ) - { - dwCookie=COOKIE_PREPROCESSOR; - } - } - else if (IsUser1Keyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER1); - } - else if (IsUser2Keyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER2); - } - else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I, dwCookie); } dwCookie = 0; diff --git a/Externals/crystaledit/editlib/parsers/cplusplus.cpp b/Externals/crystaledit/editlib/parsers/cplusplus.cpp index 0c9aaf58c89..88482f66b02 100644 --- a/Externals/crystaledit/editlib/parsers/cplusplus.cpp +++ b/Externals/crystaledit/editlib/parsers/cplusplus.cpp @@ -260,6 +260,44 @@ IsUser1Keyword (const tchar_t *pszChars, int nLength) return ISXKEYWORD (s_apszUser1KeywordList, pszChars, nLength); } +static inline void +DefineIdentiferBlock(const tchar_t *pszChars, int nLength, CrystalLineParser::TEXTBLOCK * pBuf, int &nActualItems, int nIdentBegin, int I, + bool (*IsKeyword)(const tchar_t *pszChars, int nLength), + bool (*IsUser1Keyword)(const tchar_t *pszChars, int nLength)) +{ + if (IsKeyword (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); + } + else if (IsUser1Keyword && IsUser1Keyword (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER1); + } + else if (CrystalLineParser::IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); + } + else + { + bool bFunction = false; + + for (int j = I; j < nLength; j++) + { + if (!xisspace (pszChars[j])) + { + if (pszChars[j] == '(') + { + bFunction = true; + } + break; + } + } + if (bFunction) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); + } + } +} unsigned CrystalLineParser::ParseLineC (unsigned dwCookie, const tchar_t *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems) { @@ -441,38 +479,7 @@ CrystalLineParser::ParseLineCJava (unsigned dwCookie, const tchar_t *pszChars, i { if (nIdentBegin >= 0) { - if (IsKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsUser1Keyword && IsUser1Keyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER1); - } - else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } - else - { - bool bFunction = false; - - for (int j = I; j < nLength; j++) - { - if (!xisspace (pszChars[j])) - { - if (pszChars[j] == '(') - { - bFunction = true; - } - break; - } - } - if (bFunction) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); - } - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I, IsKeyword, IsUser1Keyword); bRedefineBlock = true; bDecIndex = true; nIdentBegin = -1; @@ -482,38 +489,7 @@ CrystalLineParser::ParseLineCJava (unsigned dwCookie, const tchar_t *pszChars, i if (nIdentBegin >= 0) { - if (IsKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsUser1Keyword && IsUser1Keyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER1); - } - else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } - else - { - bool bFunction = false; - - for (int j = I; j < nLength; j++) - { - if (!xisspace (pszChars[j])) - { - if (pszChars[j] == '(') - { - bFunction = true; - } - break; - } - } - if (bFunction) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); - } - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I, IsKeyword, IsUser1Keyword); } if (pszChars[nLength - 1] != '\\' || IsMBSTrail(pszChars, nLength - 1)) diff --git a/Externals/crystaledit/editlib/parsers/dcl.cpp b/Externals/crystaledit/editlib/parsers/dcl.cpp index 6651d32a774..e22d8e621bf 100644 --- a/Externals/crystaledit/editlib/parsers/dcl.cpp +++ b/Externals/crystaledit/editlib/parsers/dcl.cpp @@ -123,6 +123,61 @@ IsUser2Keyword (const tchar_t *pszChars, int nLength) return ISXKEYWORD (s_apszUser2KeywordList, pszChars, nLength); } +static inline void +DefineIdentiferBlock(const tchar_t *pszChars, int nLength, CrystalLineParser::TEXTBLOCK * pBuf, int &nActualItems, int nIdentBegin, int I) +{ + if (IsDclKeyword (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); + } + else if (IsUser1Keyword (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER1); + } + else if (IsUser2Keyword (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER2); + } + else if (CrystalLineParser::IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); + } + else + { + bool bFunction = false; + + for (int j = I; j < nLength; j++) + { + if (!xisspace (pszChars[j])) + { + if (pszChars[j] == '{' || pszChars[j] == ':') + { + bFunction = true; + } + break; + } + } + if (!bFunction) + { + for (int j = nIdentBegin; --j >= 0;) + { + if (!xisspace (pszChars[j])) + { + if (pszChars[j] == ':') + { + bFunction = true; + } + break; + } + } + } + if (bFunction) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); + } + } +} + unsigned CrystalLineParser::ParseLineDcl (unsigned dwCookie, const tchar_t *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems) { @@ -268,56 +323,7 @@ CrystalLineParser::ParseLineDcl (unsigned dwCookie, const tchar_t *pszChars, int { if (nIdentBegin >= 0) { - if (IsDclKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsUser1Keyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER1); - } - else if (IsUser2Keyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER2); - } - else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } - else - { - bool bFunction = false; - - for (int j = I; j < nLength; j++) - { - if (!xisspace (pszChars[j])) - { - if (pszChars[j] == '{' || pszChars[j] == ':') - { - bFunction = true; - } - break; - } - } - if (!bFunction) - { - for (int j = nIdentBegin; --j >= 0;) - { - if (!xisspace (pszChars[j])) - { - if (pszChars[j] == ':') - { - bFunction = true; - } - break; - } - } - } - if (bFunction) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); - } - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I); bRedefineBlock = true; bDecIndex = true; nIdentBegin = -1; @@ -327,56 +333,7 @@ CrystalLineParser::ParseLineDcl (unsigned dwCookie, const tchar_t *pszChars, int if (nIdentBegin >= 0) { - if (IsDclKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsUser1Keyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER1); - } - else if (IsUser2Keyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER2); - } - else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } - else - { - bool bFunction = false; - - for (int j = I; j < nLength; j++) - { - if (!xisspace (pszChars[j])) - { - if (pszChars[j] == '{' || pszChars[j] == ':') - { - bFunction = true; - } - break; - } - } - if (!bFunction) - { - for (int j = nIdentBegin; --j >= 0;) - { - if (!xisspace (pszChars[j])) - { - if (pszChars[j] == ':') - { - bFunction = true; - } - break; - } - } - } - if (bFunction) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); - } - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I); } dwCookie &= COOKIE_EXT_COMMENT; diff --git a/Externals/crystaledit/editlib/parsers/dlang.cpp b/Externals/crystaledit/editlib/parsers/dlang.cpp index c274ede58ef..924ed633f1f 100644 --- a/Externals/crystaledit/editlib/parsers/dlang.cpp +++ b/Externals/crystaledit/editlib/parsers/dlang.cpp @@ -162,6 +162,43 @@ IsUser1Keyword (const tchar_t *pszChars, int nLength) return ISXKEYWORD (s_apszUser1KeywordList, pszChars, nLength); } +static inline void +DefineIdentiferBlock(const tchar_t *pszChars, int nLength, CrystalLineParser::TEXTBLOCK * pBuf, int &nActualItems, int nIdentBegin, int I) +{ + if (IsDlangKeyword (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); + } + else if (IsUser1Keyword (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER1); + } + else if (CrystalLineParser::IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); + } + else + { + bool bFunction = false; + + for (int j = I; j < nLength; j++) + { + if (!xisspace (pszChars[j])) + { + if (pszChars[j] == '(') + { + bFunction = true; + } + break; + } + } + if (bFunction) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); + } + } +} + unsigned CrystalLineParser::ParseLineDlang (unsigned dwCookie, const tchar_t *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems) { @@ -457,38 +494,7 @@ CrystalLineParser::ParseLineDlang (unsigned dwCookie, const tchar_t *pszChars, i { if (nIdentBegin >= 0) { - if (IsDlangKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsUser1Keyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER1); - } - else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } - else - { - bool bFunction = false; - - for (int j = I; j < nLength; j++) - { - if (!xisspace (pszChars[j])) - { - if (pszChars[j] == '(') - { - bFunction = true; - } - break; - } - } - if (bFunction) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); - } - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I); bRedefineBlock = true; bDecIndex = true; nIdentBegin = -1; @@ -498,38 +504,7 @@ CrystalLineParser::ParseLineDlang (unsigned dwCookie, const tchar_t *pszChars, i if (nIdentBegin >= 0) { - if (IsDlangKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsUser1Keyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER1); - } - else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } - else - { - bool bFunction = false; - - for (int j = I; j < nLength; j++) - { - if (!xisspace (pszChars[j])) - { - if (pszChars[j] == '(') - { - bFunction = true; - } - break; - } - } - if (bFunction) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); - } - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I); } dwCookie &= COOKIE_EXT_COMMENT | COOKIE_RAWSTRING | COOKIE_STRING | 0xFF000000; diff --git a/Externals/crystaledit/editlib/parsers/fortran.cpp b/Externals/crystaledit/editlib/parsers/fortran.cpp index 9f9265482b3..20ce2531493 100644 --- a/Externals/crystaledit/editlib/parsers/fortran.cpp +++ b/Externals/crystaledit/editlib/parsers/fortran.cpp @@ -239,6 +239,19 @@ IsFortranKeyword (const tchar_t *pszChars, int nLength) return ISXKEYWORDI (s_apszFortranKeywordList, pszChars, nLength); } +static inline void +DefineIdentiferBlock(const tchar_t *pszChars, int nLength, CrystalLineParser::TEXTBLOCK * pBuf, int &nActualItems, int nIdentBegin, int I) +{ + if (IsFortranKeyword (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); + } + else if (CrystalLineParser::IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); + } +} + unsigned CrystalLineParser::ParseLineFortran (unsigned dwCookie, const tchar_t *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems) { @@ -363,14 +376,7 @@ CrystalLineParser::ParseLineFortran (unsigned dwCookie, const tchar_t *pszChars, { if (nIdentBegin >= 0) { - if (IsFortranKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I); bRedefineBlock = true; bDecIndex = true; nIdentBegin = -1; @@ -380,14 +386,7 @@ CrystalLineParser::ParseLineFortran (unsigned dwCookie, const tchar_t *pszChars, if (nIdentBegin >= 0) { - if (IsFortranKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I); } if (pszChars[nLength - 1] != '\\' || IsMBSTrail(pszChars, nLength - 1)) diff --git a/Externals/crystaledit/editlib/parsers/fsharp.cpp b/Externals/crystaledit/editlib/parsers/fsharp.cpp index cf9746e3cfd..a1d7198055b 100644 --- a/Externals/crystaledit/editlib/parsers/fsharp.cpp +++ b/Externals/crystaledit/editlib/parsers/fsharp.cpp @@ -194,6 +194,44 @@ IsUserKeyword(const tchar_t* pszChars, int nLength) return ISXKEYWORD(s_apszUser1KeywordList, pszChars, nLength); } +static inline void +DefineIdentiferBlock(const tchar_t *pszChars, int nLength, CrystalLineParser::TEXTBLOCK * pBuf, int &nActualItems, int nIdentBegin, int I) +{ + if (IsFsKeyword(pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK(nIdentBegin, COLORINDEX_KEYWORD); + } + else if (IsUserKeyword(pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK(nIdentBegin, COLORINDEX_USER1); + } + else if (CrystalLineParser::IsXNumber(pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK(nIdentBegin, COLORINDEX_NUMBER); + } + else + { + // Todo: F# parenthesis are often optional, so functions are not usually this easy to detect! + bool bFunction = false; + + for (int j = I; j < nLength; j++) + { + if (!xisspace(pszChars[j])) + { + if (pszChars[j] == '(') + { + bFunction = true; + } + break; + } + } + if (bFunction) + { + DEFINE_BLOCK(nIdentBegin, COLORINDEX_FUNCNAME); + } + } +} + unsigned CrystalLineParser::ParseLineFSharp (unsigned dwCookie, const tchar_t *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems) { @@ -403,39 +441,7 @@ CrystalLineParser::ParseLineFSharp (unsigned dwCookie, const tchar_t *pszChars, { if (nIdentBegin >= 0) { - if (IsFsKeyword(pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK(nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsUserKeyword(pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK(nIdentBegin, COLORINDEX_USER1); - } - else if (IsXNumber(pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK(nIdentBegin, COLORINDEX_NUMBER); - } - else - { - // Todo: F# parenthesis are often optional, so functions are not usually this easy to detect! - bool bFunction = false; - - for (int j = I; j < nLength; j++) - { - if (!xisspace(pszChars[j])) - { - if (pszChars[j] == '(') - { - bFunction = true; - } - break; - } - } - if (bFunction) - { - DEFINE_BLOCK(nIdentBegin, COLORINDEX_FUNCNAME); - } - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I); bRedefineBlock = true; bDecIndex = true; nIdentBegin = -1; @@ -445,38 +451,7 @@ CrystalLineParser::ParseLineFSharp (unsigned dwCookie, const tchar_t *pszChars, if (nIdentBegin >= 0) { - if (IsFsKeyword(pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK(nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsUserKeyword(pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK(nIdentBegin, COLORINDEX_USER1); - } - else if (IsXNumber(pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK(nIdentBegin, COLORINDEX_NUMBER); - } - else - { - bool bFunction = false; - - for (int j = I; j < nLength; j++) - { - if (!xisspace(pszChars[j])) - { - if (pszChars[j] == '(') - { - bFunction = true; - } - break; - } - } - if (bFunction) - { - DEFINE_BLOCK(nIdentBegin, COLORINDEX_FUNCNAME); - } - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I); } if (pszChars[nLength - 1] != '\\' || IsMBSTrail(pszChars, nLength - 1)) diff --git a/Externals/crystaledit/editlib/parsers/go.cpp b/Externals/crystaledit/editlib/parsers/go.cpp index 258f00f95da..79780429dd7 100644 --- a/Externals/crystaledit/editlib/parsers/go.cpp +++ b/Externals/crystaledit/editlib/parsers/go.cpp @@ -108,6 +108,43 @@ IsUser1Keyword (const tchar_t *pszChars, int nLength) return ISXKEYWORD (s_apszUser1KeywordList, pszChars, nLength); } +static inline void +DefineIdentiferBlock(const tchar_t *pszChars, int nLength, CrystalLineParser::TEXTBLOCK * pBuf, int &nActualItems, int nIdentBegin, int I) +{ + if (IsGoKeyword (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); + } + else if (IsUser1Keyword (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER1); + } + else if (CrystalLineParser::IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); + } + else + { + bool bFunction = false; + + for (int j = I; j < nLength; j++) + { + if (!xisspace (pszChars[j])) + { + if (pszChars[j] == '(') + { + bFunction = true; + } + break; + } + } + if (bFunction) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); + } + } +} + unsigned CrystalLineParser::ParseLineGo (unsigned dwCookie, const tchar_t *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems) { @@ -270,38 +307,7 @@ CrystalLineParser::ParseLineGo (unsigned dwCookie, const tchar_t *pszChars, int { if (nIdentBegin >= 0) { - if (IsGoKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsUser1Keyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER1); - } - else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } - else - { - bool bFunction = false; - - for (int j = I; j < nLength; j++) - { - if (!xisspace (pszChars[j])) - { - if (pszChars[j] == '(') - { - bFunction = true; - } - break; - } - } - if (bFunction) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); - } - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I); bRedefineBlock = true; bDecIndex = true; nIdentBegin = -1; @@ -311,38 +317,7 @@ CrystalLineParser::ParseLineGo (unsigned dwCookie, const tchar_t *pszChars, int if (nIdentBegin >= 0) { - if (IsGoKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsUser1Keyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER1); - } - else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } - else - { - bool bFunction = false; - - for (int j = I; j < nLength; j++) - { - if (!xisspace (pszChars[j])) - { - if (pszChars[j] == '(') - { - bFunction = true; - } - break; - } - } - if (bFunction) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); - } - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I); } dwCookie &= COOKIE_EXT_COMMENT | COOKIE_RAWSTRING; diff --git a/Externals/crystaledit/editlib/parsers/ini.cpp b/Externals/crystaledit/editlib/parsers/ini.cpp index 0bf08df1070..e18d3ae95ee 100644 --- a/Externals/crystaledit/editlib/parsers/ini.cpp +++ b/Externals/crystaledit/editlib/parsers/ini.cpp @@ -24,6 +24,15 @@ #define new DEBUG_NEW #endif +static inline void +DefineIdentiferBlock(const tchar_t *pszChars, int nLength, CrystalLineParser::TEXTBLOCK * pBuf, int &nActualItems, int nIdentBegin, int I) +{ + if (CrystalLineParser::IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); + } +} + unsigned CrystalLineParser::ParseLineIni (unsigned dwCookie, const tchar_t *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems) { @@ -195,10 +204,7 @@ CrystalLineParser::ParseLineIni (unsigned dwCookie, const tchar_t *pszChars, int { if (nIdentBegin >= 0) { - if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I); bRedefineBlock = true; bDecIndex = true; nIdentBegin = -1; @@ -208,10 +214,7 @@ CrystalLineParser::ParseLineIni (unsigned dwCookie, const tchar_t *pszChars, int if (nIdentBegin >= 0) { - if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I); } dwCookie &= COOKIE_EXT_COMMENT; diff --git a/Externals/crystaledit/editlib/parsers/innosetup.cpp b/Externals/crystaledit/editlib/parsers/innosetup.cpp index d7147909b49..8cfd9141079 100644 --- a/Externals/crystaledit/editlib/parsers/innosetup.cpp +++ b/Externals/crystaledit/editlib/parsers/innosetup.cpp @@ -297,6 +297,43 @@ IsLineSection(const tchar_t *pszChars, int nLength, bool& bCodeSection) return true; } +static inline void +DefineIdentiferBlock(const tchar_t *pszChars, int nLength, CrystalLineParser::TEXTBLOCK * pBuf, int &nActualItems, int nIdentBegin, int I) +{ + if (IsInnoSetupKeyword (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); + } + else if (IsUser1Keyword (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER1); + } + else if (CrystalLineParser::IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); + } + else + { + bool bFunction = false; + + for (int j = I; j < nLength; j++) + { + if (!xisspace (pszChars[j])) + { + if (pszChars[j] == '(') + { + bFunction = true; + } + break; + } + } + if (bFunction) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); + } + } +} + unsigned CrystalLineParser::ParseLineInnoSetup (unsigned dwCookie, const tchar_t *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems) { @@ -487,38 +524,7 @@ CrystalLineParser::ParseLineInnoSetup (unsigned dwCookie, const tchar_t *pszChar { if (nIdentBegin >= 0) { - if (IsInnoSetupKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsUser1Keyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER1); - } - else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } - else - { - bool bFunction = false; - - for (int j = I; j < nLength; j++) - { - if (!xisspace (pszChars[j])) - { - if (pszChars[j] == '(') - { - bFunction = true; - } - break; - } - } - if (bFunction) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); - } - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I); bRedefineBlock = true; bDecIndex = true; nIdentBegin = -1; @@ -528,38 +534,7 @@ CrystalLineParser::ParseLineInnoSetup (unsigned dwCookie, const tchar_t *pszChar if (nIdentBegin >= 0) { - if (IsInnoSetupKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsUser1Keyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER1); - } - else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } - else - { - bool bFunction = false; - - for (int j = I; j < nLength; j++) - { - if (!xisspace (pszChars[j])) - { - if (pszChars[j] == '(') - { - bFunction = true; - } - break; - } - } - if (bFunction) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); - } - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I); } if (pszChars[nLength - 1] != '\\' || IsMBSTrail(pszChars, nLength - 1)) diff --git a/Externals/crystaledit/editlib/parsers/is.cpp b/Externals/crystaledit/editlib/parsers/is.cpp index b991278fce0..29934c27078 100644 --- a/Externals/crystaledit/editlib/parsers/is.cpp +++ b/Externals/crystaledit/editlib/parsers/is.cpp @@ -429,6 +429,47 @@ IsUser2Keyword (const tchar_t *pszChars, int nLength) return ISXKEYWORD (s_apszUser2KeywordList, pszChars, nLength); } +static inline void +DefineIdentiferBlock(const tchar_t *pszChars, int nLength, CrystalLineParser::TEXTBLOCK * pBuf, int &nActualItems, int nIdentBegin, int I) +{ + if (IsISKeyword (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); + } + else if (IsUser1Keyword (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER1); + } + else if (IsUser2Keyword (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER2); + } + else if (CrystalLineParser::IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); + } + else + { + bool bFunction = false; + + for (int j = I; j < nLength; j++) + { + if (!xisspace (pszChars[j])) + { + if (pszChars[j] == '(') + { + bFunction = true; + } + break; + } + } + if (bFunction) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); + } + } +} + unsigned CrystalLineParser::ParseLineIS (unsigned dwCookie, const tchar_t *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems) { @@ -602,42 +643,7 @@ CrystalLineParser::ParseLineIS (unsigned dwCookie, const tchar_t *pszChars, int { if (nIdentBegin >= 0) { - if (IsISKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsUser1Keyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER1); - } - else if (IsUser2Keyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER2); - } - else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } - else - { - bool bFunction = false; - - for (int j = I; j < nLength; j++) - { - if (!xisspace (pszChars[j])) - { - if (pszChars[j] == '(') - { - bFunction = true; - } - break; - } - } - if (bFunction) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); - } - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I); bRedefineBlock = true; bDecIndex = true; nIdentBegin = -1; @@ -647,42 +653,7 @@ CrystalLineParser::ParseLineIS (unsigned dwCookie, const tchar_t *pszChars, int if (nIdentBegin >= 0) { - if (IsISKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsUser1Keyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER1); - } - else if (IsUser2Keyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER2); - } - else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } - else - { - bool bFunction = false; - - for (int j = I; j < nLength; j++) - { - if (!xisspace (pszChars[j])) - { - if (pszChars[j] == '(') - { - bFunction = true; - } - break; - } - } - if (bFunction) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); - } - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I); } if (pszChars[nLength - 1] != '\\' || IsMBSTrail(pszChars, nLength - 1)) diff --git a/Externals/crystaledit/editlib/parsers/lisp.cpp b/Externals/crystaledit/editlib/parsers/lisp.cpp index 99f23166bae..34b4a39e03e 100644 --- a/Externals/crystaledit/editlib/parsers/lisp.cpp +++ b/Externals/crystaledit/editlib/parsers/lisp.cpp @@ -260,6 +260,60 @@ IsLispKeyword (const tchar_t *pszChars, int nLength) return ISXKEYWORD (s_apszLispKeywordList, pszChars, nLength); } +static inline void +DefineIdentiferBlock(const tchar_t *pszChars, int nLength, CrystalLineParser::TEXTBLOCK * pBuf, int &nActualItems, int nIdentBegin, int I, bool &bDefun) +{ + if (IsLispKeyword (pszChars + nIdentBegin, I - nIdentBegin)) + { + if (!tc::tcsnicmp (_T ("defun"), pszChars + nIdentBegin, 5)) + { + bDefun = true; + } + DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); + } + else if (CrystalLineParser::IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); + } + else + { + bool bFunction = false; + + if (!bDefun) + { + for (int j = nIdentBegin; --j >= 0;) + { + if (!xisspace (pszChars[j])) + { + if (pszChars[j] == '(') + { + bFunction = true; + } + break; + } + } + } + if (!bFunction) + { + for (int j = I; j >= 0; j--) + { + if (!xisspace (pszChars[j])) + { + if (pszChars[j] == '(') + { + bFunction = true; + } + break; + } + } + } + if (bFunction) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); + } + } +} + unsigned CrystalLineParser::ParseLineLisp (unsigned dwCookie, const tchar_t *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems) { @@ -407,55 +461,7 @@ CrystalLineParser::ParseLineLisp (unsigned dwCookie, const tchar_t *pszChars, in { if (nIdentBegin >= 0) { - if (IsLispKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - if (!tc::tcsnicmp (_T ("defun"), pszChars + nIdentBegin, 5)) - { - bDefun = true; - } - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } - else - { - bool bFunction = false; - - if (!bDefun) - { - for (int j = nIdentBegin; --j >= 0;) - { - if (!xisspace (pszChars[j])) - { - if (pszChars[j] == '(') - { - bFunction = true; - } - break; - } - } - } - if (!bFunction) - { - for (int j = I; j >= 0; j--) - { - if (!xisspace (pszChars[j])) - { - if (pszChars[j] == '(') - { - bFunction = true; - } - break; - } - } - } - if (bFunction) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); - } - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I, bDefun); bRedefineBlock = true; bDecIndex = true; nIdentBegin = -1; @@ -465,55 +471,7 @@ CrystalLineParser::ParseLineLisp (unsigned dwCookie, const tchar_t *pszChars, in if (nIdentBegin >= 0) { - if (IsLispKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - if (!tc::tcsnicmp (_T ("defun"), pszChars + nIdentBegin, 5)) - { - bDefun = true; - } - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } - else - { - bool bFunction = false; - - if (!bDefun) - { - for (int j = nIdentBegin; --j >= 0;) - { - if (!xisspace (pszChars[j])) - { - if (pszChars[j] == '(') - { - bFunction = true; - } - break; - } - } - } - if (!bFunction) - { - for (int j = I; j >= 0; j--) - { - if (!xisspace (pszChars[j])) - { - if (pszChars[j] == '(') - { - bFunction = true; - } - break; - } - } - } - if (bFunction) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); - } - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I, bDefun); } dwCookie &= COOKIE_EXT_COMMENT; diff --git a/Externals/crystaledit/editlib/parsers/lua.cpp b/Externals/crystaledit/editlib/parsers/lua.cpp index 0d44f315882..d163afe4648 100644 --- a/Externals/crystaledit/editlib/parsers/lua.cpp +++ b/Externals/crystaledit/editlib/parsers/lua.cpp @@ -56,6 +56,39 @@ IsLuaKeyword (const tchar_t *pszChars, int nLength) return ISXKEYWORD (s_apszLuaKeywordList, pszChars, nLength); } +static inline void +DefineIdentiferBlock(const tchar_t *pszChars, int nLength, CrystalLineParser::TEXTBLOCK * pBuf, int &nActualItems, int nIdentBegin, int I) +{ + if (IsLuaKeyword (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); + } + else if (CrystalLineParser::IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); + } + else + { + bool bFunction = false; + + for (int j = I; j < nLength; j++) + { + if (!xisspace (pszChars[j])) + { + if (pszChars[j] == '(') + { + bFunction = true; + } + break; + } + } + if (bFunction) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); + } + } +} + unsigned CrystalLineParser::ParseLineLua (unsigned dwCookie, const tchar_t *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems) { @@ -236,34 +269,7 @@ CrystalLineParser::ParseLineLua (unsigned dwCookie, const tchar_t *pszChars, int { if (nIdentBegin >= 0) { - if (IsLuaKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } - else - { - bool bFunction = false; - - for (int j = I; j < nLength; j++) - { - if (!xisspace (pszChars[j])) - { - if (pszChars[j] == '(') - { - bFunction = true; - } - break; - } - } - if (bFunction) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); - } - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I); bRedefineBlock = true; bDecIndex = true; nIdentBegin = -1; @@ -273,34 +279,7 @@ CrystalLineParser::ParseLineLua (unsigned dwCookie, const tchar_t *pszChars, int if (nIdentBegin >= 0) { - if (IsLuaKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } - else - { - bool bFunction = false; - - for (int j = I; j < nLength; j++) - { - if (!xisspace (pszChars[j])) - { - if (pszChars[j] == '(') - { - bFunction = true; - } - break; - } - } - if (bFunction) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); - } - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I); } dwCookie &= COOKIE_EXT_COMMENT | COOKIE_RAWSTRING | 0xFF000000; diff --git a/Externals/crystaledit/editlib/parsers/matlab.cpp b/Externals/crystaledit/editlib/parsers/matlab.cpp index e1d66a2d8fd..9358631f4ee 100644 --- a/Externals/crystaledit/editlib/parsers/matlab.cpp +++ b/Externals/crystaledit/editlib/parsers/matlab.cpp @@ -92,6 +92,39 @@ IsMatlabKeyword (const tchar_t *pszChars, int nLength) return ISXKEYWORD (s_apszMatlabKeywordList, pszChars, nLength); } +static inline void +DefineIdentiferBlock(const tchar_t *pszChars, int nLength, CrystalLineParser::TEXTBLOCK * pBuf, int &nActualItems, int nIdentBegin, int I) +{ + if (IsMatlabKeyword (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); + } + else if (CrystalLineParser::IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); + } + else + { + bool bFunction = false; + + for (int j = I; j < nLength; j++) + { + if (!xisspace (pszChars[j])) + { + if (pszChars[j] == '(') + { + bFunction = true; + } + break; + } + } + if (bFunction) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); + } + } +} + unsigned CrystalLineParser::ParseLineMatlab (unsigned dwCookie, const tchar_t *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems) { @@ -263,34 +296,7 @@ CrystalLineParser::ParseLineMatlab (unsigned dwCookie, const tchar_t *pszChars, { if (nIdentBegin >= 0) { - if (IsMatlabKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } - else - { - bool bFunction = false; - - for (int j = I; j < nLength; j++) - { - if (!xisspace (pszChars[j])) - { - if (pszChars[j] == '(') - { - bFunction = true; - } - break; - } - } - if (bFunction) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); - } - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I); bRedefineBlock = true; bDecIndex = true; nIdentBegin = -1; @@ -300,34 +306,7 @@ CrystalLineParser::ParseLineMatlab (unsigned dwCookie, const tchar_t *pszChars, if (nIdentBegin >= 0) { - if (IsMatlabKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } - else - { - bool bFunction = false; - - for (int j = I; j < nLength; j++) - { - if (!xisspace (pszChars[j])) - { - if (pszChars[j] == '(') - { - bFunction = true; - } - break; - } - } - if (bFunction) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); - } - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I); } dwCookie &= COOKIE_EXT_COMMENT | 0xFF000000; diff --git a/Externals/crystaledit/editlib/parsers/nsis.cpp b/Externals/crystaledit/editlib/parsers/nsis.cpp index bec2854c00e..42bb1b0275c 100644 --- a/Externals/crystaledit/editlib/parsers/nsis.cpp +++ b/Externals/crystaledit/editlib/parsers/nsis.cpp @@ -434,6 +434,43 @@ IsUser1Keyword (const tchar_t *pszChars, int nLength) return ISXKEYWORD (s_apszUser1KeywordList, pszChars, nLength); } +static inline void +DefineIdentiferBlock(const tchar_t *pszChars, int nLength, CrystalLineParser::TEXTBLOCK * pBuf, int &nActualItems, int nIdentBegin, int I) +{ + if (IsNsisKeyword (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); + } + else if (IsUser1Keyword (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER1); + } + else if (CrystalLineParser::IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); + } + else + { + bool bFunction = false; + + for (int j = I; j < nLength; j++) + { + if (!xisspace (pszChars[j])) + { + if (pszChars[j] == '(') + { + bFunction = true; + } + break; + } + } + if (bFunction) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); + } + } +} + unsigned CrystalLineParser::ParseLineNsis (unsigned dwCookie, const tchar_t *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems) { @@ -607,38 +644,7 @@ CrystalLineParser::ParseLineNsis (unsigned dwCookie, const tchar_t *pszChars, in { if (nIdentBegin >= 0) { - if (IsNsisKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsUser1Keyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER1); - } - else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } - else - { - bool bFunction = false; - - for (int j = I; j < nLength; j++) - { - if (!xisspace (pszChars[j])) - { - if (pszChars[j] == '(') - { - bFunction = true; - } - break; - } - } - if (bFunction) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); - } - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I); bRedefineBlock = true; bDecIndex = true; nIdentBegin = -1; @@ -648,38 +654,7 @@ CrystalLineParser::ParseLineNsis (unsigned dwCookie, const tchar_t *pszChars, in if (nIdentBegin >= 0) { - if (IsNsisKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsUser1Keyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER1); - } - else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } - else - { - bool bFunction = false; - - for (int j = I; j < nLength; j++) - { - if (!xisspace (pszChars[j])) - { - if (pszChars[j] == '(') - { - bFunction = true; - } - break; - } - } - if (bFunction) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); - } - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I); } if (pszChars[nLength - 1] != '\\' || IsMBSTrail(pszChars, nLength - 1)) diff --git a/Externals/crystaledit/editlib/parsers/pascal.cpp b/Externals/crystaledit/editlib/parsers/pascal.cpp index 129beab830f..27e5b1d3466 100644 --- a/Externals/crystaledit/editlib/parsers/pascal.cpp +++ b/Externals/crystaledit/editlib/parsers/pascal.cpp @@ -112,6 +112,39 @@ IsPascalKeyword (const tchar_t *pszChars, int nLength) return ISXKEYWORDI (s_apszPascalKeywordList, pszChars, nLength); } +static inline void +DefineIdentiferBlock(const tchar_t *pszChars, int nLength, CrystalLineParser::TEXTBLOCK * pBuf, int &nActualItems, int nIdentBegin, int I) +{ + if (IsPascalKeyword (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); + } + else if (CrystalLineParser::IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); + } + else + { + bool bFunction = false; + + for (int j = I; j < nLength; j++) + { + if (!xisspace (pszChars[j])) + { + if (pszChars[j] == '(') + { + bFunction = true; + } + break; + } + } + if (bFunction) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); + } + } +} + unsigned CrystalLineParser::ParseLinePascal (unsigned dwCookie, const tchar_t *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems) { @@ -272,34 +305,7 @@ CrystalLineParser::ParseLinePascal (unsigned dwCookie, const tchar_t *pszChars, { if (nIdentBegin >= 0) { - if (IsPascalKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } - else - { - bool bFunction = false; - - for (int j = I; j < nLength; j++) - { - if (!xisspace (pszChars[j])) - { - if (pszChars[j] == '(') - { - bFunction = true; - } - break; - } - } - if (bFunction) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); - } - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I); bRedefineBlock = true; bDecIndex = true; nIdentBegin = -1; @@ -309,34 +315,7 @@ CrystalLineParser::ParseLinePascal (unsigned dwCookie, const tchar_t *pszChars, if (nIdentBegin >= 0) { - if (IsPascalKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } - else - { - bool bFunction = false; - - for (int j = I; j < nLength; j++) - { - if (!xisspace (pszChars[j])) - { - if (pszChars[j] == '(') - { - bFunction = true; - } - break; - } - } - if (bFunction) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); - } - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I); } if (pszChars[nLength - 1] != '\\' || IsMBSTrail(pszChars, nLength - 1)) diff --git a/Externals/crystaledit/editlib/parsers/perl.cpp b/Externals/crystaledit/editlib/parsers/perl.cpp index 6dbf348c2e2..bf8f8ee5322 100644 --- a/Externals/crystaledit/editlib/parsers/perl.cpp +++ b/Externals/crystaledit/editlib/parsers/perl.cpp @@ -256,6 +256,39 @@ IsPerlKeyword (const tchar_t *pszChars, int nLength) return ISXKEYWORDI (s_apszPerlKeywordList, pszChars, nLength); } +static inline void +DefineIdentiferBlock(const tchar_t *pszChars, int nLength, CrystalLineParser::TEXTBLOCK * pBuf, int &nActualItems, int nIdentBegin, int I) +{ + if (IsPerlKeyword (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); + } + else if (CrystalLineParser::IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); + } + else + { + bool bFunction = false; + + for (int j = I; j < nLength; j++) + { + if (!xisspace (pszChars[j])) + { + if (pszChars[j] == '(') + { + bFunction = true; + } + break; + } + } + if (bFunction) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); + } + } +} + unsigned CrystalLineParser::ParseLinePerl (unsigned dwCookie, const tchar_t *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems) { @@ -380,34 +413,7 @@ CrystalLineParser::ParseLinePerl (unsigned dwCookie, const tchar_t *pszChars, in { if (nIdentBegin >= 0) { - if (IsPerlKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } - else - { - bool bFunction = false; - - for (int j = I; j < nLength; j++) - { - if (!xisspace (pszChars[j])) - { - if (pszChars[j] == '(') - { - bFunction = true; - } - break; - } - } - if (bFunction) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); - } - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I); bRedefineBlock = true; bDecIndex = true; nIdentBegin = -1; @@ -417,34 +423,7 @@ CrystalLineParser::ParseLinePerl (unsigned dwCookie, const tchar_t *pszChars, in if (nIdentBegin >= 0) { - if (IsPerlKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } - else - { - bool bFunction = false; - - for (int j = I; j < nLength; j++) - { - if (!xisspace (pszChars[j])) - { - if (pszChars[j] == '(') - { - bFunction = true; - } - break; - } - } - if (bFunction) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); - } - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I); } if (pszChars[nLength - 1] != '\\' || IsMBSTrail(pszChars, nLength - 1)) diff --git a/Externals/crystaledit/editlib/parsers/php.cpp b/Externals/crystaledit/editlib/parsers/php.cpp index 61f64ef238c..2d264df0fa7 100644 --- a/Externals/crystaledit/editlib/parsers/php.cpp +++ b/Externals/crystaledit/editlib/parsers/php.cpp @@ -253,6 +253,51 @@ IsPhp2Keyword (const tchar_t *pszChars, int nLength) ISXKEYWORDI (s_apszPredefinedConstantList, pszChars, nLength); } +static inline void +DefineIdentiferBlock(const tchar_t *pszChars, int nLength, CrystalLineParser::TEXTBLOCK * pBuf, int &nActualItems, int nIdentBegin, int I, DWORD dwCookie) +{ + if (dwCookie & COOKIE_USER2) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER1); + } + if (IsPhpKeyword (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); + } + else if (IsPhp1Keyword (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_OPERATOR); + } + else if (IsPhp2Keyword (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER2); + } + else if (CrystalLineParser::IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); + } + else + { + bool bFunction = false; + + for (int j = I; j < nLength; j++) + { + if (!xisspace (pszChars[j])) + { + if (pszChars[j] == '(') + { + bFunction = true; + } + break; + } + } + if (bFunction) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); + } + } +} + unsigned CrystalLineParser::ParseLinePhp(unsigned dwCookie, const tchar_t* pszChars, int nLength, TEXTBLOCK* pBuf, int& nActualItems) { @@ -417,46 +462,7 @@ CrystalLineParser::ParseLinePhpLanguage (unsigned dwCookie, const tchar_t *pszCh { if (nIdentBegin >= 0) { - if (dwCookie & COOKIE_USER2) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER1); - } - if (IsPhpKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsPhp1Keyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_OPERATOR); - } - else if (IsPhp2Keyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER2); - } - else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } - else - { - bool bFunction = false; - - for (int j = I; j < nLength; j++) - { - if (!xisspace (pszChars[j])) - { - if (pszChars[j] == '(') - { - bFunction = true; - } - break; - } - } - if (bFunction) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); - } - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I, dwCookie); bRedefineBlock = true; bDecIndex = true; nIdentBegin = -1; @@ -485,46 +491,7 @@ CrystalLineParser::ParseLinePhpLanguage (unsigned dwCookie, const tchar_t *pszCh if (nIdentBegin >= 0) { - if (dwCookie & COOKIE_USER2) - { - DEFINE_BLOCK(nIdentBegin, COLORINDEX_USER1); - } - if (IsPhpKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsPhp1Keyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_OPERATOR); - } - else if (IsPhp2Keyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER2); - } - else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } - else - { - bool bFunction = false; - - for (int j = I; j < nLength; j++) - { - if (!xisspace (pszChars[j])) - { - if (pszChars[j] == '(') - { - bFunction = true; - } - break; - } - } - if (bFunction) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); - } - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I, dwCookie); } dwCookie &= (COOKIE_EXT_COMMENT | COOKIE_STRING | COOKIE_CHAR); diff --git a/Externals/crystaledit/editlib/parsers/po.cpp b/Externals/crystaledit/editlib/parsers/po.cpp index c3268b87502..15a3c57811a 100644 --- a/Externals/crystaledit/editlib/parsers/po.cpp +++ b/Externals/crystaledit/editlib/parsers/po.cpp @@ -52,6 +52,39 @@ IsPoKeyword (const tchar_t *pszChars, int nLength) return IsXKeyword (s_apszPoKeywordList, pszChars, nLength); } +static inline void +DefineIdentiferBlock(const tchar_t *pszChars, int nLength, CrystalLineParser::TEXTBLOCK * pBuf, int &nActualItems, int nIdentBegin, int I) +{ + if (IsPoKeyword (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); + } + else if (CrystalLineParser::IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); + } + else + { + bool bFunction = false; + + for (int j = I; j < nLength; j++) + { + if (!xisspace (pszChars[j])) + { + if (pszChars[j] == '(') + { + bFunction = true; + } + break; + } + } + if (bFunction) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); + } + } +} + unsigned CrystalLineParser::ParseLinePo (unsigned dwCookie, const tchar_t *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems) { @@ -176,34 +209,7 @@ CrystalLineParser::ParseLinePo (unsigned dwCookie, const tchar_t *pszChars, int { if (nIdentBegin >= 0) { - if (IsPoKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } - else - { - bool bFunction = false; - - for (int j = I; j < nLength; j++) - { - if (!xisspace (pszChars[j])) - { - if (pszChars[j] == '(') - { - bFunction = true; - } - break; - } - } - if (bFunction) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); - } - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I); bRedefineBlock = true; bDecIndex = true; nIdentBegin = -1; @@ -213,34 +219,7 @@ CrystalLineParser::ParseLinePo (unsigned dwCookie, const tchar_t *pszChars, int if (nIdentBegin >= 0) { - if (IsPoKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } - else - { - bool bFunction = false; - - for (int j = I; j < nLength; j++) - { - if (!xisspace (pszChars[j])) - { - if (pszChars[j] == '(') - { - bFunction = true; - } - break; - } - } - if (bFunction) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); - } - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I); } if (pszChars[nLength - 1] != '\\' || IsMBSTrail(pszChars, nLength - 1)) diff --git a/Externals/crystaledit/editlib/parsers/powershell.cpp b/Externals/crystaledit/editlib/parsers/powershell.cpp index 20023437c43..2e27c20044b 100644 --- a/Externals/crystaledit/editlib/parsers/powershell.cpp +++ b/Externals/crystaledit/editlib/parsers/powershell.cpp @@ -341,6 +341,23 @@ IsCmdletKeyword (const tchar_t *pszChars, int nLength) return ISXKEYWORDI (s_apszCmdletKeywordList, pszChars, nLength); } +static inline void +DefineIdentiferBlock(const tchar_t *pszChars, int nLength, CrystalLineParser::TEXTBLOCK * pBuf, int &nActualItems, int nIdentBegin, int I) +{ + if (IsPowerShellKeyword (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); + } + else if (IsCmdletKeyword (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); + } + else if (CrystalLineParser::IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); + } +} + unsigned CrystalLineParser::ParseLinePowerShell (unsigned dwCookie, const tchar_t *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems) { @@ -491,18 +508,7 @@ CrystalLineParser::ParseLinePowerShell (unsigned dwCookie, const tchar_t *pszCha { if (nIdentBegin >= 0) { - if (IsPowerShellKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsCmdletKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); - } - else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I); bRedefineBlock = true; bDecIndex = true; nIdentBegin = -1; @@ -512,18 +518,7 @@ CrystalLineParser::ParseLinePowerShell (unsigned dwCookie, const tchar_t *pszCha if (nIdentBegin >= 0) { - if (IsPowerShellKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsCmdletKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); - } - else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I); } dwCookie &= COOKIE_EXT_COMMENT; diff --git a/Externals/crystaledit/editlib/parsers/python.cpp b/Externals/crystaledit/editlib/parsers/python.cpp index bf7b9c9a29d..dcf1ca04f40 100644 --- a/Externals/crystaledit/editlib/parsers/python.cpp +++ b/Externals/crystaledit/editlib/parsers/python.cpp @@ -392,6 +392,47 @@ IsUser2Keyword (const tchar_t *pszChars, int nLength) return ISXKEYWORD (s_apszUser2KeywordList, pszChars, nLength); } +static inline void +DefineIdentiferBlock(const tchar_t *pszChars, int nLength, CrystalLineParser::TEXTBLOCK * pBuf, int &nActualItems, int nIdentBegin, int I) +{ + if (IsPythonKeyword (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); + } + else if (IsUser1Keyword (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER1); + } + else if (IsUser2Keyword (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER2); + } + else if (CrystalLineParser::IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); + } + else + { + bool bFunction = false; + + for (int j = I; j < nLength; j++) + { + if (!xisspace (pszChars[j])) + { + if (pszChars[j] == '(') + { + bFunction = true; + } + break; + } + } + if (bFunction) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); + } + } +} + unsigned CrystalLineParser::ParseLinePython (unsigned dwCookie, const tchar_t *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems) { @@ -516,42 +557,7 @@ CrystalLineParser::ParseLinePython (unsigned dwCookie, const tchar_t *pszChars, { if (nIdentBegin >= 0) { - if (IsPythonKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsUser1Keyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER1); - } - else if (IsUser2Keyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER2); - } - else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } - else - { - bool bFunction = false; - - for (int j = I; j < nLength; j++) - { - if (!xisspace (pszChars[j])) - { - if (pszChars[j] == '(') - { - bFunction = true; - } - break; - } - } - if (bFunction) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); - } - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I); bRedefineBlock = true; bDecIndex = true; nIdentBegin = -1; @@ -561,42 +567,7 @@ CrystalLineParser::ParseLinePython (unsigned dwCookie, const tchar_t *pszChars, if (nIdentBegin >= 0) { - if (IsPythonKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsUser1Keyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER1); - } - else if (IsUser2Keyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER2); - } - else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } - else - { - bool bFunction = false; - - for (int j = I; j < nLength; j++) - { - if (!xisspace (pszChars[j])) - { - if (pszChars[j] == '(') - { - bFunction = true; - } - break; - } - } - if (bFunction) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); - } - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I); } if (pszChars[nLength - 1] != '\\' || IsMBSTrail(pszChars, nLength - 1)) diff --git a/Externals/crystaledit/editlib/parsers/rexx.cpp b/Externals/crystaledit/editlib/parsers/rexx.cpp index c19c78dfaf8..79d78c4da14 100644 --- a/Externals/crystaledit/editlib/parsers/rexx.cpp +++ b/Externals/crystaledit/editlib/parsers/rexx.cpp @@ -111,6 +111,43 @@ IsUser1Keyword (const tchar_t *pszChars, int nLength) return ISXKEYWORDI (s_apszUser1KeywordList, pszChars, nLength); } +static inline void +DefineIdentiferBlock(const tchar_t *pszChars, int nLength, CrystalLineParser::TEXTBLOCK * pBuf, int &nActualItems, int nIdentBegin, int I) +{ + if (IsRexxKeyword (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); + } + else if (IsUser1Keyword (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER1); + } + else if (CrystalLineParser::IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); + } + else + { + bool bFunction = false; + + for (int j = I; j < nLength; j++) + { + if (!xisspace (pszChars[j])) + { + if (pszChars[j] == '(') + { + bFunction = true; + } + break; + } + } + if (bFunction) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); + } + } +} + unsigned CrystalLineParser::ParseLineRexx (unsigned dwCookie, const tchar_t *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems) { @@ -256,38 +293,7 @@ CrystalLineParser::ParseLineRexx (unsigned dwCookie, const tchar_t *pszChars, in { if (nIdentBegin >= 0) { - if (IsRexxKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsUser1Keyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER1); - } - else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } - else - { - bool bFunction = false; - - for (int j = I; j < nLength; j++) - { - if (!xisspace (pszChars[j])) - { - if (pszChars[j] == '(') - { - bFunction = true; - } - break; - } - } - if (bFunction) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); - } - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I); bRedefineBlock = true; bDecIndex = true; nIdentBegin = -1; @@ -297,38 +303,7 @@ CrystalLineParser::ParseLineRexx (unsigned dwCookie, const tchar_t *pszChars, in if (nIdentBegin >= 0) { - if (IsRexxKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsUser1Keyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER1); - } - else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } - else - { - bool bFunction = false; - - for (int j = I; j < nLength; j++) - { - if (!xisspace (pszChars[j])) - { - if (pszChars[j] == '(') - { - bFunction = true; - } - break; - } - } - if (bFunction) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); - } - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I); } if (pszChars[nLength - 1] != '\\' || IsMBSTrail(pszChars, nLength - 1)) diff --git a/Externals/crystaledit/editlib/parsers/rsrc.cpp b/Externals/crystaledit/editlib/parsers/rsrc.cpp index 71762164e82..69e1bbc541b 100644 --- a/Externals/crystaledit/editlib/parsers/rsrc.cpp +++ b/Externals/crystaledit/editlib/parsers/rsrc.cpp @@ -175,6 +175,43 @@ IsUser1Keyword (const tchar_t *pszChars, int nLength) return ISXKEYWORDI (s_apszUser1KeywordList, pszChars, nLength); } +static inline void +DefineIdentiferBlock(const tchar_t *pszChars, int nLength, CrystalLineParser::TEXTBLOCK * pBuf, int &nActualItems, int nIdentBegin, int I) +{ + if (IsRsrcKeyword (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); + } + else if (IsUser1Keyword (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER1); + } + else if (CrystalLineParser::IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); + } + else + { + bool bFunction = false; + + for (int j = I; j < nLength; j++) + { + if (!xisspace (pszChars[j])) + { + if (pszChars[j] == '(') + { + bFunction = true; + } + break; + } + } + if (bFunction) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); + } + } +} + unsigned CrystalLineParser::ParseLineRsrc (unsigned dwCookie, const tchar_t *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems) { @@ -348,38 +385,7 @@ CrystalLineParser::ParseLineRsrc (unsigned dwCookie, const tchar_t *pszChars, in { if (nIdentBegin >= 0) { - if (IsRsrcKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsUser1Keyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER1); - } - else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } - else - { - bool bFunction = false; - - for (int j = I; j < nLength; j++) - { - if (!xisspace (pszChars[j])) - { - if (pszChars[j] == '(') - { - bFunction = true; - } - break; - } - } - if (bFunction) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); - } - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I); bRedefineBlock = true; bDecIndex = true; nIdentBegin = -1; @@ -389,38 +395,7 @@ CrystalLineParser::ParseLineRsrc (unsigned dwCookie, const tchar_t *pszChars, in if (nIdentBegin >= 0) { - if (IsRsrcKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsUser1Keyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER1); - } - else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } - else - { - bool bFunction = false; - - for (int j = I; j < nLength; j++) - { - if (!xisspace (pszChars[j])) - { - if (pszChars[j] == '(') - { - bFunction = true; - } - break; - } - } - if (bFunction) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); - } - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I); } if (pszChars[nLength - 1] != '\\' || IsMBSTrail(pszChars, nLength - 1)) diff --git a/Externals/crystaledit/editlib/parsers/ruby.cpp b/Externals/crystaledit/editlib/parsers/ruby.cpp index 5d3fcdf6c5e..4fc063d7ed0 100644 --- a/Externals/crystaledit/editlib/parsers/ruby.cpp +++ b/Externals/crystaledit/editlib/parsers/ruby.cpp @@ -120,6 +120,43 @@ IsRubyConstant (const tchar_t *pszChars, int nLength) return ISXKEYWORD (s_apszRubyConstantsList, pszChars, nLength); } +static inline void +DefineIdentiferBlock(const tchar_t *pszChars, int nLength, CrystalLineParser::TEXTBLOCK * pBuf, int &nActualItems, int nIdentBegin, int I) +{ + if (IsRubyKeyword (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); + } + else if (IsRubyConstant (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_PREPROCESSOR); + } + else if (CrystalLineParser::IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); + } + else + { + bool bFunction = false; + + for (int j = I; j < nLength; j++) + { + if (!xisspace (pszChars[j])) + { + if (pszChars[j] == '(') + { + bFunction = true; + } + break; + } + } + if (bFunction) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); + } + } +} + unsigned CrystalLineParser::ParseLineRuby(unsigned dwCookie, const tchar_t *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems) { @@ -268,38 +305,7 @@ CrystalLineParser::ParseLineRuby(unsigned dwCookie, const tchar_t *pszChars, int { if (nIdentBegin >= 0) { - if (IsRubyKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsRubyConstant (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_PREPROCESSOR); - } - else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } - else - { - bool bFunction = false; - - for (int j = I; j < nLength; j++) - { - if (!xisspace (pszChars[j])) - { - if (pszChars[j] == '(') - { - bFunction = true; - } - break; - } - } - if (bFunction) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); - } - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I); bRedefineBlock = true; bDecIndex = true; nIdentBegin = -1; @@ -309,38 +315,7 @@ CrystalLineParser::ParseLineRuby(unsigned dwCookie, const tchar_t *pszChars, int if (nIdentBegin >= 0) { - if (IsRubyKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsRubyConstant (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_PREPROCESSOR); - } - else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } - else - { - bool bFunction = false; - - for (int j = I; j < nLength; j++) - { - if (!xisspace (pszChars[j])) - { - if (pszChars[j] == '(') - { - bFunction = true; - } - break; - } - } - if (bFunction) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); - } - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I); } if (pszChars[nLength - 1] != '\\' || IsMBSTrail(pszChars, nLength - 1)) diff --git a/Externals/crystaledit/editlib/parsers/rust.cpp b/Externals/crystaledit/editlib/parsers/rust.cpp index 339b3ac0ac6..032c281ac29 100644 --- a/Externals/crystaledit/editlib/parsers/rust.cpp +++ b/Externals/crystaledit/editlib/parsers/rust.cpp @@ -123,6 +123,43 @@ IsUser1Keyword (const tchar_t *pszChars, int nLength) return ISXKEYWORD (s_apszUser1KeywordList, pszChars, nLength); } +static inline void +DefineIdentiferBlock(const tchar_t *pszChars, int nLength, CrystalLineParser::TEXTBLOCK * pBuf, int &nActualItems, int nIdentBegin, int I) +{ + if (IsRustKeyword (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); + } + else if (IsUser1Keyword (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER1); + } + else if (CrystalLineParser::IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); + } + else + { + bool bFunction = false; + + for (int j = I; j < nLength; j++) + { + if (!xisspace (pszChars[j]) && pszChars[j] != '!') + { + if (pszChars[j] == '(') + { + bFunction = true; + } + break; + } + } + if (bFunction) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); + } + } +} + unsigned CrystalLineParser::ParseLineRust (unsigned dwCookie, const tchar_t *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems) { @@ -296,38 +333,7 @@ CrystalLineParser::ParseLineRust (unsigned dwCookie, const tchar_t *pszChars, in { if (nIdentBegin >= 0) { - if (IsRustKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsUser1Keyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER1); - } - else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } - else - { - bool bFunction = false; - - for (int j = I; j < nLength; j++) - { - if (!xisspace (pszChars[j]) && pszChars[j] != '!') - { - if (pszChars[j] == '(') - { - bFunction = true; - } - break; - } - } - if (bFunction) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); - } - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I); bRedefineBlock = true; bDecIndex = true; nIdentBegin = -1; @@ -337,38 +343,7 @@ CrystalLineParser::ParseLineRust (unsigned dwCookie, const tchar_t *pszChars, in if (nIdentBegin >= 0) { - if (IsRustKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsUser1Keyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER1); - } - else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } - else - { - bool bFunction = false; - - for (int j = I; j < nLength; j++) - { - if (!xisspace (pszChars[j]) && pszChars[j] != '!') - { - if (pszChars[j] == '(') - { - bFunction = true; - } - break; - } - } - if (bFunction) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); - } - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I); } dwCookie &= COOKIE_EXT_COMMENT | COOKIE_RAWSTRING | COOKIE_STRING | 0xFF000000; diff --git a/Externals/crystaledit/editlib/parsers/sh.cpp b/Externals/crystaledit/editlib/parsers/sh.cpp index fa5d4122fa1..b83cb379bc5 100644 --- a/Externals/crystaledit/editlib/parsers/sh.cpp +++ b/Externals/crystaledit/editlib/parsers/sh.cpp @@ -80,6 +80,43 @@ IsUser1Keyword (const tchar_t *pszChars, int nLength) return ISXKEYWORDI (s_apszUser1KeywordList, pszChars, nLength); } +static inline void +DefineIdentiferBlock(const tchar_t *pszChars, int nLength, CrystalLineParser::TEXTBLOCK * pBuf, int &nActualItems, int nIdentBegin, int I) +{ + if (IsShKeyword (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); + } + else if (IsUser1Keyword (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER1); + } + else if (CrystalLineParser::IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); + } + else + { + bool bFunction = false; + + for (int j = I; j < nLength; j++) + { + if (!xisspace (pszChars[j])) + { + if (pszChars[j] == '(') + { + bFunction = true; + } + break; + } + } + if (bFunction) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); + } + } +} + unsigned CrystalLineParser::ParseLineSh (unsigned dwCookie, const tchar_t *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems) { @@ -204,38 +241,7 @@ CrystalLineParser::ParseLineSh (unsigned dwCookie, const tchar_t *pszChars, int { if (nIdentBegin >= 0) { - if (IsShKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsUser1Keyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER1); - } - else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } - else - { - bool bFunction = false; - - for (int j = I; j < nLength; j++) - { - if (!xisspace (pszChars[j])) - { - if (pszChars[j] == '(') - { - bFunction = true; - } - break; - } - } - if (bFunction) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); - } - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I); bRedefineBlock = true; bDecIndex = true; nIdentBegin = -1; @@ -245,38 +251,7 @@ CrystalLineParser::ParseLineSh (unsigned dwCookie, const tchar_t *pszChars, int if (nIdentBegin >= 0) { - if (IsShKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsUser1Keyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER1); - } - else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } - else - { - bool bFunction = false; - - for (int j = I; j < nLength; j++) - { - if (!xisspace (pszChars[j])) - { - if (pszChars[j] == '(') - { - bFunction = true; - } - break; - } - } - if (bFunction) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); - } - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I); } if (pszChars[nLength - 1] != '\\' || IsMBSTrail(pszChars, nLength - 1)) diff --git a/Externals/crystaledit/editlib/parsers/siod.cpp b/Externals/crystaledit/editlib/parsers/siod.cpp index 0cdea385bd8..7159ac20eb3 100644 --- a/Externals/crystaledit/editlib/parsers/siod.cpp +++ b/Externals/crystaledit/editlib/parsers/siod.cpp @@ -336,6 +336,68 @@ IsUser2Keyword (const tchar_t *pszChars, int nLength) return ISXKEYWORDI (s_apszUser2KeywordList, pszChars, nLength); } +static inline void +DefineIdentiferBlock(const tchar_t *pszChars, int nLength, CrystalLineParser::TEXTBLOCK * pBuf, int &nActualItems, int nIdentBegin, int I, bool &bDefun) +{ + if (IsSiodKeyword (pszChars + nIdentBegin, I - nIdentBegin)) + { + if (!tc::tcsnicmp (_T ("defun"), pszChars + nIdentBegin, 5)) + { + bDefun = true; + } + DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); + } + else if (IsUser1Keyword (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER1); + } + else if (IsUser2Keyword (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER2); + } + else if (CrystalLineParser::IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); + } + else + { + bool bFunction = false; + + if (!bDefun) + { + for (int j = nIdentBegin; --j >= 0;) + { + if (!xisspace (pszChars[j])) + { + if (pszChars[j] == '(') + { + bFunction = true; + } + break; + } + } + } + if (!bFunction) + { + for (int j = I; j >= 0; j--) + { + if (!xisspace (pszChars[j])) + { + if (pszChars[j] == '(') + { + bFunction = true; + } + break; + } + } + } + if (bFunction) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); + } + } +} + unsigned CrystalLineParser::ParseLineSiod (unsigned dwCookie, const tchar_t *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems) { @@ -483,63 +545,7 @@ CrystalLineParser::ParseLineSiod (unsigned dwCookie, const tchar_t *pszChars, in { if (nIdentBegin >= 0) { - if (IsSiodKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - if (!tc::tcsnicmp (_T ("defun"), pszChars + nIdentBegin, 5)) - { - bDefun = true; - } - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsUser1Keyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER1); - } - else if (IsUser2Keyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER2); - } - else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } - else - { - bool bFunction = false; - - if (!bDefun) - { - for (int j = nIdentBegin; --j >= 0;) - { - if (!xisspace (pszChars[j])) - { - if (pszChars[j] == '(') - { - bFunction = true; - } - break; - } - } - } - if (!bFunction) - { - for (int j = I; j >= 0; j--) - { - if (!xisspace (pszChars[j])) - { - if (pszChars[j] == '(') - { - bFunction = true; - } - break; - } - } - } - if (bFunction) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); - } - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I, bDefun); bRedefineBlock = true; bDecIndex = true; nIdentBegin = -1; @@ -549,63 +555,7 @@ CrystalLineParser::ParseLineSiod (unsigned dwCookie, const tchar_t *pszChars, in if (nIdentBegin >= 0) { - if (IsSiodKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - if (!tc::tcsnicmp (_T ("defun"), pszChars + nIdentBegin, 5)) - { - bDefun = true; - } - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsUser1Keyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER1); - } - else if (IsUser2Keyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER2); - } - else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } - else - { - bool bFunction = false; - - if (!bDefun) - { - for (int j = nIdentBegin; --j >= 0;) - { - if (!xisspace (pszChars[j])) - { - if (pszChars[j] == '(') - { - bFunction = true; - } - break; - } - } - } - if (!bFunction) - { - for (int j = I; j >= 0; j--) - { - if (!xisspace (pszChars[j])) - { - if (pszChars[j] == '(') - { - bFunction = true; - } - break; - } - } - } - if (bFunction) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); - } - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I, bDefun); } dwCookie &= COOKIE_EXT_COMMENT; diff --git a/Externals/crystaledit/editlib/parsers/smarty.cpp b/Externals/crystaledit/editlib/parsers/smarty.cpp index 964f0595b1d..cb0e926c4df 100644 --- a/Externals/crystaledit/editlib/parsers/smarty.cpp +++ b/Externals/crystaledit/editlib/parsers/smarty.cpp @@ -161,6 +161,55 @@ IsUser2Keyword (const tchar_t *pszChars, int nLength) return ISXKEYWORDI (s_apszVariableModifierList, pszChars, nLength); } +static inline void +DefineIdentiferBlock(const tchar_t *pszChars, int nLength, CrystalLineParser::TEXTBLOCK * pBuf, int &nActualItems, int nIdentBegin, int I, DWORD dwCookie) +{ + if (dwCookie & COOKIE_USER2) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER1); + } + if (IsSmartyKeyword (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); + } + else if (IsUser1Keyword (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); + } + else if (IsUser2Keyword (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER2); + } + else if (IsOperatorKeyword(pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK(nIdentBegin, COLORINDEX_OPERATOR); + } + else if (CrystalLineParser::IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); + } + else + { + bool bFunction = false; + + for (int j = I; j < nLength; j++) + { + if (!xisspace (pszChars[j])) + { + if (pszChars[j] == '(') + { + bFunction = true; + } + break; + } + } + if (bFunction) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); + } + } +} + unsigned CrystalLineParser::ParseLineSmarty(unsigned dwCookie, const tchar_t* pszChars, int nLength, TEXTBLOCK* pBuf, int& nActualItems) { @@ -333,50 +382,7 @@ CrystalLineParser::ParseLineSmartyLanguage (unsigned dwCookie, const tchar_t *ps { if (nIdentBegin >= 0) { - if (dwCookie & COOKIE_USER2) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER1); - } - if (IsSmartyKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsUser1Keyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); - } - else if (IsUser2Keyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER2); - } - else if (IsOperatorKeyword(pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK(nIdentBegin, COLORINDEX_OPERATOR); - } - else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } - else - { - bool bFunction = false; - - for (int j = I; j < nLength; j++) - { - if (!xisspace (pszChars[j])) - { - if (pszChars[j] == '(') - { - bFunction = true; - } - break; - } - } - if (bFunction) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); - } - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I, dwCookie); bRedefineBlock = true; bDecIndex = true; nIdentBegin = -1; @@ -405,46 +411,7 @@ CrystalLineParser::ParseLineSmartyLanguage (unsigned dwCookie, const tchar_t *ps if (nIdentBegin >= 0) { - if (IsSmartyKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsUser1Keyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); - } - else if (IsUser2Keyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER2); - } - else if (IsOperatorKeyword(pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK(nIdentBegin, COLORINDEX_OPERATOR); - } - else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } - else - { - bool bFunction = false; - - for (int j = I; j < nLength; j++) - { - if (!xisspace (pszChars[j])) - { - if (pszChars[j] == '(') - { - bFunction = true; - } - break; - } - } - if (bFunction) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); - } - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I, dwCookie); } dwCookie &= (COOKIE_EXT_COMMENT | COOKIE_STRING | COOKIE_CHAR); diff --git a/Externals/crystaledit/editlib/parsers/sql.cpp b/Externals/crystaledit/editlib/parsers/sql.cpp index 97ef97f3236..a268dc2230e 100644 --- a/Externals/crystaledit/editlib/parsers/sql.cpp +++ b/Externals/crystaledit/editlib/parsers/sql.cpp @@ -453,6 +453,43 @@ IsUser1Keyword (const tchar_t *pszChars, int nLength) return ISXKEYWORDI (s_apszUser1KeywordList, pszChars, nLength); } +static inline void +DefineIdentiferBlock(const tchar_t *pszChars, int nLength, CrystalLineParser::TEXTBLOCK * pBuf, int &nActualItems, int nIdentBegin, int I) +{ + if (IsSqlKeyword (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); + } + else if (IsUser1Keyword (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER1); + } + else if (CrystalLineParser::IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); + } + else + { + bool bFunction = false; + + for (int j = I; j < nLength; j++) + { + if (!xisspace (pszChars[j])) + { + if (pszChars[j] == '(') + { + bFunction = true; + } + break; + } + } + if (bFunction) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); + } + } +} + unsigned CrystalLineParser::ParseLineSql (unsigned dwCookie, const tchar_t *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems) { @@ -600,38 +637,7 @@ CrystalLineParser::ParseLineSql (unsigned dwCookie, const tchar_t *pszChars, int { if (nIdentBegin >= 0) { - if (IsSqlKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsUser1Keyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER1); - } - else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } - else - { - bool bFunction = false; - - for (int j = I; j < nLength; j++) - { - if (!xisspace (pszChars[j])) - { - if (pszChars[j] == '(') - { - bFunction = true; - } - break; - } - } - if (bFunction) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); - } - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I); bRedefineBlock = true; bDecIndex = true; nIdentBegin = -1; @@ -641,38 +647,7 @@ CrystalLineParser::ParseLineSql (unsigned dwCookie, const tchar_t *pszChars, int if (nIdentBegin >= 0) { - if (IsSqlKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsUser1Keyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER1); - } - else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } - else - { - bool bFunction = false; - - for (int j = I; j < nLength; j++) - { - if (!xisspace (pszChars[j])) - { - if (pszChars[j] == '(') - { - bFunction = true; - } - break; - } - } - if (bFunction) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); - } - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I); } if (pszChars[nLength - 1] != '\\' || IsMBSTrail(pszChars, nLength - 1)) diff --git a/Externals/crystaledit/editlib/parsers/tcl.cpp b/Externals/crystaledit/editlib/parsers/tcl.cpp index cf91ec62f83..620433886c2 100644 --- a/Externals/crystaledit/editlib/parsers/tcl.cpp +++ b/Externals/crystaledit/editlib/parsers/tcl.cpp @@ -48,6 +48,39 @@ IsTclKeyword (const tchar_t *pszChars, int nLength) return ISXKEYWORDI (s_apszTclKeywordList, pszChars, nLength); } +static inline void +DefineIdentiferBlock(const tchar_t *pszChars, int nLength, CrystalLineParser::TEXTBLOCK * pBuf, int &nActualItems, int nIdentBegin, int I) +{ + if (IsTclKeyword (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); + } + else if (CrystalLineParser::IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); + } + else + { + bool bFunction = false; + + for (int j = I; j < nLength; j++) + { + if (!xisspace (pszChars[j])) + { + if (pszChars[j] == '(') + { + bFunction = true; + } + break; + } + } + if (bFunction) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); + } + } +} + unsigned CrystalLineParser::ParseLineTcl (unsigned dwCookie, const tchar_t *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems) { @@ -172,34 +205,7 @@ CrystalLineParser::ParseLineTcl (unsigned dwCookie, const tchar_t *pszChars, int { if (nIdentBegin >= 0) { - if (IsTclKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } - else - { - bool bFunction = false; - - for (int j = I; j < nLength; j++) - { - if (!xisspace (pszChars[j])) - { - if (pszChars[j] == '(') - { - bFunction = true; - } - break; - } - } - if (bFunction) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); - } - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I); bRedefineBlock = true; bDecIndex = true; nIdentBegin = -1; @@ -209,34 +215,7 @@ CrystalLineParser::ParseLineTcl (unsigned dwCookie, const tchar_t *pszChars, int if (nIdentBegin >= 0) { - if (IsTclKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } - else - { - bool bFunction = false; - - for (int j = I; j < nLength; j++) - { - if (!xisspace (pszChars[j])) - { - if (pszChars[j] == '(') - { - bFunction = true; - } - break; - } - } - if (bFunction) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); - } - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I); } if (pszChars[nLength - 1] != '\\' || IsMBSTrail(pszChars, nLength - 1)) diff --git a/Externals/crystaledit/editlib/parsers/verilog.cpp b/Externals/crystaledit/editlib/parsers/verilog.cpp index bfa4670e271..246b28f4d48 100644 --- a/Externals/crystaledit/editlib/parsers/verilog.cpp +++ b/Externals/crystaledit/editlib/parsers/verilog.cpp @@ -331,6 +331,23 @@ IsVerilogNumber (const tchar_t *pszChars, int nLength) return true; } +static inline void +DefineIdentiferBlock(const tchar_t *pszChars, int nLength, CrystalLineParser::TEXTBLOCK * pBuf, int &nActualItems, int nIdentBegin, int I) +{ + if (IsVerilogKeyword (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); + } + else if (IsVerilogFunction (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER1); + } + else if (IsVerilogNumber (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); + } +} + unsigned CrystalLineParser::ParseLineVerilog (unsigned dwCookie, const tchar_t *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems) { @@ -484,18 +501,7 @@ CrystalLineParser::ParseLineVerilog (unsigned dwCookie, const tchar_t *pszChars, { if (nIdentBegin >= 0) { - if (IsVerilogKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsVerilogFunction (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER1); - } - else if (IsVerilogNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I); bRedefineBlock = true; bDecIndex = true; nIdentBegin = -1; @@ -505,18 +511,7 @@ CrystalLineParser::ParseLineVerilog (unsigned dwCookie, const tchar_t *pszChars, if (nIdentBegin >= 0) { - if (IsVerilogKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsVerilogFunction (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); - } - else if (IsVerilogNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I); } dwCookie &= COOKIE_EXT_COMMENT; diff --git a/Externals/crystaledit/editlib/parsers/vhdl.cpp b/Externals/crystaledit/editlib/parsers/vhdl.cpp index 224e2a69f18..62c70452c26 100644 --- a/Externals/crystaledit/editlib/parsers/vhdl.cpp +++ b/Externals/crystaledit/editlib/parsers/vhdl.cpp @@ -328,6 +328,40 @@ IsVhdlChar (const tchar_t *pszChars, int nLength) return false; } +static inline void +DefineIdentiferBlock(const tchar_t *pszChars, int nLength, CrystalLineParser::TEXTBLOCK * pBuf, int &nActualItems, int nIdentBegin, int I, unsigned &dwCookie, int &nAttributeBegin) +{ + if (IsVhdlNumber (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); + } + else if (pszChars[nIdentBegin] == '"') + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_STRING); + dwCookie |= COOKIE_STRING; + } + else if (IsVhdlKeyword (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); + } + else if (IsVhdlAttribute (pszChars + nIdentBegin, I - nIdentBegin, &nAttributeBegin)) + { + DEFINE_BLOCK (nIdentBegin + nAttributeBegin, COLORINDEX_FUNCNAME); + } + else if (IsVhdlType (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_PREPROCESSOR); + } + else if (IsVhdlFunction (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); + } + else if (IsVhdlChar (pszChars + nIdentBegin, I - nIdentBegin)) + { + DEFINE_BLOCK (nIdentBegin, COLORINDEX_STRING); + } +} + unsigned CrystalLineParser::ParseLineVhdl (unsigned dwCookie, const tchar_t *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems) { @@ -446,36 +480,7 @@ CrystalLineParser::ParseLineVhdl (unsigned dwCookie, const tchar_t *pszChars, in { if (nIdentBegin >= 0) { - if (IsVhdlNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } - else if (pszChars[nIdentBegin] == '"') - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_STRING); - dwCookie |= COOKIE_STRING; - continue; - } - else if (IsVhdlKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsVhdlAttribute (pszChars + nIdentBegin, I - nIdentBegin, &nAttributeBegin)) - { - DEFINE_BLOCK (nIdentBegin + nAttributeBegin, COLORINDEX_FUNCNAME); - } - else if (IsVhdlType (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_PREPROCESSOR); - } - else if (IsVhdlFunction (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); - } - else if (IsVhdlChar (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_STRING); - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I, dwCookie, nAttributeBegin); bRedefineBlock = true; bDecIndex = true; nIdentBegin = -1; @@ -485,35 +490,7 @@ CrystalLineParser::ParseLineVhdl (unsigned dwCookie, const tchar_t *pszChars, in if (nIdentBegin >= 0) { - if (IsVhdlNumber (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER); - } - else if (pszChars[nIdentBegin] == '"') - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_STRING); - dwCookie |= COOKIE_STRING; - } - else if (IsVhdlKeyword (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD); - } - else if (IsVhdlAttribute (pszChars + nIdentBegin, I - nIdentBegin, &nAttributeBegin)) - { - DEFINE_BLOCK (nIdentBegin + nAttributeBegin, COLORINDEX_FUNCNAME); - } - else if (IsVhdlType (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_PREPROCESSOR); - } - else if (IsVhdlFunction (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME); - } - else if (IsVhdlChar (pszChars + nIdentBegin, I - nIdentBegin)) - { - DEFINE_BLOCK (nIdentBegin, COLORINDEX_STRING); - } + DefineIdentiferBlock(pszChars, nLength, pBuf, nActualItems, nIdentBegin, I, dwCookie, nAttributeBegin); } dwCookie &= COOKIE_EXT_COMMENT;