mirror of
https://github.com/rizinorg/rizin
synced 2026-08-22 20:26:16 -04:00
RzShell: autocomplete '@e:' argument
This commit is contained in:
parent
55f68de68f
commit
f3cd78fa85
8 changed files with 9714 additions and 9636 deletions
|
|
@ -22,6 +22,7 @@ enum autocmplt_type_t {
|
|||
AUTOCMPLT_FILE, ///< A file needs to be autocompleted
|
||||
AUTOCMPLT_FLAG_SPACE, ///< A flag space needs to be autocompleted
|
||||
AUTOCMPLT_REG, ///< A cpu register needs to be autocompleted
|
||||
AUTOCMPLT_EVAL_FULL, ///< A name=value of a evaluable variable (e.g. `e` command)
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -817,6 +818,8 @@ static bool find_autocmplt_type_arg_identifier(struct autocmplt_data_t *ad, RzCo
|
|||
return fill_autocmplt_data(ad, AUTOCMPLT_FLAG_SPACE, lstart, lend);
|
||||
} else if (!ts_node_is_null(parent) && !strcmp(ts_node_type(parent), "tmp_reg_stmt")) {
|
||||
return fill_autocmplt_data(ad, AUTOCMPLT_REG, lstart, lend);
|
||||
} else if (!ts_node_is_null(parent) && !strcmp(ts_node_type(parent), "tmp_eval_stmt")) {
|
||||
return fill_autocmplt_data(ad, AUTOCMPLT_EVAL_FULL, lstart, lend);
|
||||
} else {
|
||||
return fill_autocmplt_data_cmdarg(ad, lstart, lend, buf->data, root, core);
|
||||
}
|
||||
|
|
@ -888,6 +891,8 @@ static bool find_autocmplt_type(struct autocmplt_data_t *ad, RzCore *core, TSNod
|
|||
return true;
|
||||
} else if (find_autocmplt_type_tmp_stmt_op(ad, core, buf, "tmp_reg_stmt", "a", AUTOCMPLT_REG)) {
|
||||
return true;
|
||||
} else if (find_autocmplt_type_tmp_stmt_op(ad, core, buf, "tmp_eval_stmt", "a", AUTOCMPLT_EVAL_FULL)) {
|
||||
return true;
|
||||
} else if (find_autocmplt_type_tmp_stmt(ad, core, buf)) {
|
||||
return true;
|
||||
}
|
||||
|
|
@ -959,6 +964,9 @@ RZ_API RzLineNSCompletionResult *rz_core_autocomplete_rzshell(RzCore *core, RzLi
|
|||
case AUTOCMPLT_REG:
|
||||
autocmplt_reg(core, ad.res, buf->data + ad.res->start, ad.res->end - ad.res->start);
|
||||
break;
|
||||
case AUTOCMPLT_EVAL_FULL:
|
||||
autocmplt_cmd_arg_eval_full(core, ad.res, buf->data + ad.res->start, ad.res->end - ad.res->start);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7170,7 +7170,7 @@ static const RzCmdDescDetailEntry tmp_modifiers_empty_detail_entries[] = {
|
|||
{ .text = "<cmd> @a:", .arg_str = "<arch>[:<bits>]", .comment = "Temporary set arch and bits, if specified" },
|
||||
{ .text = "<cmd> @b:", .arg_str = "<bits>", .comment = "Temporary set asm.bits" },
|
||||
{ .text = "<cmd> @B:", .arg_str = "<nth>", .comment = "Temporary seek to nth instruction in current basic block (negative numbers too)" },
|
||||
{ .text = "<cmd> @e:", .arg_str = "<k>=<v>[<k>=<v>]", .comment = "Temporary change eval vars (multiple vars separated by comma)" },
|
||||
{ .text = "<cmd> @e:", .arg_str = "<k>=<v>[,<k>=<v>]", .comment = "Temporary change eval vars (multiple vars separated by comma)" },
|
||||
{ .text = "<cmd> @f:", .arg_str = "<file>", .comment = "Temporary replace block with file contents" },
|
||||
{ .text = "<cmd> @F:", .arg_str = "<flagspace>", .comment = "Temporary change flag space" },
|
||||
{ .text = "<cmd> @i:", .arg_str = "<nth.op>", .comment = "Temporary seek to the Nth relative instruction" },
|
||||
|
|
|
|||
|
|
@ -297,7 +297,7 @@ commands:
|
|||
Temporary seek to nth instruction in current basic block
|
||||
(negative numbers too)
|
||||
- text: "<cmd> @e:"
|
||||
arg_str: "<k>=<v>[<k>=<v>]"
|
||||
arg_str: "<k>=<v>[,<k>=<v>]"
|
||||
comment: >
|
||||
Temporary change eval vars (multiple vars separated by comma)
|
||||
- text: "<cmd> @f:"
|
||||
|
|
|
|||
|
|
@ -116,13 +116,13 @@ pd 2 @e:asm.arch=x86,scr.utf8=true
|
|||
(tmp_eval_stmt
|
||||
(arged_stmt command: (cmd_identifier)
|
||||
args: (args (arg (arg_identifier))))
|
||||
(tmp_eval_args (tmp_eval_arg)))
|
||||
(args (arg (arg_identifier))))
|
||||
(tmp_eval_stmt
|
||||
(arged_stmt command: (cmd_identifier)
|
||||
args: (args (arg (arg_identifier))))
|
||||
(tmp_eval_args
|
||||
(tmp_eval_arg)
|
||||
(tmp_eval_arg))))
|
||||
(args
|
||||
(arg (arg_identifier))
|
||||
(arg (arg_identifier)))))
|
||||
|
||||
=================
|
||||
Temporary flagspace
|
||||
|
|
|
|||
|
|
@ -197,7 +197,7 @@ module.exports = grammar({
|
|||
tmp_arch_stmt: ($) => prec.right(1, seq($._simple_stmt, "@a:", $.arg)),
|
||||
tmp_bits_stmt: ($) => prec.right(1, seq($._simple_stmt, "@b:", $.args)),
|
||||
tmp_nthi_stmt: ($) => prec.right(1, seq($._simple_stmt, "@B:", $.arg)),
|
||||
tmp_eval_stmt: ($) => prec.right(1, seq($._simple_stmt, "@e:", $.tmp_eval_args)),
|
||||
tmp_eval_stmt: ($) => prec.right(1, seq($._simple_stmt, "@e:", alias($.tmp_eval_args, $.args))),
|
||||
tmp_fs_stmt: ($) => prec.right(1, seq($._simple_stmt, "@F:", $.arg)),
|
||||
tmp_reli_stmt: ($) => prec.right(1, seq($._simple_stmt, "@i:", $.args)),
|
||||
tmp_kuery_stmt: ($) => prec.right(1, seq($._simple_stmt, "@k:", $.arg)),
|
||||
|
|
@ -397,8 +397,8 @@ module.exports = grammar({
|
|||
arg: ($) => choice($._arg, $.concatenation),
|
||||
args: ($) => prec.left(repeat1($.arg)),
|
||||
// TODO: this should accept a quoted_arg and a cmd_substitution_arg as well
|
||||
tmp_eval_args: ($) => prec.left(seq($.tmp_eval_arg, repeat(seq(",", $.tmp_eval_arg)))),
|
||||
tmp_eval_arg: ($) => repeat1(noneOf(...SPECIAL_CHARACTERS_COMMA)),
|
||||
tmp_eval_args: ($) => prec.left(seq(alias($.tmp_eval_arg, $.arg), repeat(seq(",", alias($.tmp_eval_arg, $.arg))))),
|
||||
tmp_eval_arg: ($) => alias(repeat1(noneOf(...SPECIAL_CHARACTERS_COMMA)), $.arg_identifier),
|
||||
|
||||
_eq_sep_key_single: ($) =>
|
||||
choice(
|
||||
|
|
|
|||
40
shlr/rizin-shell-parser/src/grammar.json
generated
40
shlr/rizin-shell-parser/src/grammar.json
generated
|
|
@ -1229,8 +1229,13 @@
|
|||
"value": "@e:"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "tmp_eval_args"
|
||||
"type": "ALIAS",
|
||||
"content": {
|
||||
"type": "SYMBOL",
|
||||
"name": "tmp_eval_args"
|
||||
},
|
||||
"named": true,
|
||||
"value": "args"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -3110,8 +3115,13 @@
|
|||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "tmp_eval_arg"
|
||||
"type": "ALIAS",
|
||||
"content": {
|
||||
"type": "SYMBOL",
|
||||
"name": "tmp_eval_arg"
|
||||
},
|
||||
"named": true,
|
||||
"value": "arg"
|
||||
},
|
||||
{
|
||||
"type": "REPEAT",
|
||||
|
|
@ -3123,8 +3133,13 @@
|
|||
"value": ","
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "tmp_eval_arg"
|
||||
"type": "ALIAS",
|
||||
"content": {
|
||||
"type": "SYMBOL",
|
||||
"name": "tmp_eval_arg"
|
||||
},
|
||||
"named": true,
|
||||
"value": "arg"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -3133,11 +3148,16 @@
|
|||
}
|
||||
},
|
||||
"tmp_eval_arg": {
|
||||
"type": "REPEAT1",
|
||||
"type": "ALIAS",
|
||||
"content": {
|
||||
"type": "PATTERN",
|
||||
"value": "[^\\s@|#\"'>;$`~\\\\,(),]"
|
||||
}
|
||||
"type": "REPEAT1",
|
||||
"content": {
|
||||
"type": "PATTERN",
|
||||
"value": "[^\\s@|#\"'>;$`~\\\\,(),]"
|
||||
}
|
||||
},
|
||||
"named": true,
|
||||
"value": "arg_identifier"
|
||||
},
|
||||
"_eq_sep_key_single": {
|
||||
"type": "CHOICE",
|
||||
|
|
|
|||
28
shlr/rizin-shell-parser/src/node-types.json
generated
28
shlr/rizin-shell-parser/src/node-types.json
generated
|
|
@ -8219,26 +8219,6 @@
|
|||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "tmp_eval_arg",
|
||||
"named": true,
|
||||
"fields": {}
|
||||
},
|
||||
{
|
||||
"type": "tmp_eval_args",
|
||||
"named": true,
|
||||
"fields": {},
|
||||
"children": {
|
||||
"multiple": true,
|
||||
"required": true,
|
||||
"types": [
|
||||
{
|
||||
"type": "tmp_eval_arg",
|
||||
"named": true
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "tmp_eval_stmt",
|
||||
"named": true,
|
||||
|
|
@ -8251,6 +8231,10 @@
|
|||
"type": "arged_stmt",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "args",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "grep_stmt",
|
||||
"named": true
|
||||
|
|
@ -8391,10 +8375,6 @@
|
|||
"type": "tmp_blksz_stmt",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "tmp_eval_args",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "tmp_eval_stmt",
|
||||
"named": true
|
||||
|
|
|
|||
19256
shlr/rizin-shell-parser/src/parser.c
generated
19256
shlr/rizin-shell-parser/src/parser.c
generated
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue