From 7b003599b31c2cc0324c468d9ae9adc16b970ba8 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Thu, 24 May 2018 15:00:48 -0700 Subject: [PATCH] Allow subshells in negated commands Fixes #13 --- grammar.js | 3 ++- script/known-failures.txt | 2 -- src/grammar.json | 4 ++++ src/parser.c | 12 ++++++++++++ 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/grammar.js b/grammar.js index bd685e3..ec9e809 100644 --- a/grammar.js +++ b/grammar.js @@ -197,7 +197,8 @@ module.exports = grammar({ '!', choice( $.command, - $.test_command + $.test_command, + $.subshell ) ), diff --git a/script/known-failures.txt b/script/known-failures.txt index 545fd3e..754a1f9 100644 --- a/script/known-failures.txt +++ b/script/known-failures.txt @@ -1,6 +1,5 @@ examples/bash-it/plugins/available/git.plugin.bash examples/bash-it/plugins/available/extract.plugin.bash -examples/bash-it/plugins/available/sshagent.plugin.bash examples/bash-it/plugins/available/go.plugin.bash examples/bash-it/install.sh examples/bash-it/completion/available/go.completion.bash @@ -31,7 +30,6 @@ examples/bash-it/lib/search.bash examples/bash-it/test_lib/bats-support/src/lang.bash examples/bash-it/test_lib/bats-support/src/output.bash examples/bash-it/test_lib/bats-assert/src/assert.bash -examples/bash-it/test_lib/bats-file/src/temp.bash examples/bash-it/themes/hawaii50/hawaii50.theme.bash examples/bash-it/themes/dulcie/dulcie.theme.bash examples/bash-it/themes/colors.theme.bash diff --git a/src/grammar.json b/src/grammar.json index 0db8b19..7ba127b 100644 --- a/src/grammar.json +++ b/src/grammar.json @@ -705,6 +705,10 @@ { "type": "SYMBOL", "name": "test_command" + }, + { + "type": "SYMBOL", + "name": "subshell" } ] } diff --git a/src/parser.c b/src/parser.c index a9b4018..b8ea5cf 100644 --- a/src/parser.c +++ b/src/parser.c @@ -3732,6 +3732,8 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) { ADVANCE(140); if (lookahead == '\'') ADVANCE(14); + if (lookahead == '(') + ADVANCE(16); if (lookahead == '<') ADVANCE(141); if (lookahead == '>') @@ -11932,6 +11934,7 @@ static uint16_t ts_parse_table[STATE_COUNT][SYMBOL_COUNT] = { [sym_word] = ACTIONS(105), }, [10] = { + [sym_subshell] = STATE(70), [sym_test_command] = STATE(70), [sym_command] = STATE(70), [sym_command_name] = STATE(27), @@ -11948,6 +11951,7 @@ static uint16_t ts_parse_table[STATE_COUNT][SYMBOL_COUNT] = { [aux_sym_command_repeat1] = STATE(33), [sym_file_descriptor] = ACTIONS(5), [sym_variable_name] = ACTIONS(107), + [anon_sym_LPAREN] = ACTIONS(21), [anon_sym_LBRACK] = ACTIONS(25), [anon_sym_LBRACK_LBRACK] = ACTIONS(27), [anon_sym_LT] = ACTIONS(33), @@ -13171,6 +13175,7 @@ static uint16_t ts_parse_table[STATE_COUNT][SYMBOL_COUNT] = { [sym_word] = ACTIONS(459), }, [55] = { + [sym_subshell] = STATE(70), [sym_test_command] = STATE(70), [sym_command] = STATE(70), [sym_command_name] = STATE(64), @@ -13187,6 +13192,7 @@ static uint16_t ts_parse_table[STATE_COUNT][SYMBOL_COUNT] = { [aux_sym_command_repeat1] = STATE(68), [sym_file_descriptor] = ACTIONS(5), [sym_variable_name] = ACTIONS(107), + [anon_sym_LPAREN] = ACTIONS(21), [anon_sym_LBRACK] = ACTIONS(93), [anon_sym_LBRACK_LBRACK] = ACTIONS(95), [anon_sym_LT] = ACTIONS(33), @@ -16025,6 +16031,7 @@ static uint16_t ts_parse_table[STATE_COUNT][SYMBOL_COUNT] = { [sym_word] = ACTIONS(105), }, [149] = { + [sym_subshell] = STATE(441), [sym_test_command] = STATE(441), [sym_command] = STATE(441), [sym_command_name] = STATE(164), @@ -16041,6 +16048,7 @@ static uint16_t ts_parse_table[STATE_COUNT][SYMBOL_COUNT] = { [aux_sym_command_repeat1] = STATE(168), [sym_file_descriptor] = ACTIONS(5), [sym_variable_name] = ACTIONS(107), + [anon_sym_LPAREN] = ACTIONS(273), [anon_sym_LBRACK] = ACTIONS(277), [anon_sym_LBRACK_LBRACK] = ACTIONS(279), [anon_sym_LT] = ACTIONS(33), @@ -16738,6 +16746,7 @@ static uint16_t ts_parse_table[STATE_COUNT][SYMBOL_COUNT] = { [sym_word] = ACTIONS(905), }, [172] = { + [sym_subshell] = STATE(441), [sym_test_command] = STATE(441), [sym_command] = STATE(441), [sym_command_name] = STATE(181), @@ -16754,6 +16763,7 @@ static uint16_t ts_parse_table[STATE_COUNT][SYMBOL_COUNT] = { [aux_sym_command_repeat1] = STATE(184), [sym_file_descriptor] = ACTIONS(5), [sym_variable_name] = ACTIONS(107), + [anon_sym_LPAREN] = ACTIONS(273), [anon_sym_LBRACK] = ACTIONS(311), [anon_sym_LBRACK_LBRACK] = ACTIONS(313), [anon_sym_LT] = ACTIONS(33), @@ -54036,6 +54046,7 @@ static uint16_t ts_parse_table[STATE_COUNT][SYMBOL_COUNT] = { [sym_word] = ACTIONS(5258), }, [1920] = { + [sym_subshell] = STATE(70), [sym_test_command] = STATE(70), [sym_command] = STATE(70), [sym_command_name] = STATE(1935), @@ -54052,6 +54063,7 @@ static uint16_t ts_parse_table[STATE_COUNT][SYMBOL_COUNT] = { [aux_sym_command_repeat1] = STATE(1940), [sym_file_descriptor] = ACTIONS(5), [sym_variable_name] = ACTIONS(107), + [anon_sym_LPAREN] = ACTIONS(21), [anon_sym_LBRACK] = ACTIONS(4460), [anon_sym_LBRACK_LBRACK] = ACTIONS(4462), [anon_sym_LT] = ACTIONS(33),