aboutsummaryrefslogtreecommitdiffhomepage
path: root/lexers/LexMatlab.cxx
diff options
context:
space:
mode:
authorJohn Donoghue <john.donoghue@ieee.org>2017-06-29 07:54:05 -0400
committerJohn Donoghue <john.donoghue@ieee.org>2017-06-29 07:54:05 -0400
commit9c38cba4055ac8e4cd9fd92774c2c46e50c3bcf7 (patch)
treea5ffe0d3c3ad23d895249fcec83a6cf1f95785aa /lexers/LexMatlab.cxx
parent1df9c8ad39efea4595abfcc9a7305b72a4cf7565 (diff)
downloadscintilla-mirror-9c38cba4055ac8e4cd9fd92774c2c46e50c3bcf7.tar.gz
Bug [#1951]. matlab lexer - dont use 'end' as a keyword when used as a index.
(ColouriseMatlabOctaveDoc) - set end as a number if within brackets ()[]{} that would allow end as an index rather than a keyword.
Diffstat (limited to 'lexers/LexMatlab.cxx')
-rw-r--r--lexers/LexMatlab.cxx13
1 files changed, 13 insertions, 0 deletions
diff --git a/lexers/LexMatlab.cxx b/lexers/LexMatlab.cxx
index 45f0b6926..a0e3ea937 100644
--- a/lexers/LexMatlab.cxx
+++ b/lexers/LexMatlab.cxx
@@ -100,6 +100,9 @@ static void ColouriseMatlabOctaveDoc(
// of a string
bool transpose = false;
+ // count of brackets as boolean for when end could be an operator not a keyword
+ int allow_end_op = 0;
+
// approximate position of first non space character in a line
int nonSpaceColumn = -1;
// approximate column position of the current character in a line
@@ -153,7 +156,11 @@ static void ColouriseMatlabOctaveDoc(
if (!isalnum(sc.ch) && sc.ch != '_') {
char s[100];
sc.GetCurrentLowered(s, sizeof(s));
+
if (keywords.InList(s)) {
+ if (strcmp ("end", s) == 0 && allow_end_op) {
+ sc.ChangeState(SCE_MATLAB_NUMBER);
+ }
sc.SetState(SCE_MATLAB_DEFAULT);
transpose = false;
} else {
@@ -253,6 +260,12 @@ static void ColouriseMatlabOctaveDoc(
} else if (isalpha(sc.ch)) {
sc.SetState(SCE_MATLAB_KEYWORD);
} else if (isoperator(static_cast<char>(sc.ch)) || sc.ch == '@' || sc.ch == '\\') {
+ if (sc.ch == '(' || sc.ch == '[' || sc.ch == '{') {
+ allow_end_op ++;
+ } else if ((sc.ch == ')' || sc.ch == ']' || sc.ch == '}') && (allow_end_op > 0)) {
+ allow_end_op --;
+ }
+
if (sc.ch == ')' || sc.ch == ']' || sc.ch == '}') {
transpose = true;
} else {