aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorVicente <unknown>2017-11-05 09:49:56 +1100
committerVicente <unknown>2017-11-05 09:49:56 +1100
commit15cdc7c516058f218d9f1aac1173b98c5ec1b50d (patch)
tree07c4e2f01aadf7ef639a9f5064ea4dad9d3ee2ae
parente7f619c6a2a7b7a586ab64e7be11dbaae095d7d0 (diff)
downloadscintilla-mirror-15cdc7c516058f218d9f1aac1173b98c5ec1b50d.tar.gz
Backport: Stop treating '\' as an escape character in strings.
Detect character literals and assign SCE_VHDL_STRING to them. Backport of changeset 6415:2407bf63ca01.
-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 ce2ada621..cc08532c6 100644
--- a/doc/ScintillaHistory.html
+++ b/doc/ScintillaHistory.html
@@ -569,6 +569,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>
The Baan lexer checks that matches to 3rd set of keywords are function calls and leaves as identifiers if not.
Baan lexer and folder support #context_on / #context_off preprocessor feature.
</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();
}