Handle heredocs followed by pipes or redirects
Fixes atom/language-shellscript#134
This commit is contained in:
parent
da10d84aec
commit
53446e0e81
|
@ -160,9 +160,9 @@ wc -l $tmpfile
|
|||
(program
|
||||
(redirected_statement
|
||||
(command (command_name (word)))
|
||||
(heredoc_redirect (heredoc_start)))
|
||||
(heredoc_redirect (heredoc_start))
|
||||
(file_redirect (simple_expansion (variable_name))))
|
||||
(heredoc_body
|
||||
(simple_expansion (variable_name))
|
||||
(simple_expansion (variable_name))
|
||||
(expansion (variable_name)))
|
||||
(command
|
||||
|
@ -170,6 +170,24 @@ wc -l $tmpfile
|
|||
(word)
|
||||
(simple_expansion (variable_name))))
|
||||
|
||||
=================================
|
||||
Heredocs with pipes
|
||||
================================
|
||||
|
||||
one <<EOF | grep two
|
||||
three
|
||||
EOF
|
||||
|
||||
---
|
||||
|
||||
(program
|
||||
(pipeline
|
||||
(redirected_statement
|
||||
(command (command_name (word)))
|
||||
(heredoc_redirect (heredoc_start)))
|
||||
(command (command_name (word)) (word)))
|
||||
(heredoc_body))
|
||||
|
||||
======================================
|
||||
Heredocs with escaped expansions
|
||||
======================================
|
||||
|
|
|
@ -54,11 +54,11 @@ module.exports = grammar({
|
|||
_statements: $ => prec(1, seq(
|
||||
repeat(seq(
|
||||
$._statement,
|
||||
optional($.heredoc_body),
|
||||
optional(seq('\n', $.heredoc_body)),
|
||||
$._terminator
|
||||
)),
|
||||
$._statement,
|
||||
optional($.heredoc_body),
|
||||
optional(seq('\n', $.heredoc_body)),
|
||||
optional($._terminator)
|
||||
)),
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
"devDependencies": {
|
||||
"nodemon": "^1.18.3",
|
||||
"prebuild": "^7.6.1",
|
||||
"tree-sitter-cli": "^0.13.1"
|
||||
"tree-sitter-cli": "^0.14.5"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "tree-sitter generate && node-gyp build",
|
||||
|
|
|
@ -33,8 +33,17 @@
|
|||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "heredoc_body"
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "\n"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "heredoc_body"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "BLANK"
|
||||
|
@ -56,8 +65,17 @@
|
|||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "heredoc_body"
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "\n"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "heredoc_body"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "BLANK"
|
||||
|
@ -2296,4 +2314,4 @@
|
|||
"_simple_variable_name",
|
||||
"_special_variable_name"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -13,7 +13,7 @@ extern "C" {
|
|||
#define ts_builtin_sym_end 0
|
||||
#define TREE_SITTER_SERIALIZATION_BUFFER_SIZE 1024
|
||||
|
||||
#ifndef TREE_SITTER_RUNTIME_H_
|
||||
#ifndef TREE_SITTER_API_H_
|
||||
typedef uint16_t TSSymbol;
|
||||
typedef struct TSLanguage TSLanguage;
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue