Skip to content

Syntax/Pascal: Support multiline strings #2720

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 11, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 27 additions & 7 deletions Externals/crystaledit/editlib/parsers/pascal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ unsigned
CrystalLineParser::ParseLinePascal (unsigned dwCookie, const tchar_t *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems)
{
if (nLength == 0)
return dwCookie & (COOKIE_EXT_COMMENT | COOKIE_EXT_COMMENT2);
return dwCookie & (COOKIE_EXT_COMMENT | COOKIE_EXT_COMMENT2 | COOKIE_BLOCK_STYLE);

bool bRedefineBlock = true;
bool bDecIndex = false;
Expand All @@ -174,7 +174,7 @@ CrystalLineParser::ParseLinePascal (unsigned dwCookie, const tchar_t *pszChars,
{
DEFINE_BLOCK (nPos, COLORINDEX_COMMENT);
}
else if (dwCookie & (COOKIE_CHAR | COOKIE_STRING))
else if (dwCookie & (COOKIE_CHAR | COOKIE_STRING | COOKIE_BLOCK_STYLE))
{
DEFINE_BLOCK (nPos, COLORINDEX_STRING);
}
Expand Down Expand Up @@ -221,12 +221,32 @@ CrystalLineParser::ParseLinePascal (unsigned dwCookie, const tchar_t *pszChars,
}

// Char constant '..'
if (dwCookie & COOKIE_CHAR)
if (dwCookie & COOKIE_CHAR || dwCookie & COOKIE_BLOCK_STYLE)
{
if (pszChars[I] == '\'' && (I == 0 || I == 1 && pszChars[nPrevI] != '\\' || I >= 2 && (pszChars[nPrevI] != '\\' || *tc::tcharprev(pszChars, pszChars + nPrevI) == '\\')))
{
dwCookie &= ~COOKIE_CHAR;
bRedefineBlock = true;
// Multiline string ('''...''')?
if (((nLength >= I + 1) && (pszChars[I+1] == '\'')) || (dwCookie & COOKIE_BLOCK_STYLE))
{
if (dwCookie & COOKIE_BLOCK_STYLE)
{
// End of multiline string
dwCookie &= ~COOKIE_BLOCK_STYLE;
}
else
{
// Start of multiline string
dwCookie |= COOKIE_BLOCK_STYLE;
// Skip one
I++;
}
}
else
{
dwCookie &= ~COOKIE_CHAR;

bRedefineBlock = true;
}
}
continue;
}
Expand Down Expand Up @@ -278,7 +298,7 @@ CrystalLineParser::ParseLinePascal (unsigned dwCookie, const tchar_t *pszChars,
continue;
}
}
if (I > 0 && pszChars[I] == '*' && pszChars[nPrevI] == '(')
if (I > 0 && pszChars[I] == '*' && pszChars[nPrevI] == '(') // (*
{
DEFINE_BLOCK (nPrevI, COLORINDEX_COMMENT);
dwCookie |= COOKIE_EXT_COMMENT;
Expand Down Expand Up @@ -319,6 +339,6 @@ CrystalLineParser::ParseLinePascal (unsigned dwCookie, const tchar_t *pszChars,
}

if (pszChars[nLength - 1] != '\\' || IsMBSTrail(pszChars, nLength - 1))
dwCookie &= (COOKIE_EXT_COMMENT | COOKIE_EXT_COMMENT2);
dwCookie &= (COOKIE_EXT_COMMENT | COOKIE_EXT_COMMENT2 | COOKIE_BLOCK_STYLE);
return dwCookie;
}
Loading