Add support for case fallthrough (#85)
Fixes https://github.com/tree-sitter/tree-sitter-bash/issues/40
This commit is contained in:
parent
f226a4b55a
commit
8ece09ca4c
|
@ -217,7 +217,11 @@ case "opt" in
|
|||
;;
|
||||
|
||||
b)
|
||||
echo b;;
|
||||
echo b
|
||||
;&
|
||||
|
||||
c)
|
||||
echo c;;
|
||||
esac
|
||||
|
||||
case "$Z" in
|
||||
|
@ -234,6 +238,8 @@ esac
|
|||
|
||||
(program
|
||||
(case_statement (string)
|
||||
(case_item (word)
|
||||
(command (command_name (word)) (word)))
|
||||
(case_item (word)
|
||||
(command (command_name (word)) (word)))
|
||||
(case_item (word)
|
||||
|
|
|
@ -190,7 +190,10 @@ module.exports = grammar({
|
|||
repeat(seq('|', field('value', $._literal))),
|
||||
')',
|
||||
optional($._statements),
|
||||
prec(1, ';;')
|
||||
prec(1, choice(
|
||||
field('termination', ';;'),
|
||||
field('fallthrough', choice(';&', ';;&'))
|
||||
))
|
||||
),
|
||||
|
||||
last_case_item: $ => seq(
|
||||
|
|
|
@ -696,10 +696,36 @@
|
|||
{
|
||||
"type": "PREC",
|
||||
"value": 1,
|
||||
"content": {
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "FIELD",
|
||||
"name": "termination",
|
||||
"content": {
|
||||
"type": "STRING",
|
||||
"value": ";;"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "FIELD",
|
||||
"name": "fallthrough",
|
||||
"content": {
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": ";&"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": ";;&"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
|
@ -322,6 +322,30 @@
|
|||
"type": "case_item",
|
||||
"named": true,
|
||||
"fields": {
|
||||
"fallthrough": {
|
||||
"multiple": false,
|
||||
"required": false,
|
||||
"types": [
|
||||
{
|
||||
"type": ";&",
|
||||
"named": false
|
||||
},
|
||||
{
|
||||
"type": ";;&",
|
||||
"named": false
|
||||
}
|
||||
]
|
||||
},
|
||||
"termination": {
|
||||
"multiple": false,
|
||||
"required": false,
|
||||
"types": [
|
||||
{
|
||||
"type": ";;",
|
||||
"named": false
|
||||
}
|
||||
]
|
||||
},
|
||||
"value": {
|
||||
"multiple": true,
|
||||
"required": true,
|
||||
|
@ -1403,10 +1427,18 @@
|
|||
"type": ";",
|
||||
"named": false
|
||||
},
|
||||
{
|
||||
"type": ";&",
|
||||
"named": false
|
||||
},
|
||||
{
|
||||
"type": ";;",
|
||||
"named": false
|
||||
},
|
||||
{
|
||||
"type": ";;&",
|
||||
"named": false
|
||||
},
|
||||
{
|
||||
"type": "<",
|
||||
"named": false
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue