diff --git a/src/scanner.c b/src/scanner.c index cf61e4b38..270ec7816 100644 --- a/src/scanner.c +++ b/src/scanner.c @@ -276,10 +276,24 @@ static bool scan(Scanner *scanner, TSLexer *lexer, const bool *valid_symbols) { lexer->lookahead == '<' || lexer->lookahead == ')' || lexer->lookahead == '(' || lexer->lookahead == ';' || lexer->lookahead == '&' || lexer->lookahead == '|' || - lexer->lookahead == '`' || (lexer->lookahead == '}' && valid_symbols[CLOSING_BRACE]) || (lexer->lookahead == ']' && valid_symbols[CLOSING_BRACKET]))) { lexer->result_symbol = CONCAT; + // This sucks + if (lexer->lookahead == '`') { + lexer->mark_end(lexer); + advance(lexer); + while (lexer->lookahead != '`' && !lexer->eof(lexer)) { + advance(lexer); + } + if (lexer->eof(lexer)) { + return false; + } + if (lexer->lookahead == '`') { + advance(lexer); + } + return iswspace(lexer->lookahead) || lexer->eof(lexer); + } return true; } } diff --git a/test/corpus/literals.txt b/test/corpus/literals.txt index a05bc083b..c95c113b9 100644 --- a/test/corpus/literals.txt +++ b/test/corpus/literals.txt @@ -390,6 +390,10 @@ echo `echo hi; echo there` echo $(echo $(echo hi)) echo $(< some-file) +# both of these are concatenations! +echo `echo otherword`word +echo word`echo otherword` + -------------------------------------------------------------------------------- (program @@ -430,7 +434,28 @@ echo $(< some-file) (word)) (command_substitution (file_redirect - (word))))) + (word)))) + (comment) + (command + (command_name + (word)) + (concatenation + (command_substitution + (command + (command_name + (word)) + (word))) + (word))) + (command + (command_name + (word)) + (concatenation + (word) + (command_substitution + (command + (command_name + (word)) + (word)))))) ================================================================================ Process substitutions