mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
viml/parser/expressions: Make $ENV not depend on &isident
This commit is contained in:
parent
11a05e778f
commit
17077b6813
@ -983,7 +983,7 @@ typedef kvec_withinit_t(ExprASTConvStackItem, 16) ExprASTConvStack;
|
|||||||
/// "DoubleQuotedString" nodes.
|
/// "DoubleQuotedString" nodes.
|
||||||
Dictionary nvim_parse_expression(String expr, String flags, Boolean highlight,
|
Dictionary nvim_parse_expression(String expr, String flags, Boolean highlight,
|
||||||
Error *err)
|
Error *err)
|
||||||
FUNC_API_SINCE(4)
|
FUNC_API_SINCE(4) FUNC_API_ASYNC
|
||||||
{
|
{
|
||||||
int pflags = 0;
|
int pflags = 0;
|
||||||
for (size_t i = 0 ; i < flags.size ; i++) {
|
for (size_t i = 0 ; i < flags.size ; i++) {
|
||||||
|
@ -47,6 +47,8 @@
|
|||||||
// type of what is in the first expression is generally not known when
|
// type of what is in the first expression is generally not known when
|
||||||
// parsing, so to have separate expressions like this separate them with
|
// parsing, so to have separate expressions like this separate them with
|
||||||
// spaces.
|
// spaces.
|
||||||
|
// 7. 'isident' no longer applies to environment variables, they always include
|
||||||
|
// ASCII alphanumeric characters and underscore and nothing except this.
|
||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
@ -383,10 +385,14 @@ LexExprToken viml_pexpr_next_token(ParserState *const pstate, const int flags)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define ISWORD_OR_AUTOLOAD(x) \
|
||||||
|
(ASCII_ISALNUM(x) || (x) == AUTOLOAD_CHAR || (x) == '_')
|
||||||
|
#define ISWORD(x) \
|
||||||
|
(ASCII_ISALNUM(x) || (x) == '_')
|
||||||
|
|
||||||
// Environment variable.
|
// Environment variable.
|
||||||
case '$': {
|
case '$': {
|
||||||
// FIXME: Parser function can’t be thread-safe with vim_isIDc.
|
CHARREG(kExprLexEnv, ISWORD);
|
||||||
CHARREG(kExprLexEnv, vim_isIDc);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -400,10 +406,6 @@ LexExprToken viml_pexpr_next_token(ParserState *const pstate, const int flags)
|
|||||||
case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U':
|
case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U':
|
||||||
case 'V': case 'W': case 'X': case 'Y': case 'Z':
|
case 'V': case 'W': case 'X': case 'Y': case 'Z':
|
||||||
case '_': {
|
case '_': {
|
||||||
#define ISWORD_OR_AUTOLOAD(x) \
|
|
||||||
(ASCII_ISALNUM(x) || (x) == AUTOLOAD_CHAR || (x) == '_')
|
|
||||||
#define ISWORD(x) \
|
|
||||||
(ASCII_ISALNUM(x) || (x) == '_')
|
|
||||||
ret.data.var.scope = 0;
|
ret.data.var.scope = 0;
|
||||||
ret.data.var.autoload = false;
|
ret.data.var.autoload = false;
|
||||||
CHARREG(kExprLexPlainIdentifier, ISWORD);
|
CHARREG(kExprLexPlainIdentifier, ISWORD);
|
||||||
@ -441,9 +443,10 @@ LexExprToken viml_pexpr_next_token(ParserState *const pstate, const int flags)
|
|||||||
CHARREG(kExprLexPlainIdentifier, ISWORD_OR_AUTOLOAD);
|
CHARREG(kExprLexPlainIdentifier, ISWORD_OR_AUTOLOAD);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
#undef ISWORD_OR_AUTOLOAD
|
|
||||||
#undef ISWORD
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#undef ISWORD
|
||||||
|
#undef ISWORD_OR_AUTOLOAD
|
||||||
#undef CHARREG
|
#undef CHARREG
|
||||||
|
|
||||||
// Option.
|
// Option.
|
||||||
|
@ -717,6 +717,9 @@ describe('api', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
describe('nvim_parse_expression', function()
|
describe('nvim_parse_expression', function()
|
||||||
|
before_each(function()
|
||||||
|
meths.set_option('isident', '')
|
||||||
|
end)
|
||||||
local function simplify_east_api_node(line, east_api_node)
|
local function simplify_east_api_node(line, east_api_node)
|
||||||
if east_api_node == NIL then
|
if east_api_node == NIL then
|
||||||
return nil
|
return nil
|
||||||
|
Loading…
Reference in New Issue
Block a user