parent
5203b504db
commit
cdbc8863cd
|
@ -90,13 +90,11 @@ cat a b > /dev/null
|
|||
---
|
||||
|
||||
(program
|
||||
(command
|
||||
(command_name (word))
|
||||
(redirected_statement
|
||||
(command (command_name (word)))
|
||||
(file_redirect (word)))
|
||||
(command
|
||||
(command_name (word))
|
||||
(word)
|
||||
(word)
|
||||
(redirected_statement
|
||||
(command (command_name (word)) (word) (word))
|
||||
(file_redirect (word)))
|
||||
(command
|
||||
(file_redirect (file_descriptor) (word))
|
||||
|
@ -117,15 +115,14 @@ JS
|
|||
---
|
||||
|
||||
(program
|
||||
(command
|
||||
(command_name (word))
|
||||
(heredoc_redirect (heredoc_start))
|
||||
(heredoc_body))
|
||||
(command
|
||||
(command_name (word))
|
||||
(word)
|
||||
(heredoc_redirect (heredoc_start))
|
||||
(heredoc_body)))
|
||||
(redirected_statement
|
||||
(command (command_name (word)))
|
||||
(heredoc_redirect (heredoc_start)))
|
||||
(heredoc_body)
|
||||
(redirected_statement
|
||||
(command (command_name (word)) (word))
|
||||
(heredoc_redirect (heredoc_start)))
|
||||
(heredoc_body))
|
||||
|
||||
===============================
|
||||
Heredocs with variables
|
||||
|
@ -140,12 +137,12 @@ exit
|
|||
---
|
||||
|
||||
(program
|
||||
(command
|
||||
(command_name (word))
|
||||
(heredoc_redirect (heredoc_start))
|
||||
(heredoc_body
|
||||
(simple_expansion (variable_name))
|
||||
(expansion (variable_name))))
|
||||
(redirected_statement
|
||||
(command (command_name (word)))
|
||||
(heredoc_redirect (heredoc_start)))
|
||||
(heredoc_body
|
||||
(simple_expansion (variable_name))
|
||||
(expansion (variable_name)))
|
||||
(command (command_name (word))))
|
||||
|
||||
=================================
|
||||
|
@ -161,13 +158,13 @@ wc -l $tmpfile
|
|||
---
|
||||
|
||||
(program
|
||||
(command
|
||||
(command_name (word))
|
||||
(heredoc_redirect (heredoc_start))
|
||||
(heredoc_body
|
||||
(simple_expansion (variable_name))
|
||||
(simple_expansion (variable_name))
|
||||
(expansion (variable_name))))
|
||||
(redirected_statement
|
||||
(command (command_name (word)))
|
||||
(heredoc_redirect (heredoc_start)))
|
||||
(heredoc_body
|
||||
(simple_expansion (variable_name))
|
||||
(simple_expansion (variable_name))
|
||||
(expansion (variable_name)))
|
||||
(command
|
||||
(command_name (word))
|
||||
(word)
|
||||
|
|
|
@ -200,9 +200,10 @@ echo abc > >(wc -c)
|
|||
(process_substitution
|
||||
(command (command_name (word)) (word))
|
||||
(command (command_name (word)) (word))))
|
||||
(command
|
||||
(command_name (word))
|
||||
(word)
|
||||
(redirected_statement
|
||||
(command
|
||||
(command_name (word))
|
||||
(word))
|
||||
(file_redirect (process_substitution
|
||||
(command (command_name (word)) (word))))))
|
||||
|
||||
|
|
|
@ -64,10 +64,11 @@ done < <(cat file)
|
|||
---
|
||||
|
||||
(program
|
||||
(while_statement
|
||||
(command (command_name (word)) (word))
|
||||
(do_group
|
||||
(command (command_name (word)) (simple_expansion (variable_name))))
|
||||
(redirected_statement
|
||||
(while_statement
|
||||
(command (command_name (word)) (word))
|
||||
(do_group
|
||||
(command (command_name (word)) (simple_expansion (variable_name)))))
|
||||
(file_redirect (process_substitution
|
||||
(command (command_name (word)) (word))))))
|
||||
|
||||
|
@ -312,9 +313,9 @@ function do_yet_another_thing {
|
|||
(function_definition
|
||||
(word)
|
||||
(compound_statement (command (command_name (word)) (word))))
|
||||
(function_definition
|
||||
(redirected_statement (function_definition
|
||||
(word)
|
||||
(compound_statement (command (command_name (word)) (word)))
|
||||
(compound_statement (command (command_name (word)) (word))))
|
||||
(file_redirect (file_descriptor) (word))))
|
||||
|
||||
=========================================
|
||||
|
@ -429,3 +430,30 @@ unsetenv -f ONE TWO
|
|||
(unset_command (variable_name))
|
||||
(unset_command (string (simple_expansion (variable_name))))
|
||||
(unset_command (word) (variable_name) (variable_name)))
|
||||
|
||||
===========================================
|
||||
Compound statements
|
||||
===========================================
|
||||
|
||||
a () {
|
||||
ls || { echo "b"; return 0; }
|
||||
echo c
|
||||
}
|
||||
|
||||
{ echo "a"
|
||||
echo "b"
|
||||
} >&2
|
||||
|
||||
---
|
||||
|
||||
(program
|
||||
(function_definition (word) (compound_statement
|
||||
(list
|
||||
(command (command_name (word)))
|
||||
(compound_statement
|
||||
(command (command_name (word)) (string))
|
||||
(command (command_name (word)) (word))))
|
||||
(command (command_name (word)) (word))))
|
||||
(redirected_statement
|
||||
(compound_statement (command (command_name (word)) (string)) (command (command_name (word)) (string)))
|
||||
(file_redirect (word))))
|
||||
|
|
39
grammar.js
39
grammar.js
|
@ -52,12 +52,14 @@ module.exports = grammar({
|
|||
|
||||
_terminated_statement: $ => seq(
|
||||
$._statement,
|
||||
optional($.heredoc_body),
|
||||
$._terminator
|
||||
),
|
||||
|
||||
// Statements
|
||||
|
||||
_statement: $ => choice(
|
||||
$.redirected_statement,
|
||||
$.variable_assignment,
|
||||
$.command,
|
||||
$.declaration_command,
|
||||
|
@ -72,15 +74,26 @@ module.exports = grammar({
|
|||
$.pipeline,
|
||||
$.list,
|
||||
$.subshell,
|
||||
$.compound_statement,
|
||||
$.function_definition
|
||||
),
|
||||
|
||||
_statements: $ => seq(
|
||||
repeat($._terminated_statement),
|
||||
$._statement,
|
||||
optional($.heredoc_body),
|
||||
optional($._terminator)
|
||||
),
|
||||
|
||||
redirected_statement: $ => prec(-1, seq(
|
||||
$._statement,
|
||||
repeat1(choice(
|
||||
$.file_redirect,
|
||||
$.heredoc_redirect,
|
||||
$.herestring_redirect
|
||||
))
|
||||
)),
|
||||
|
||||
for_statement: $ => seq(
|
||||
'for',
|
||||
$._simple_variable_name,
|
||||
|
@ -111,13 +124,7 @@ module.exports = grammar({
|
|||
while_statement: $ => seq(
|
||||
'while',
|
||||
$._terminated_statement,
|
||||
$.do_group,
|
||||
repeat(choice(
|
||||
$.file_redirect,
|
||||
$.heredoc_redirect,
|
||||
$.herestring_redirect
|
||||
)),
|
||||
optional($.heredoc_body)
|
||||
$.do_group
|
||||
),
|
||||
|
||||
do_group: $ => seq(
|
||||
|
@ -188,8 +195,7 @@ module.exports = grammar({
|
|||
seq('function', $.word, optional(seq('(', ')'))),
|
||||
seq($.word, '(', ')')
|
||||
),
|
||||
$.compound_statement,
|
||||
optional($.file_redirect)
|
||||
$.compound_statement
|
||||
),
|
||||
|
||||
compound_statement: $ => seq(
|
||||
|
@ -232,12 +238,7 @@ module.exports = grammar({
|
|||
seq('[', $._expression, ']'),
|
||||
seq('[[', $._expression, ']]'),
|
||||
seq('((', $._expression, '))')
|
||||
),
|
||||
repeat(choice(
|
||||
$.file_redirect,
|
||||
$.heredoc_redirect,
|
||||
$.herestring_redirect
|
||||
))
|
||||
)
|
||||
),
|
||||
|
||||
declaration_command: $ => prec.left(seq(
|
||||
|
@ -269,13 +270,7 @@ module.exports = grammar({
|
|||
choice('=~', '=='),
|
||||
choice($._literal, $.regex)
|
||||
)
|
||||
)),
|
||||
repeat(choice(
|
||||
$.file_redirect,
|
||||
$.heredoc_redirect,
|
||||
$.herestring_redirect
|
||||
)),
|
||||
optional($.heredoc_body)
|
||||
))
|
||||
)),
|
||||
|
||||
command_name: $ => $._literal,
|
||||
|
|
|
@ -1,28 +1,20 @@
|
|||
examples/bash-it/plugins/available/git.plugin.bash
|
||||
examples/bash-it/plugins/available/extract.plugin.bash
|
||||
examples/bash-it/plugins/available/go.plugin.bash
|
||||
examples/bash-it/install.sh
|
||||
examples/bash-it/completion/available/svn.completion.bash
|
||||
examples/bash-it/completion/available/docker-compose.completion.bash
|
||||
examples/bash-it/completion/available/gh.completion.bash
|
||||
examples/bash-it/completion/available/drush.completion.bash
|
||||
examples/bash-it/completion/available/hub.completion.bash
|
||||
examples/bash-it/completion/available/docker-machine.completion.bash
|
||||
examples/bash-it/completion/available/git.completion.bash
|
||||
examples/bash-it/completion/available/defaults.completion.bash
|
||||
examples/bash-it/completion/available/packer.completion.bash
|
||||
examples/bash-it/completion/available/docker.completion.bash
|
||||
examples/bash-it/completion/available/tmux.completion.bash
|
||||
examples/bash-it/lib/preexec.bash
|
||||
examples/bash-it/lib/composure.bash
|
||||
examples/bash-it/test_lib/bats-support/src/output.bash
|
||||
examples/bash-it/test_lib/bats-assert/src/assert.bash
|
||||
examples/bash-it/themes/hawaii50/hawaii50.theme.bash
|
||||
examples/bash-it/themes/dulcie/dulcie.theme.bash
|
||||
examples/bash-it/themes/colors.theme.bash
|
||||
examples/bash-it/themes/morris/morris.theme.bash
|
||||
examples/bash-it/themes/powerline/powerline.base.bash
|
||||
examples/bash-it/themes/base.theme.bash
|
||||
examples/bash-it/themes/brainy/brainy.theme.bash
|
||||
examples/bash-it/themes/nwinkler_random_colors/nwinkler_random_colors.theme.bash
|
||||
examples/bash-it/themes/kitsune/kitsune.theme.bash
|
||||
|
|
|
@ -21,6 +21,18 @@
|
|||
"type": "SYMBOL",
|
||||
"name": "_statement"
|
||||
},
|
||||
{
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "heredoc_body"
|
||||
},
|
||||
{
|
||||
"type": "BLANK"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_terminator"
|
||||
|
@ -30,6 +42,10 @@
|
|||
"_statement": {
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "redirected_statement"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "variable_assignment"
|
||||
|
@ -86,6 +102,10 @@
|
|||
"type": "SYMBOL",
|
||||
"name": "subshell"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "compound_statement"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "function_definition"
|
||||
|
@ -106,6 +126,18 @@
|
|||
"type": "SYMBOL",
|
||||
"name": "_statement"
|
||||
},
|
||||
{
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "heredoc_body"
|
||||
},
|
||||
{
|
||||
"type": "BLANK"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
|
@ -120,6 +152,39 @@
|
|||
}
|
||||
]
|
||||
},
|
||||
"redirected_statement": {
|
||||
"type": "PREC",
|
||||
"value": -1,
|
||||
"content": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_statement"
|
||||
},
|
||||
{
|
||||
"type": "REPEAT1",
|
||||
"content": {
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "file_redirect"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "heredoc_redirect"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "herestring_redirect"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"for_statement": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
|
@ -265,38 +330,6 @@
|
|||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "do_group"
|
||||
},
|
||||
{
|
||||
"type": "REPEAT",
|
||||
"content": {
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "file_redirect"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "heredoc_redirect"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "herestring_redirect"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "heredoc_body"
|
||||
},
|
||||
{
|
||||
"type": "BLANK"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -681,18 +714,6 @@
|
|||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "compound_statement"
|
||||
},
|
||||
{
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "file_redirect"
|
||||
},
|
||||
{
|
||||
"type": "BLANK"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -877,26 +898,6 @@
|
|||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "REPEAT",
|
||||
"content": {
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "file_redirect"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "heredoc_redirect"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "herestring_redirect"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -1060,38 +1061,6 @@
|
|||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "REPEAT",
|
||||
"content": {
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "file_redirect"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "heredoc_redirect"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "herestring_redirect"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "heredoc_body"
|
||||
},
|
||||
{
|
||||
"type": "BLANK"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue