diff options
author | Jad Altahan <xviyy@aol.com> | 2019-01-23 07:43:00 +1100 |
---|---|---|
committer | Jad Altahan <xviyy@aol.com> | 2019-01-23 07:43:00 +1100 |
commit | bb1bdfa2f811ecc80f885d9fe024e16f46947a9a (patch) | |
tree | f0c404df2d64da6b16b3453bc8bf3f2befe05d3f | |
parent | 8a3ff5e93b7e1ca8055e41891433146304969074 (diff) | |
download | scintilla-mirror-bb1bdfa2f811ecc80f885d9fe024e16f46947a9a.tar.gz |
Feature [feature-requests:#1258]. Add function IsFuncName() to Nim lexer.
-rw-r--r-- | lexers/LexNim.cxx | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/lexers/LexNim.cxx b/lexers/LexNim.cxx index 52a8c7fd7..109b3547b 100644 --- a/lexers/LexNim.cxx +++ b/lexers/LexNim.cxx @@ -75,6 +75,26 @@ bool IsNewline(const int ch) { return (ch == '\n' || ch == '\r'); } +bool IsFuncName(const char *str) { + const char *identifiers[] = { + "proc", + "func", + "macro", + "method", + "template", + "iterator", + "converter" + }; + + for (const char *id : identifiers) { + if (strcmp(str, id) == 0) { + return true; + } + } + + return false; +} + constexpr bool IsTripleLiteral(const int style) noexcept { return style == SCE_NIM_TRIPLE || style == SCE_NIM_TRIPLEDOUBLE; } @@ -419,17 +439,7 @@ void SCI_METHOD LexerNim::Lex(Sci_PositionU startPos, Sci_Position length, sc.SetState(SCE_NIM_DEFAULT); if (style == SCE_NIM_WORD) { - if (0 == strcmp(s, "proc") - || 0 == strcmp(s, "func") - || 0 == strcmp(s, "macro") - || 0 == strcmp(s, "method") - || 0 == strcmp(s, "template") - || 0 == strcmp(s, "iterator") - || 0 == strcmp(s, "converter")) { - funcNameExists = true; - } else { - funcNameExists = false; - } + funcNameExists = IsFuncName(s); } else { funcNameExists = false; } |