mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-01-22 08:43:01 +08:00
Migrate token_infos inside token_for_string and reformat
This commit is contained in:
parent
e1c0ab8edb
commit
cf01694def
|
@ -116,44 +116,44 @@ struct token_info_t {
|
|||
unsigned int flags;
|
||||
};
|
||||
|
||||
static const std::map<wcstring, const token_info_t> token_infos =
|
||||
{{L"", {test_unknown, 0}},
|
||||
{L"!", {test_bang, 0}},
|
||||
{L"-b", {test_filetype_b, UNARY_PRIMARY}},
|
||||
{L"-c", {test_filetype_c, UNARY_PRIMARY}},
|
||||
{L"-d", {test_filetype_d, UNARY_PRIMARY}},
|
||||
{L"-e", {test_filetype_e, UNARY_PRIMARY}},
|
||||
{L"-f", {test_filetype_f, UNARY_PRIMARY}},
|
||||
{L"-G", {test_filetype_G, UNARY_PRIMARY}},
|
||||
{L"-g", {test_filetype_g, UNARY_PRIMARY}},
|
||||
{L"-h", {test_filetype_h, UNARY_PRIMARY}},
|
||||
{L"-k", {test_filetype_k, UNARY_PRIMARY}},
|
||||
{L"-L", {test_filetype_L, UNARY_PRIMARY}},
|
||||
{L"-O", {test_filetype_O, UNARY_PRIMARY}},
|
||||
{L"-p", {test_filetype_p, UNARY_PRIMARY}},
|
||||
{L"-S", {test_filetype_S, UNARY_PRIMARY}},
|
||||
{L"-s", {test_filesize_s, UNARY_PRIMARY}},
|
||||
{L"-t", {test_filedesc_t, UNARY_PRIMARY}},
|
||||
{L"-r", {test_fileperm_r, UNARY_PRIMARY}},
|
||||
{L"-u", {test_fileperm_u, UNARY_PRIMARY}},
|
||||
{L"-w", {test_fileperm_w, UNARY_PRIMARY}},
|
||||
{L"-x", {test_fileperm_x, UNARY_PRIMARY}},
|
||||
{L"-n", {test_string_n, UNARY_PRIMARY}},
|
||||
{L"-z", {test_string_z, UNARY_PRIMARY}},
|
||||
{L"=", {test_string_equal, BINARY_PRIMARY}},
|
||||
{L"!=", {test_string_not_equal, BINARY_PRIMARY}},
|
||||
{L"-eq", {test_number_equal, BINARY_PRIMARY}},
|
||||
{L"-ne", {test_number_not_equal, BINARY_PRIMARY}},
|
||||
{L"-gt", {test_number_greater, BINARY_PRIMARY}},
|
||||
{L"-ge", {test_number_greater_equal, BINARY_PRIMARY}},
|
||||
{L"-lt", {test_number_lesser, BINARY_PRIMARY}},
|
||||
{L"-le", {test_number_lesser_equal, BINARY_PRIMARY}},
|
||||
{L"-a", {test_combine_and, 0}},
|
||||
{L"-o", {test_combine_or, 0}},
|
||||
{L"(", {test_paren_open, 0}},
|
||||
{L")", {test_paren_close, 0}}};
|
||||
|
||||
const token_info_t * const token_for_string(const wcstring &str) {
|
||||
static const std::map<wcstring, const token_info_t> token_infos = {
|
||||
{L"", {test_unknown, 0}},
|
||||
{L"!", {test_bang, 0}},
|
||||
{L"-b", {test_filetype_b, UNARY_PRIMARY}},
|
||||
{L"-c", {test_filetype_c, UNARY_PRIMARY}},
|
||||
{L"-d", {test_filetype_d, UNARY_PRIMARY}},
|
||||
{L"-e", {test_filetype_e, UNARY_PRIMARY}},
|
||||
{L"-f", {test_filetype_f, UNARY_PRIMARY}},
|
||||
{L"-G", {test_filetype_G, UNARY_PRIMARY}},
|
||||
{L"-g", {test_filetype_g, UNARY_PRIMARY}},
|
||||
{L"-h", {test_filetype_h, UNARY_PRIMARY}},
|
||||
{L"-k", {test_filetype_k, UNARY_PRIMARY}},
|
||||
{L"-L", {test_filetype_L, UNARY_PRIMARY}},
|
||||
{L"-O", {test_filetype_O, UNARY_PRIMARY}},
|
||||
{L"-p", {test_filetype_p, UNARY_PRIMARY}},
|
||||
{L"-S", {test_filetype_S, UNARY_PRIMARY}},
|
||||
{L"-s", {test_filesize_s, UNARY_PRIMARY}},
|
||||
{L"-t", {test_filedesc_t, UNARY_PRIMARY}},
|
||||
{L"-r", {test_fileperm_r, UNARY_PRIMARY}},
|
||||
{L"-u", {test_fileperm_u, UNARY_PRIMARY}},
|
||||
{L"-w", {test_fileperm_w, UNARY_PRIMARY}},
|
||||
{L"-x", {test_fileperm_x, UNARY_PRIMARY}},
|
||||
{L"-n", {test_string_n, UNARY_PRIMARY}},
|
||||
{L"-z", {test_string_z, UNARY_PRIMARY}},
|
||||
{L"=", {test_string_equal, BINARY_PRIMARY}},
|
||||
{L"!=", {test_string_not_equal, BINARY_PRIMARY}},
|
||||
{L"-eq", {test_number_equal, BINARY_PRIMARY}},
|
||||
{L"-ne", {test_number_not_equal, BINARY_PRIMARY}},
|
||||
{L"-gt", {test_number_greater, BINARY_PRIMARY}},
|
||||
{L"-ge", {test_number_greater_equal, BINARY_PRIMARY}},
|
||||
{L"-lt", {test_number_lesser, BINARY_PRIMARY}},
|
||||
{L"-le", {test_number_lesser_equal, BINARY_PRIMARY}},
|
||||
{L"-a", {test_combine_and, 0}},
|
||||
{L"-o", {test_combine_or, 0}},
|
||||
{L"(", {test_paren_open, 0}},
|
||||
{L")", {test_paren_close, 0}}};
|
||||
|
||||
auto t = token_infos.find(str);
|
||||
if (t != token_infos.end()) return &t->second;
|
||||
return &token_infos.find(L"")->second;
|
||||
|
|
Loading…
Reference in New Issue
Block a user