Make unquoted_argument named

This commit is contained in:
Uy Ha 2021-04-10 18:12:41 +02:00
parent 89c8485128
commit f79a9ebe9e
5 changed files with 40 additions and 26 deletions

View file

@ -56,7 +56,7 @@ message(STATUS)
(command_invocation (command_invocation
(identifier) (identifier)
(arguments (arguments
(argument) (argument (unquoted_argument))
) )
) )
) )
@ -73,9 +73,9 @@ message(STATUS Hello)
(command_invocation (command_invocation
(identifier) (identifier)
(arguments (arguments
(argument) (argument (unquoted_argument))
(seperation (space)) (seperation (space))
(argument) (argument (unquoted_argument))
) )
) )
) )

View file

@ -9,7 +9,7 @@ module.exports = grammar({
newline: $ => /\n/, newline: $ => /\n/,
identifier: $ => /[A-Za-z_][A-Za-z0-9_]*/, identifier: $ => /[A-Za-z_][A-Za-z0-9_]*/,
argument: $ => choice($._unquoted_argument), argument: $ => choice($.unquoted_argument),
seperation: $ => choice($.space, $.line_ending), seperation: $ => choice($.space, $.line_ending),
arguments: $ => seq($.argument, repeat($._seperated_arguments)), arguments: $ => seq($.argument, repeat($._seperated_arguments)),
@ -28,6 +28,6 @@ module.exports = grammar({
')' ')'
), ),
_unquoted_argument: $ => /[^ ()#\"\\]+/, unquoted_argument: $ => /[^ ()#\"\\]+/,
} }
}) })

View file

@ -29,7 +29,7 @@
"members": [ "members": [
{ {
"type": "SYMBOL", "type": "SYMBOL",
"name": "_unquoted_argument" "name": "unquoted_argument"
} }
] ]
}, },
@ -140,7 +140,7 @@
} }
] ]
}, },
"_unquoted_argument": { "unquoted_argument": {
"type": "PATTERN", "type": "PATTERN",
"value": "[^ ()#\\\"\\\\]+" "value": "[^ ()#\\\"\\\\]+"
} }

View file

@ -2,7 +2,17 @@
{ {
"type": "argument", "type": "argument",
"named": true, "named": true,
"fields": {} "fields": {},
"children": {
"multiple": false,
"required": true,
"types": [
{
"type": "unquoted_argument",
"named": true
}
]
}
}, },
{ {
"type": "arguments", "type": "arguments",
@ -118,5 +128,9 @@
{ {
"type": "space", "type": "space",
"named": true "named": true
},
{
"type": "unquoted_argument",
"named": true
} }
] ]

View file

@ -22,7 +22,7 @@ enum {
sym_identifier = 3, sym_identifier = 3,
anon_sym_LPAREN = 4, anon_sym_LPAREN = 4,
anon_sym_RPAREN = 5, anon_sym_RPAREN = 5,
sym__unquoted_argument = 6, sym_unquoted_argument = 6,
sym_source_file = 7, sym_source_file = 7,
sym_line_ending = 8, sym_line_ending = 8,
sym_argument = 9, sym_argument = 9,
@ -43,7 +43,7 @@ static const char *ts_symbol_names[] = {
[sym_identifier] = "identifier", [sym_identifier] = "identifier",
[anon_sym_LPAREN] = "(", [anon_sym_LPAREN] = "(",
[anon_sym_RPAREN] = ")", [anon_sym_RPAREN] = ")",
[sym__unquoted_argument] = "_unquoted_argument", [sym_unquoted_argument] = "unquoted_argument",
[sym_source_file] = "source_file", [sym_source_file] = "source_file",
[sym_line_ending] = "line_ending", [sym_line_ending] = "line_ending",
[sym_argument] = "argument", [sym_argument] = "argument",
@ -64,7 +64,7 @@ static TSSymbol ts_symbol_map[] = {
[sym_identifier] = sym_identifier, [sym_identifier] = sym_identifier,
[anon_sym_LPAREN] = anon_sym_LPAREN, [anon_sym_LPAREN] = anon_sym_LPAREN,
[anon_sym_RPAREN] = anon_sym_RPAREN, [anon_sym_RPAREN] = anon_sym_RPAREN,
[sym__unquoted_argument] = sym__unquoted_argument, [sym_unquoted_argument] = sym_unquoted_argument,
[sym_source_file] = sym_source_file, [sym_source_file] = sym_source_file,
[sym_line_ending] = sym_line_ending, [sym_line_ending] = sym_line_ending,
[sym_argument] = sym_argument, [sym_argument] = sym_argument,
@ -103,8 +103,8 @@ static const TSSymbolMetadata ts_symbol_metadata[] = {
.visible = true, .visible = true,
.named = false, .named = false,
}, },
[sym__unquoted_argument] = { [sym_unquoted_argument] = {
.visible = false, .visible = true,
.named = true, .named = true,
}, },
[sym_source_file] = { [sym_source_file] = {
@ -251,7 +251,7 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) {
ACCEPT_TOKEN(anon_sym_RPAREN); ACCEPT_TOKEN(anon_sym_RPAREN);
END_STATE(); END_STATE();
case 13: case 13:
ACCEPT_TOKEN(sym__unquoted_argument); ACCEPT_TOKEN(sym_unquoted_argument);
if (lookahead == '\t') ADVANCE(5); if (lookahead == '\t') ADVANCE(5);
if (lookahead == '\n') ADVANCE(8); if (lookahead == '\n') ADVANCE(8);
if (lookahead == '\r') ADVANCE(13); if (lookahead == '\r') ADVANCE(13);
@ -264,7 +264,7 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) {
lookahead != '\\') ADVANCE(14); lookahead != '\\') ADVANCE(14);
END_STATE(); END_STATE();
case 14: case 14:
ACCEPT_TOKEN(sym__unquoted_argument); ACCEPT_TOKEN(sym_unquoted_argument);
if (lookahead != 0 && if (lookahead != 0 &&
lookahead != ' ' && lookahead != ' ' &&
lookahead != '"' && lookahead != '"' &&
@ -344,7 +344,7 @@ static uint16_t ts_small_parse_table[] = {
ACTIONS(13), 1, ACTIONS(13), 1,
anon_sym_RPAREN, anon_sym_RPAREN,
ACTIONS(15), 1, ACTIONS(15), 1,
sym__unquoted_argument, sym_unquoted_argument,
STATE(8), 1, STATE(8), 1,
sym_argument, sym_argument,
STATE(17), 1, STATE(17), 1,
@ -360,7 +360,7 @@ static uint16_t ts_small_parse_table[] = {
ACTIONS(11), 1, ACTIONS(11), 1,
sym_newline, sym_newline,
ACTIONS(15), 1, ACTIONS(15), 1,
sym__unquoted_argument, sym_unquoted_argument,
ACTIONS(17), 1, ACTIONS(17), 1,
anon_sym_RPAREN, anon_sym_RPAREN,
STATE(8), 1, STATE(8), 1,
@ -378,7 +378,7 @@ static uint16_t ts_small_parse_table[] = {
ACTIONS(11), 1, ACTIONS(11), 1,
sym_newline, sym_newline,
ACTIONS(15), 1, ACTIONS(15), 1,
sym__unquoted_argument, sym_unquoted_argument,
ACTIONS(17), 1, ACTIONS(17), 1,
anon_sym_RPAREN, anon_sym_RPAREN,
STATE(8), 1, STATE(8), 1,
@ -396,7 +396,7 @@ static uint16_t ts_small_parse_table[] = {
ACTIONS(11), 1, ACTIONS(11), 1,
sym_newline, sym_newline,
ACTIONS(15), 1, ACTIONS(15), 1,
sym__unquoted_argument, sym_unquoted_argument,
ACTIONS(19), 1, ACTIONS(19), 1,
anon_sym_RPAREN, anon_sym_RPAREN,
STATE(8), 1, STATE(8), 1,
@ -414,7 +414,7 @@ static uint16_t ts_small_parse_table[] = {
ACTIONS(11), 1, ACTIONS(11), 1,
sym_newline, sym_newline,
ACTIONS(15), 1, ACTIONS(15), 1,
sym__unquoted_argument, sym_unquoted_argument,
ACTIONS(21), 1, ACTIONS(21), 1,
anon_sym_RPAREN, anon_sym_RPAREN,
STATE(8), 1, STATE(8), 1,
@ -432,7 +432,7 @@ static uint16_t ts_small_parse_table[] = {
ACTIONS(11), 1, ACTIONS(11), 1,
sym_newline, sym_newline,
ACTIONS(15), 1, ACTIONS(15), 1,
sym__unquoted_argument, sym_unquoted_argument,
ACTIONS(21), 1, ACTIONS(21), 1,
anon_sym_RPAREN, anon_sym_RPAREN,
STATE(8), 1, STATE(8), 1,
@ -476,7 +476,7 @@ static uint16_t ts_small_parse_table[] = {
aux_sym__seperated_arguments_repeat1, aux_sym__seperated_arguments_repeat1,
[198] = 5, [198] = 5,
ACTIONS(15), 1, ACTIONS(15), 1,
sym__unquoted_argument, sym_unquoted_argument,
STATE(17), 1, STATE(17), 1,
sym_line_ending, sym_line_ending,
STATE(26), 1, STATE(26), 1,
@ -512,7 +512,7 @@ static uint16_t ts_small_parse_table[] = {
sym_line_ending, sym_line_ending,
ACTIONS(43), 2, ACTIONS(43), 2,
anon_sym_RPAREN, anon_sym_RPAREN,
sym__unquoted_argument, sym_unquoted_argument,
STATE(12), 2, STATE(12), 2,
sym_seperation, sym_seperation,
aux_sym__seperated_arguments_repeat1, aux_sym__seperated_arguments_repeat1,
@ -545,7 +545,7 @@ static uint16_t ts_small_parse_table[] = {
sym_space, sym_space,
sym_newline, sym_newline,
anon_sym_RPAREN, anon_sym_RPAREN,
sym__unquoted_argument, sym_unquoted_argument,
[297] = 3, [297] = 3,
ACTIONS(57), 1, ACTIONS(57), 1,
sym_space, sym_space,
@ -559,7 +559,7 @@ static uint16_t ts_small_parse_table[] = {
sym_space, sym_space,
sym_newline, sym_newline,
anon_sym_RPAREN, anon_sym_RPAREN,
sym__unquoted_argument, sym_unquoted_argument,
[315] = 3, [315] = 3,
ACTIONS(64), 1, ACTIONS(64), 1,
sym_space, sym_space,