From b20e12a326ad36c203002b2529f5ba28559f5d27 Mon Sep 17 00:00:00 2001 From: Vadim Lopatin Date: Mon, 11 Sep 2017 13:35:19 +0300 Subject: [PATCH] fix tokenizer keyword detection - #269 --- src/ddc/lexer/tokenizer.d | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/ddc/lexer/tokenizer.d b/src/ddc/lexer/tokenizer.d index 3fbce93..16ec5e3 100644 --- a/src/ddc/lexer/tokenizer.d +++ b/src/ddc/lexer/tokenizer.d @@ -883,7 +883,8 @@ public Keyword findKeyword(Keyword start, Keyword end, dchar * name, int len, re } } if (found) { - if (s.length == len - 1 || !isIdentMiddleChar(name[s.length - 1])) { + //if (s.length == len - 1 || !isIdentMiddleChar(name[s.length - 1])) { + if (s.length == len + 1 || !isIdentMiddleChar(name[s.length - 1])) { pos += s.length - 1; return i; } @@ -3439,5 +3440,8 @@ TEST" checkReal(25.67e-5f, 0), checkEOF() ]); + // strange keyword detection: `fork;` or `ind;` keyword in beginning of ident is highlighted + testTokenizer("fork;", [checkIdent("fork"),checkOp(OpCode.SEMICOLON),checkEOF()]); + }