mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-26 04:43:10 +00:00
Add detection of eval
to the parser
While `eval` is still a function, this paves the way for changing that in the future, and lets the proc/exec functions detect when an eval is used to allow/disallow certain behaviors and optimizations.
This commit is contained in:
parent
25dd22242d
commit
0bda853dc7
6 changed files with 23 additions and 3 deletions
|
@ -1465,6 +1465,14 @@ void completer_t::perform() {
|
|||
use_abbr = false;
|
||||
break;
|
||||
}
|
||||
case parse_statement_decoration_eval: {
|
||||
use_command = true;
|
||||
use_function = true;
|
||||
use_builtin = true;
|
||||
use_implicit_cd = false;
|
||||
use_abbr = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (cmd_node.location_in_or_at_end_of_source_range(pos)) {
|
||||
|
|
|
@ -944,6 +944,7 @@ static bool exec_process_in_job(parser_t &parser, process_t *p, std::shared_ptr<
|
|||
// Execute the process.
|
||||
p->check_generations_before_launch();
|
||||
switch (p->type) {
|
||||
case process_type_t::eval: /* so long as `eval` is a function */
|
||||
case process_type_t::function:
|
||||
case process_type_t::block_node: {
|
||||
// Allow buffering unless this is a deferred run. If deferred, then processes after us
|
||||
|
|
|
@ -97,7 +97,6 @@ const enum_map<parse_token_type_t> token_enum_map[] = {
|
|||
//
|
||||
// IMPORTANT: These enums must start at zero.
|
||||
enum parse_keyword_t {
|
||||
parse_keyword_none = 0,
|
||||
parse_keyword_and,
|
||||
parse_keyword_begin,
|
||||
parse_keyword_builtin,
|
||||
|
@ -105,13 +104,15 @@ enum parse_keyword_t {
|
|||
parse_keyword_command,
|
||||
parse_keyword_else,
|
||||
parse_keyword_end,
|
||||
parse_keyword_eval,
|
||||
parse_keyword_exclam,
|
||||
parse_keyword_exec,
|
||||
parse_keyword_for,
|
||||
parse_keyword_function,
|
||||
parse_keyword_if,
|
||||
parse_keyword_in,
|
||||
parse_keyword_none,
|
||||
parse_keyword_not,
|
||||
parse_keyword_exclam,
|
||||
parse_keyword_or,
|
||||
parse_keyword_switch,
|
||||
parse_keyword_while,
|
||||
|
@ -125,6 +126,7 @@ const enum_map<parse_keyword_t> keyword_enum_map[] = {{parse_keyword_exclam, L"!
|
|||
{parse_keyword_command, L"command"},
|
||||
{parse_keyword_else, L"else"},
|
||||
{parse_keyword_end, L"end"},
|
||||
{parse_keyword_eval, L"eval"},
|
||||
{parse_keyword_exec, L"exec"},
|
||||
{parse_keyword_for, L"for"},
|
||||
{parse_keyword_function, L"function"},
|
||||
|
@ -144,7 +146,8 @@ enum parse_statement_decoration_t {
|
|||
parse_statement_decoration_none,
|
||||
parse_statement_decoration_command,
|
||||
parse_statement_decoration_builtin,
|
||||
parse_statement_decoration_exec
|
||||
parse_statement_decoration_exec,
|
||||
parse_statement_decoration_eval,
|
||||
};
|
||||
|
||||
// Boolean statement types, stored in node tag.
|
||||
|
|
|
@ -334,6 +334,8 @@ DEF_ALT(decorated_statement) {
|
|||
using cmds = seq<keyword<parse_keyword_command>, plain_statement>;
|
||||
using builtins = seq<keyword<parse_keyword_builtin>, plain_statement>;
|
||||
using execs = seq<keyword<parse_keyword_exec>, plain_statement>;
|
||||
// using evals = seq<keyword<parse_keyword_eval>, plain_statement>;
|
||||
using evals = single<plain_statement>; /* so long as `eval` is a function */
|
||||
ALT_BODY(decorated_statement, plains, cmds, builtins, execs);
|
||||
};
|
||||
|
||||
|
|
|
@ -314,6 +314,10 @@ RESOLVE(decorated_statement) {
|
|||
*out_tag = parse_statement_decoration_exec;
|
||||
return production_for<execs>();
|
||||
}
|
||||
case parse_keyword_eval: {
|
||||
*out_tag = parse_statement_decoration_eval;
|
||||
return production_for<evals>();
|
||||
}
|
||||
default: {
|
||||
*out_tag = parse_statement_decoration_none;
|
||||
return production_for<plains>();
|
||||
|
|
|
@ -36,6 +36,8 @@ enum class process_type_t {
|
|||
block_node,
|
||||
/// The exec builtin.
|
||||
exec,
|
||||
/// A literal evaluation
|
||||
eval,
|
||||
};
|
||||
|
||||
enum class job_control_t {
|
||||
|
|
Loading…
Reference in a new issue