tree-sitter-bash/src/grammar.json

225 lines
4.5 KiB
JSON
Raw Normal View History

2017-07-14 19:28:54 +00:00
{
"name": "bash",
"rules": {
"program": {
"type": "REPEAT",
"content": {
"type": "SYMBOL",
"name": "command"
}
},
"command": {
"type": "SEQ",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "simple_command"
},
{
"type": "SYMBOL",
"name": "pipeline"
},
{
"type": "SYMBOL",
"name": "list"
}
]
},
{
"type": "SYMBOL",
"name": "control_operator"
}
]
},
"simple_command": {
"type": "SEQ",
"members": [
{
"type": "REPEAT",
"content": {
"type": "SYMBOL",
"name": "environment_variable_assignment"
}
},
{
"type": "RENAME",
"content": {
"type": "SYMBOL",
"name": "leading_word"
},
"value": "command_name"
},
{
"type": "CHOICE",
"members": [
{
"type": "SEQ",
"members": [
{
"type": "PATTERN",
"value": "\\s+"
},
{
"type": "REPEAT",
"content": {
"type": "RENAME",
"content": {
"type": "SYMBOL",
"name": "word"
},
"value": "argument"
}
}
]
},
{
"type": "BLANK"
}
]
}
]
},
"pipeline": {
"type": "PREC_LEFT",
"value": 0,
"content": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "simple_command"
},
{
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": "|"
},
{
"type": "STRING",
"value": "|&"
}
]
},
{
"type": "SYMBOL",
"name": "simple_command"
}
]
}
},
"list": {
"type": "PREC_LEFT",
"value": 0,
"content": {
"type": "SEQ",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "simple_command"
},
{
"type": "SYMBOL",
"name": "list"
},
{
"type": "SYMBOL",
"name": "pipeline"
}
]
},
{
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": "&&"
},
{
"type": "STRING",
"value": ";"
}
]
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "simple_command"
},
{
"type": "SYMBOL",
"name": "pipeline"
}
]
}
]
}
},
"environment_variable_assignment": {
"type": "SEQ",
"members": [
{
"type": "RENAME",
"content": {
"type": "SYMBOL",
"name": "leading_word"
},
"value": "variable_name"
},
{
"type": "STRING",
"value": "="
},
{
"type": "RENAME",
"content": {
"type": "SYMBOL",
"name": "word"
},
"value": "argument"
}
]
},
"leading_word": {
"type": "PATTERN",
"value": "[^\\s=|;]+"
},
"word": {
"type": "PATTERN",
"value": "[^\\s]+"
},
"control_operator": {
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": "\n"
},
{
"type": "STRING",
"value": ";;"
}
]
}
},
"extras": [
{
"type": "PATTERN",
"value": "\\s"
}
],
"conflicts": [],
"externals": [],
"inline": [
"control_operator"
]
}