Implement length tool

This commit is contained in:
Jeff 2023-10-17 12:42:44 -04:00
parent cf22950b7e
commit 9ec43a9841
4 changed files with 133 additions and 130 deletions

View File

@ -203,7 +203,7 @@ module.exports = grammar({
'random_string',
'random_integer',
'count',
'length',
'sort',
'transform',
'filter',

View File

@ -816,7 +816,7 @@
},
{
"type": "STRING",
"value": "count"
"value": "length"
},
{
"type": "STRING",

View File

@ -580,10 +580,6 @@
"type": "bash",
"named": false
},
{
"type": "count",
"named": false
},
{
"type": "else",
"named": false
@ -656,6 +652,10 @@
"type": "into",
"named": false
},
{
"type": "length",
"named": false
},
{
"type": "output",
"named": false

View File

@ -70,7 +70,7 @@ enum {
anon_sym_random_float = 51,
anon_sym_random_string = 52,
anon_sym_random_integer = 53,
anon_sym_count = 54,
anon_sym_length = 54,
anon_sym_sort = 55,
anon_sym_transform = 56,
anon_sym_filter = 57,
@ -178,7 +178,7 @@ static const char * const ts_symbol_names[] = {
[anon_sym_random_float] = "random_float",
[anon_sym_random_string] = "random_string",
[anon_sym_random_integer] = "random_integer",
[anon_sym_count] = "count",
[anon_sym_length] = "length",
[anon_sym_sort] = "sort",
[anon_sym_transform] = "transform",
[anon_sym_filter] = "filter",
@ -286,7 +286,7 @@ static const TSSymbol ts_symbol_map[] = {
[anon_sym_random_float] = anon_sym_random_float,
[anon_sym_random_string] = anon_sym_random_string,
[anon_sym_random_integer] = anon_sym_random_integer,
[anon_sym_count] = anon_sym_count,
[anon_sym_length] = anon_sym_length,
[anon_sym_sort] = anon_sym_sort,
[anon_sym_transform] = anon_sym_transform,
[anon_sym_filter] = anon_sym_filter,
@ -556,7 +556,7 @@ static const TSSymbolMetadata ts_symbol_metadata[] = {
.visible = true,
.named = false,
},
[anon_sym_count] = {
[anon_sym_length] = {
.visible = true,
.named = false,
},
@ -1375,10 +1375,10 @@ static bool ts_lex_keywords(TSLexer *lexer, TSStateId state) {
case 0:
if (lookahead == 'a') ADVANCE(1);
if (lookahead == 'b') ADVANCE(2);
if (lookahead == 'c') ADVANCE(3);
if (lookahead == 'f') ADVANCE(4);
if (lookahead == 'h') ADVANCE(5);
if (lookahead == 'i') ADVANCE(6);
if (lookahead == 'f') ADVANCE(3);
if (lookahead == 'h') ADVANCE(4);
if (lookahead == 'i') ADVANCE(5);
if (lookahead == 'l') ADVANCE(6);
if (lookahead == 'o') ADVANCE(7);
if (lookahead == 'r') ADVANCE(8);
if (lookahead == 's') ADVANCE(9);
@ -1397,21 +1397,21 @@ static bool ts_lex_keywords(TSLexer *lexer, TSStateId state) {
if (lookahead == 'a') ADVANCE(14);
END_STATE();
case 3:
if (lookahead == 'o') ADVANCE(15);
if (lookahead == 'a') ADVANCE(15);
if (lookahead == 'i') ADVANCE(16);
if (lookahead == 'o') ADVANCE(17);
if (lookahead == 'r') ADVANCE(18);
if (lookahead == 'u') ADVANCE(19);
END_STATE();
case 4:
if (lookahead == 'a') ADVANCE(16);
if (lookahead == 'i') ADVANCE(17);
if (lookahead == 'o') ADVANCE(18);
if (lookahead == 'r') ADVANCE(19);
if (lookahead == 'u') ADVANCE(20);
if (lookahead == 'e') ADVANCE(20);
END_STATE();
case 5:
if (lookahead == 'e') ADVANCE(21);
if (lookahead == 'f') ADVANCE(21);
if (lookahead == 'n') ADVANCE(22);
END_STATE();
case 6:
if (lookahead == 'f') ADVANCE(22);
if (lookahead == 'n') ADVANCE(23);
if (lookahead == 'e') ADVANCE(23);
END_STATE();
case 7:
if (lookahead == 'u') ADVANCE(24);
@ -1445,34 +1445,34 @@ static bool ts_lex_keywords(TSLexer *lexer, TSStateId state) {
if (lookahead == 's') ADVANCE(38);
END_STATE();
case 15:
if (lookahead == 'u') ADVANCE(39);
if (lookahead == 'l') ADVANCE(39);
END_STATE();
case 16:
if (lookahead == 'l') ADVANCE(40);
if (lookahead == 's') ADVANCE(41);
END_STATE();
case 17:
if (lookahead == 'l') ADVANCE(41);
if (lookahead == 's') ADVANCE(42);
if (lookahead == 'r') ADVANCE(42);
END_STATE();
case 18:
if (lookahead == 'r') ADVANCE(43);
if (lookahead == 'o') ADVANCE(43);
END_STATE();
case 19:
if (lookahead == 'o') ADVANCE(44);
if (lookahead == 'n') ADVANCE(44);
END_STATE();
case 20:
if (lookahead == 'n') ADVANCE(45);
if (lookahead == 'l') ADVANCE(45);
END_STATE();
case 21:
if (lookahead == 'l') ADVANCE(46);
END_STATE();
case 22:
ACCEPT_TOKEN(anon_sym_if);
END_STATE();
case 23:
case 22:
ACCEPT_TOKEN(anon_sym_in);
if (lookahead == 's') ADVANCE(47);
if (lookahead == 't') ADVANCE(48);
if (lookahead == 's') ADVANCE(46);
if (lookahead == 't') ADVANCE(47);
END_STATE();
case 23:
if (lookahead == 'n') ADVANCE(48);
END_STATE();
case 24:
if (lookahead == 't') ADVANCE(49);
@ -1523,34 +1523,34 @@ static bool ts_lex_keywords(TSLexer *lexer, TSStateId state) {
if (lookahead == 'h') ADVANCE(65);
END_STATE();
case 39:
if (lookahead == 'n') ADVANCE(66);
if (lookahead == 's') ADVANCE(66);
END_STATE();
case 40:
if (lookahead == 's') ADVANCE(67);
if (lookahead == 't') ADVANCE(67);
END_STATE();
case 41:
if (lookahead == 't') ADVANCE(68);
if (lookahead == 'h') ADVANCE(68);
END_STATE();
case 42:
if (lookahead == 'h') ADVANCE(69);
END_STATE();
case 43:
ACCEPT_TOKEN(anon_sym_for);
END_STATE();
case 43:
if (lookahead == 'm') ADVANCE(69);
END_STATE();
case 44:
if (lookahead == 'm') ADVANCE(70);
if (lookahead == 'c') ADVANCE(70);
END_STATE();
case 45:
if (lookahead == 'c') ADVANCE(71);
if (lookahead == 'p') ADVANCE(71);
END_STATE();
case 46:
if (lookahead == 'p') ADVANCE(72);
if (lookahead == 'e') ADVANCE(72);
END_STATE();
case 47:
if (lookahead == 'e') ADVANCE(73);
if (lookahead == 'o') ADVANCE(73);
END_STATE();
case 48:
if (lookahead == 'o') ADVANCE(74);
if (lookahead == 'g') ADVANCE(74);
END_STATE();
case 49:
if (lookahead == 'p') ADVANCE(75);
@ -1605,32 +1605,32 @@ static bool ts_lex_keywords(TSLexer *lexer, TSStateId state) {
ACCEPT_TOKEN(anon_sym_bash);
END_STATE();
case 66:
if (lookahead == 't') ADVANCE(90);
if (lookahead == 'e') ADVANCE(90);
END_STATE();
case 67:
if (lookahead == 'e') ADVANCE(91);
END_STATE();
case 68:
if (lookahead == 'e') ADVANCE(92);
END_STATE();
case 69:
ACCEPT_TOKEN(anon_sym_fish);
END_STATE();
case 70:
case 69:
ACCEPT_TOKEN(anon_sym_from);
if (lookahead == '_') ADVANCE(93);
if (lookahead == '_') ADVANCE(92);
END_STATE();
case 70:
if (lookahead == 't') ADVANCE(93);
END_STATE();
case 71:
if (lookahead == 't') ADVANCE(94);
END_STATE();
case 72:
ACCEPT_TOKEN(anon_sym_help);
END_STATE();
case 72:
if (lookahead == 'r') ADVANCE(94);
END_STATE();
case 73:
if (lookahead == 'r') ADVANCE(95);
ACCEPT_TOKEN(anon_sym_into);
END_STATE();
case 74:
ACCEPT_TOKEN(anon_sym_into);
if (lookahead == 't') ADVANCE(95);
END_STATE();
case 75:
if (lookahead == 'u') ADVANCE(96);
@ -1678,44 +1678,44 @@ static bool ts_lex_keywords(TSLexer *lexer, TSStateId state) {
ACCEPT_TOKEN(anon_sym_async);
END_STATE();
case 90:
ACCEPT_TOKEN(anon_sym_count);
END_STATE();
case 91:
ACCEPT_TOKEN(anon_sym_false);
END_STATE();
case 92:
case 91:
if (lookahead == 'r') ADVANCE(107);
END_STATE();
case 93:
case 92:
if (lookahead == 'c') ADVANCE(108);
if (lookahead == 'j') ADVANCE(109);
END_STATE();
case 94:
case 93:
if (lookahead == 'i') ADVANCE(110);
END_STATE();
case 95:
case 94:
if (lookahead == 't') ADVANCE(111);
END_STATE();
case 95:
if (lookahead == 'h') ADVANCE(112);
END_STATE();
case 96:
if (lookahead == 't') ADVANCE(112);
if (lookahead == 't') ADVANCE(113);
END_STATE();
case 97:
if (lookahead == 'm') ADVANCE(113);
if (lookahead == 'm') ADVANCE(114);
END_STATE();
case 98:
if (lookahead == 't') ADVANCE(114);
if (lookahead == 't') ADVANCE(115);
END_STATE();
case 99:
ACCEPT_TOKEN(anon_sym_table);
END_STATE();
case 100:
if (lookahead == 'v') ADVANCE(115);
if (lookahead == 'v') ADVANCE(116);
END_STATE();
case 101:
if (lookahead == 'o') ADVANCE(116);
if (lookahead == 'o') ADVANCE(117);
END_STATE();
case 102:
if (lookahead == 'f') ADVANCE(117);
if (lookahead == 'f') ADVANCE(118);
END_STATE();
case 103:
ACCEPT_TOKEN(anon_sym_where);
@ -1728,172 +1728,175 @@ static bool ts_lex_keywords(TSLexer *lexer, TSStateId state) {
END_STATE();
case 106:
ACCEPT_TOKEN(anon_sym_assert);
if (lookahead == '_') ADVANCE(118);
if (lookahead == '_') ADVANCE(119);
END_STATE();
case 107:
ACCEPT_TOKEN(anon_sym_filter);
END_STATE();
case 108:
if (lookahead == 's') ADVANCE(119);
END_STATE();
case 109:
if (lookahead == 's') ADVANCE(120);
END_STATE();
case 109:
if (lookahead == 's') ADVANCE(121);
END_STATE();
case 110:
if (lookahead == 'o') ADVANCE(121);
if (lookahead == 'o') ADVANCE(122);
END_STATE();
case 111:
ACCEPT_TOKEN(anon_sym_insert);
END_STATE();
case 112:
ACCEPT_TOKEN(anon_sym_output);
ACCEPT_TOKEN(anon_sym_length);
END_STATE();
case 113:
ACCEPT_TOKEN(anon_sym_random);
if (lookahead == '_') ADVANCE(122);
ACCEPT_TOKEN(anon_sym_output);
END_STATE();
case 114:
ACCEPT_TOKEN(anon_sym_select);
ACCEPT_TOKEN(anon_sym_random);
if (lookahead == '_') ADVANCE(123);
END_STATE();
case 115:
ACCEPT_TOKEN(anon_sym_to_csv);
ACCEPT_TOKEN(anon_sym_select);
END_STATE();
case 116:
if (lookahead == 'n') ADVANCE(123);
ACCEPT_TOKEN(anon_sym_to_csv);
END_STATE();
case 117:
if (lookahead == 'o') ADVANCE(124);
if (lookahead == 'n') ADVANCE(124);
END_STATE();
case 118:
if (lookahead == 'e') ADVANCE(125);
if (lookahead == 'o') ADVANCE(125);
END_STATE();
case 119:
if (lookahead == 'v') ADVANCE(126);
if (lookahead == 'e') ADVANCE(126);
END_STATE();
case 120:
if (lookahead == 'o') ADVANCE(127);
if (lookahead == 'v') ADVANCE(127);
END_STATE();
case 121:
if (lookahead == 'n') ADVANCE(128);
if (lookahead == 'o') ADVANCE(128);
END_STATE();
case 122:
if (lookahead == 'b') ADVANCE(129);
if (lookahead == 'f') ADVANCE(130);
if (lookahead == 'i') ADVANCE(131);
if (lookahead == 's') ADVANCE(132);
if (lookahead == 'n') ADVANCE(129);
END_STATE();
case 123:
ACCEPT_TOKEN(anon_sym_to_json);
if (lookahead == 'b') ADVANCE(130);
if (lookahead == 'f') ADVANCE(131);
if (lookahead == 'i') ADVANCE(132);
if (lookahead == 's') ADVANCE(133);
END_STATE();
case 124:
if (lookahead == 'r') ADVANCE(133);
ACCEPT_TOKEN(anon_sym_to_json);
END_STATE();
case 125:
if (lookahead == 'q') ADVANCE(134);
if (lookahead == 'r') ADVANCE(134);
END_STATE();
case 126:
ACCEPT_TOKEN(anon_sym_from_csv);
if (lookahead == 'q') ADVANCE(135);
END_STATE();
case 127:
if (lookahead == 'n') ADVANCE(135);
ACCEPT_TOKEN(anon_sym_from_csv);
END_STATE();
case 128:
ACCEPT_TOKEN(anon_sym_function);
if (lookahead == 'n') ADVANCE(136);
END_STATE();
case 129:
if (lookahead == 'o') ADVANCE(136);
ACCEPT_TOKEN(anon_sym_function);
END_STATE();
case 130:
if (lookahead == 'l') ADVANCE(137);
if (lookahead == 'o') ADVANCE(137);
END_STATE();
case 131:
if (lookahead == 'n') ADVANCE(138);
if (lookahead == 'l') ADVANCE(138);
END_STATE();
case 132:
if (lookahead == 't') ADVANCE(139);
if (lookahead == 'n') ADVANCE(139);
END_STATE();
case 133:
if (lookahead == 'm') ADVANCE(140);
if (lookahead == 't') ADVANCE(140);
END_STATE();
case 134:
if (lookahead == 'u') ADVANCE(141);
if (lookahead == 'm') ADVANCE(141);
END_STATE();
case 135:
ACCEPT_TOKEN(anon_sym_from_json);
if (lookahead == 'u') ADVANCE(142);
END_STATE();
case 136:
if (lookahead == 'o') ADVANCE(142);
ACCEPT_TOKEN(anon_sym_from_json);
END_STATE();
case 137:
if (lookahead == 'o') ADVANCE(143);
END_STATE();
case 138:
if (lookahead == 't') ADVANCE(144);
if (lookahead == 'o') ADVANCE(144);
END_STATE();
case 139:
if (lookahead == 'r') ADVANCE(145);
if (lookahead == 't') ADVANCE(145);
END_STATE();
case 140:
ACCEPT_TOKEN(anon_sym_transform);
if (lookahead == 'r') ADVANCE(146);
END_STATE();
case 141:
if (lookahead == 'a') ADVANCE(146);
ACCEPT_TOKEN(anon_sym_transform);
END_STATE();
case 142:
if (lookahead == 'l') ADVANCE(147);
if (lookahead == 'a') ADVANCE(147);
END_STATE();
case 143:
if (lookahead == 'a') ADVANCE(148);
if (lookahead == 'l') ADVANCE(148);
END_STATE();
case 144:
if (lookahead == 'e') ADVANCE(149);
if (lookahead == 'a') ADVANCE(149);
END_STATE();
case 145:
if (lookahead == 'i') ADVANCE(150);
if (lookahead == 'e') ADVANCE(150);
END_STATE();
case 146:
if (lookahead == 'l') ADVANCE(151);
if (lookahead == 'i') ADVANCE(151);
END_STATE();
case 147:
if (lookahead == 'e') ADVANCE(152);
if (lookahead == 'l') ADVANCE(152);
END_STATE();
case 148:
if (lookahead == 't') ADVANCE(153);
if (lookahead == 'e') ADVANCE(153);
END_STATE();
case 149:
if (lookahead == 'g') ADVANCE(154);
if (lookahead == 't') ADVANCE(154);
END_STATE();
case 150:
if (lookahead == 'n') ADVANCE(155);
if (lookahead == 'g') ADVANCE(155);
END_STATE();
case 151:
ACCEPT_TOKEN(anon_sym_assert_equal);
if (lookahead == 'n') ADVANCE(156);
END_STATE();
case 152:
if (lookahead == 'a') ADVANCE(156);
ACCEPT_TOKEN(anon_sym_assert_equal);
END_STATE();
case 153:
ACCEPT_TOKEN(anon_sym_random_float);
if (lookahead == 'a') ADVANCE(157);
END_STATE();
case 154:
if (lookahead == 'e') ADVANCE(157);
ACCEPT_TOKEN(anon_sym_random_float);
END_STATE();
case 155:
if (lookahead == 'g') ADVANCE(158);
if (lookahead == 'e') ADVANCE(158);
END_STATE();
case 156:
if (lookahead == 'n') ADVANCE(159);
if (lookahead == 'g') ADVANCE(159);
END_STATE();
case 157:
if (lookahead == 'r') ADVANCE(160);
if (lookahead == 'n') ADVANCE(160);
END_STATE();
case 158:
ACCEPT_TOKEN(anon_sym_random_string);
if (lookahead == 'r') ADVANCE(161);
END_STATE();
case 159:
ACCEPT_TOKEN(anon_sym_random_boolean);
ACCEPT_TOKEN(anon_sym_random_string);
END_STATE();
case 160:
ACCEPT_TOKEN(anon_sym_random_boolean);
END_STATE();
case 161:
ACCEPT_TOKEN(anon_sym_random_integer);
END_STATE();
default:
@ -2184,7 +2187,7 @@ static const uint16_t ts_parse_table[LARGE_STATE_COUNT][SYMBOL_COUNT] = {
[anon_sym_random_float] = ACTIONS(1),
[anon_sym_random_string] = ACTIONS(1),
[anon_sym_random_integer] = ACTIONS(1),
[anon_sym_count] = ACTIONS(1),
[anon_sym_length] = ACTIONS(1),
[anon_sym_sort] = ACTIONS(1),
[anon_sym_transform] = ACTIONS(1),
[anon_sym_filter] = ACTIONS(1),
@ -2299,7 +2302,7 @@ static const uint16_t ts_small_parse_table[] = {
anon_sym_random_float,
anon_sym_random_string,
anon_sym_random_integer,
anon_sym_count,
anon_sym_length,
anon_sym_sort,
anon_sym_transform,
anon_sym_filter,
@ -2361,7 +2364,7 @@ static const uint16_t ts_small_parse_table[] = {
anon_sym_random_float,
anon_sym_random_string,
anon_sym_random_integer,
anon_sym_count,
anon_sym_length,
anon_sym_sort,
anon_sym_transform,
anon_sym_filter,
@ -2423,7 +2426,7 @@ static const uint16_t ts_small_parse_table[] = {
anon_sym_random_float,
anon_sym_random_string,
anon_sym_random_integer,
anon_sym_count,
anon_sym_length,
anon_sym_sort,
anon_sym_transform,
anon_sym_filter,