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 | 458304eb583a64fcdec5f5d9270417a1c5c628c8 (patch) | |
tree | 0f38b441721cc5fdc1eaba850a9d8a4f8b09040a | |
parent | e7243a4c941f75c9aebe9b035ef90e5af0ecd7f8 (diff) | |
download | scintilla-mirror-458304eb583a64fcdec5f5d9270417a1c5c628c8.tar.gz |
Backport: Feature [feature-requests:#1258]. Add function IsFuncName() to Nim lexer.
Backport of changeset 7235:6e959f8ec7d9.
-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 fae9e8d6e..c74c1a965 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; } |