aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorVicente <unknown>2017-11-05 09:49:56 +1100
committerVicente <unknown>2017-11-05 09:49:56 +1100
commit57a581f6bc86f11ca668e23b1e9ea66c4e23f9ba (patch)
tree976771523861eec866b3b80e0954426d551d60e5
parent0f4e2fa312e3450538e011f6919d0b325c3e2988 (diff)
downloadscintilla-mirror-57a581f6bc86f11ca668e23b1e9ea66c4e23f9ba.tar.gz
Stop treating '\' as an escape character in strings.
Detect character literals and assign SCE_VHDL_STRING to them.
-rw-r--r--doc/ScintillaHistory.html3
-rw-r--r--lexers/LexVHDL.cxx33
2 files changed, 29 insertions, 7 deletions
diff --git a/doc/ScintillaHistory.html b/doc/ScintillaHistory.html
index 051baf916..36039a5b4 100644
--- a/doc/ScintillaHistory.html
+++ b/doc/ScintillaHistory.html
@@ -538,6 +538,9 @@
Django tag inside of a &#123;# #&#125; Django comment does not break highlighting of rest of file
</li>
<li>
+ Improve VHDL lexer's handling of character literals and escape characters in strings.
+ </li>
+ <li>
Fix failure on Cocoa with animated find indicator in large files with macOS 10.13
by disabling animation on 10.13.
</li>
diff --git a/lexers/LexVHDL.cxx b/lexers/LexVHDL.cxx
index e0fc428fb..de87d2792 100644
--- a/lexers/LexVHDL.cxx
+++ b/lexers/LexVHDL.cxx
@@ -72,8 +72,9 @@ static void ColouriseVHDLDoc(
StyleContext sc(startPos, length, initStyle, styler);
bool isExtendedId = false; // true when parsing an extended identifier
- for (; sc.More(); sc.Forward())
+ while (sc.More())
{
+ bool advance = true;
// Determine if the current state should terminate.
if (sc.state == SCE_VHDL_OPERATOR) {
@@ -106,24 +107,28 @@ static void ColouriseVHDLDoc(
// extended identifiers are terminated by backslash, check for end of line in case we have invalid syntax
isExtendedId = false;
sc.ForwardSetState(SCE_VHDL_DEFAULT);
+ advance = false;
}
} else if (sc.state == SCE_VHDL_COMMENT || sc.state == SCE_VHDL_COMMENTLINEBANG) {
if (sc.atLineEnd) {
sc.SetState(SCE_VHDL_DEFAULT);
}
} else if (sc.state == SCE_VHDL_STRING) {
- if (sc.ch == '\\') {
- if (sc.chNext == '\"' || sc.chNext == '\'' || sc.chNext == '\\') {
+ if (sc.ch == '"') {
+ advance = false;
+ sc.Forward();
+ if (sc.ch == '"')
sc.Forward();
- }
- } else if (sc.ch == '\"') {
- sc.ForwardSetState(SCE_VHDL_DEFAULT);
+ else
+ sc.SetState(SCE_VHDL_DEFAULT);
} else if (sc.atLineEnd) {
+ advance = false;
sc.ChangeState(SCE_VHDL_STRINGEOL);
sc.ForwardSetState(SCE_VHDL_DEFAULT);
}
} else if (sc.state == SCE_VHDL_BLOCK_COMMENT){
if(sc.ch == '*' && sc.chNext == '/'){
+ advance = false;
sc.Forward();
sc.ForwardSetState(SCE_VHDL_DEFAULT);
}
@@ -142,8 +147,19 @@ static void ColouriseVHDLDoc(
sc.SetState(SCE_VHDL_COMMENT);
} else if (sc.Match('/', '*')){
sc.SetState(SCE_VHDL_BLOCK_COMMENT);
- } else if (sc.ch == '\"') {
+ } else if (sc.ch == '"') {
sc.SetState(SCE_VHDL_STRING);
+ } else if (sc.ch == '\'') {
+ if (sc.GetRelative(2) == '\''){
+ if (sc.chNext != '(' || sc.GetRelative(4) != '\''){
+ // Can only be a character literal
+ sc.SetState(SCE_VHDL_STRING);
+ sc.Forward();
+ sc.Forward();
+ sc.ForwardSetState(SCE_VHDL_DEFAULT);
+ advance = false;
+ } // else can be a tick or a character literal, need more context, eg.: identifier'('x')
+ } // else can only be a tick
} else if (sc.ch == '\\') {
isExtendedId = true;
sc.SetState(SCE_VHDL_IDENTIFIER);
@@ -151,6 +167,9 @@ static void ColouriseVHDLDoc(
sc.SetState(SCE_VHDL_OPERATOR);
}
}
+
+ if (advance)
+ sc.Forward();
}
sc.Complete();
}