viml/parser/expressions: Forbid dot or alpha characters after a float

This is basically what Vim already does, in addition to forbidding floats should
there be a concat immediately before it.
This commit is contained in:
ZyX
2017-10-03 00:39:40 +03:00
parent 6168e1127c
commit 0bc4e22379
2 changed files with 15 additions and 12 deletions

View File

@@ -186,6 +186,7 @@ LexExprToken viml_pexpr_next_token(ParserState *const pstate, const int flags)
ret.data.num.is_float = false;
CHARREG(kExprLexNumber, ascii_isdigit);
if (flags & kELFlagAllowFloat) {
const LexExprToken non_float_ret = ret;
if (pline.size > ret.len + 1
&& pline.data[ret.len] == '.'
&& ascii_isdigit(pline.data[ret.len + 1])) {
@@ -207,6 +208,11 @@ LexExprToken viml_pexpr_next_token(ParserState *const pstate, const int flags)
CHARREG(kExprLexNumber, ascii_isdigit);
}
}
if (pline.size > ret.len
&& (pline.data[ret.len] == '.'
|| ASCII_ISALPHA(pline.data[ret.len]))) {
ret = non_float_ret;
}
}
break;
}