parent
7902804460
commit
065a4ec425
|
@ -10,3 +10,4 @@ Bash grammar for [tree-sitter](https://github.com/tree-sitter/tree-sitter).
|
|||
|
||||
* [Bash man page](http://man7.org/linux/man-pages/man1/bash.1.html#SHELL_GRAMMAR)
|
||||
* [Shell command language specification](http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html)
|
||||
* [mvdnan/sh - a shell parser in go](https://github.com/mvdan/sh)
|
||||
|
|
|
@ -22,21 +22,6 @@ git diff --word-diff=color -- file1.txt file2.txt
|
|||
(command (command_name (word)) (word))
|
||||
(command (command_name (word)) (word) (word) (word) (word) (word)))
|
||||
|
||||
===============================
|
||||
Commands with quoted arguments
|
||||
===============================
|
||||
|
||||
echo "hello $(whoami), this is $(uname)"
|
||||
echo 'hi'
|
||||
|
||||
---
|
||||
|
||||
(program
|
||||
(command (command_name (word)) (string
|
||||
(command_substitution (command (command_name (word))))
|
||||
(command_substitution (command (command_name (word))))))
|
||||
(command (command_name (word)) (raw_string)))
|
||||
|
||||
===============================
|
||||
Quoted command names
|
||||
===============================
|
||||
|
@ -94,43 +79,6 @@ VAR2= echo
|
|||
(variable_assignment (variable_name))
|
||||
(command (variable_assignment (variable_name)) (command_name (word))))
|
||||
|
||||
===================================
|
||||
Pipelines
|
||||
===================================
|
||||
|
||||
whoami | cat
|
||||
cat foo | grep -v bar
|
||||
|
||||
---
|
||||
|
||||
(program
|
||||
(pipeline
|
||||
(command (command_name (word)))
|
||||
(command (command_name (word))))
|
||||
(pipeline
|
||||
(command (command_name (word)) (word))
|
||||
(command (command_name (word)) (word) (word))))
|
||||
|
||||
===================================
|
||||
Lists
|
||||
===================================
|
||||
|
||||
a | b && c && d; d e f || e g
|
||||
|
||||
---
|
||||
|
||||
(program
|
||||
(list
|
||||
(list
|
||||
(pipeline
|
||||
(command (command_name (word)))
|
||||
(command (command_name (word))))
|
||||
(command (command_name (word))))
|
||||
(command (command_name (word))))
|
||||
(list
|
||||
(command (command_name (word)) (word) (word))
|
||||
(command (command_name (word)) (word))))
|
||||
|
||||
===============================
|
||||
File redirects
|
||||
===============================
|
||||
|
|
|
@ -26,35 +26,6 @@ echo ]]] ===
|
|||
(command (command_name (word)) (word))
|
||||
(command (command_name (word)) (word) (word)))
|
||||
|
||||
=============================
|
||||
The regex operator
|
||||
=============================
|
||||
|
||||
[[ "35d8b" =~ ^[0-9a-fA-F] ]]
|
||||
[[ $CMD =~ (^|;)update_terminal_cwd($|;) ]]
|
||||
[[ ! " ${completions[*]} " =~ " $alias_cmd " ]]
|
||||
! [[ "$a" =~ ^a|b\ *c|d$ ]]
|
||||
|
||||
---
|
||||
|
||||
(program
|
||||
(bracket_command
|
||||
(string)
|
||||
(regex))
|
||||
(bracket_command
|
||||
(simple_expansion (variable_name))
|
||||
(regex))
|
||||
(bracket_command
|
||||
(word)
|
||||
(string (expansion (subscript (variable_name) (word))))
|
||||
(string (simple_expansion (variable_name))))
|
||||
(command
|
||||
(command_name (word))
|
||||
(word)
|
||||
(string (simple_expansion (variable_name)))
|
||||
(regex)
|
||||
(word)))
|
||||
|
||||
=============================
|
||||
Simple variable expansions
|
||||
=============================
|
|
@ -1,3 +1,40 @@
|
|||
===================================
|
||||
Pipelines
|
||||
===================================
|
||||
|
||||
whoami | cat
|
||||
cat foo | grep -v bar
|
||||
|
||||
---
|
||||
|
||||
(program
|
||||
(pipeline
|
||||
(command (command_name (word)))
|
||||
(command (command_name (word))))
|
||||
(pipeline
|
||||
(command (command_name (word)) (word))
|
||||
(command (command_name (word)) (word) (word))))
|
||||
|
||||
===================================
|
||||
Lists
|
||||
===================================
|
||||
|
||||
a | b && c && d; d e f || e g
|
||||
|
||||
---
|
||||
|
||||
(program
|
||||
(list
|
||||
(list
|
||||
(pipeline
|
||||
(command (command_name (word)))
|
||||
(command (command_name (word))))
|
||||
(command (command_name (word))))
|
||||
(command (command_name (word))))
|
||||
(list
|
||||
(command (command_name (word)) (word) (word))
|
||||
(command (command_name (word)) (word))))
|
||||
|
||||
====================================
|
||||
While statements
|
||||
====================================
|
||||
|
@ -103,9 +140,9 @@ fi
|
|||
|
||||
(program
|
||||
(if_statement
|
||||
(bracket_command
|
||||
(test_command (binary_expression
|
||||
(string (command_substitution (command (command_name (word)))))
|
||||
(raw_string))
|
||||
(raw_string)))
|
||||
(command (command_name (word)) (word))))
|
||||
|
||||
====================================
|
||||
|
@ -146,6 +183,60 @@ esac
|
|||
(case_item (concatenation (word) (word))
|
||||
(command (command_name (word)) (simple_expansion (special_variable_name))))))
|
||||
|
||||
=============================
|
||||
Test commands
|
||||
=============================
|
||||
|
||||
if [[ "$lsb_dist" != 'Ubuntu' || $(ver_to_int "$lsb_release") < $(ver_to_int '14.04') ]]; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
---
|
||||
|
||||
(program
|
||||
(if_statement
|
||||
(test_command (binary_expression
|
||||
(binary_expression
|
||||
(binary_expression
|
||||
(string (simple_expansion (variable_name)))
|
||||
(raw_string))
|
||||
(command_substitution (command
|
||||
(command_name (word))
|
||||
(string (simple_expansion (variable_name))))))
|
||||
(command_substitution (command (command_name (word)) (raw_string)))))
|
||||
(command (command_name (word)) (word))))
|
||||
|
||||
=============================
|
||||
Test commands with regexes
|
||||
=============================
|
||||
|
||||
[[ "35d8b" =~ ^[0-9a-fA-F] ]]
|
||||
[[ $CMD =~ (^|;)update_terminal_cwd($|;) ]]
|
||||
[[ ! " ${completions[*]} " =~ " $alias_cmd " ]]
|
||||
! [[ "$a" =~ ^a|b\ *c|d$ ]]
|
||||
|
||||
---
|
||||
|
||||
(program
|
||||
(test_command
|
||||
(binary_expression
|
||||
(string)
|
||||
(regex)))
|
||||
(test_command
|
||||
(binary_expression
|
||||
(simple_expansion (variable_name))
|
||||
(regex)))
|
||||
(test_command
|
||||
(unary_expression
|
||||
(binary_expression
|
||||
(string (expansion (subscript (variable_name) (word))))
|
||||
(string (simple_expansion (variable_name))))))
|
||||
(negated_command
|
||||
(test_command
|
||||
(binary_expression
|
||||
(string (simple_expansion (variable_name)))
|
||||
(regex)))))
|
||||
|
||||
===============================
|
||||
Subshells
|
||||
===============================
|
||||
|
|
153
grammar.js
153
grammar.js
|
@ -17,7 +17,7 @@ module.exports = grammar({
|
|||
inline: $ => [
|
||||
$._statement,
|
||||
$._terminator,
|
||||
$._expression,
|
||||
$._literal,
|
||||
$._primary_expression,
|
||||
$._simple_variable_name,
|
||||
$._special_variable_name,
|
||||
|
@ -58,7 +58,8 @@ module.exports = grammar({
|
|||
$.command,
|
||||
$.declaration_command,
|
||||
$.unset_command,
|
||||
$.bracket_command,
|
||||
$.test_command,
|
||||
$.negated_command,
|
||||
$.for_statement,
|
||||
$.while_statement,
|
||||
$.if_statement,
|
||||
|
@ -74,7 +75,7 @@ module.exports = grammar({
|
|||
$._simple_variable_name,
|
||||
optional(seq(
|
||||
'in',
|
||||
repeat1($._expression)
|
||||
repeat1($._literal)
|
||||
)),
|
||||
$._terminator,
|
||||
$.do_group
|
||||
|
@ -122,7 +123,7 @@ module.exports = grammar({
|
|||
|
||||
case_statement: $ => seq(
|
||||
'case',
|
||||
$._expression,
|
||||
$._literal,
|
||||
optional($._terminator),
|
||||
'in',
|
||||
$._terminator,
|
||||
|
@ -134,8 +135,8 @@ module.exports = grammar({
|
|||
),
|
||||
|
||||
case_item: $ => seq(
|
||||
$._expression,
|
||||
repeat(seq('|', $._expression)),
|
||||
$._literal,
|
||||
repeat(seq('|', $._literal)),
|
||||
')',
|
||||
optional(seq(
|
||||
repeat($._terminated_statement),
|
||||
|
@ -145,8 +146,8 @@ module.exports = grammar({
|
|||
),
|
||||
|
||||
last_case_item: $ => seq(
|
||||
$._expression,
|
||||
repeat(seq('|', $._expression)),
|
||||
$._literal,
|
||||
repeat(seq('|', $._literal)),
|
||||
')',
|
||||
optional(seq(
|
||||
repeat($._terminated_statement),
|
||||
|
@ -192,6 +193,43 @@ module.exports = grammar({
|
|||
|
||||
// Commands
|
||||
|
||||
negated_command: $ => seq(
|
||||
'!',
|
||||
choice(
|
||||
$.command,
|
||||
$.test_command
|
||||
)
|
||||
),
|
||||
|
||||
test_command: $ => seq(
|
||||
choice(
|
||||
seq('[', $._expression, ']'),
|
||||
seq('[[', $._expression, ']]')
|
||||
),
|
||||
repeat(choice(
|
||||
$.file_redirect,
|
||||
$.heredoc_redirect,
|
||||
$.herestring_redirect
|
||||
))
|
||||
),
|
||||
|
||||
declaration_command: $ => prec.left(seq(
|
||||
choice('declare', 'typeset', 'export', 'readonly', 'local'),
|
||||
repeat(choice(
|
||||
$._literal,
|
||||
$._simple_variable_name,
|
||||
$.variable_assignment
|
||||
))
|
||||
)),
|
||||
|
||||
unset_command: $ => prec.left(seq(
|
||||
choice('unset', 'unsetenv'),
|
||||
repeat(choice(
|
||||
$._literal,
|
||||
$._simple_variable_name
|
||||
))
|
||||
)),
|
||||
|
||||
command: $ => prec.left(seq(
|
||||
repeat(choice(
|
||||
$.variable_assignment,
|
||||
|
@ -199,10 +237,10 @@ module.exports = grammar({
|
|||
)),
|
||||
$.command_name,
|
||||
repeat(choice(
|
||||
$._expression,
|
||||
$._literal,
|
||||
seq(
|
||||
choice('=~', '=='),
|
||||
choice($.regex, $._expression)
|
||||
choice($.regex, $._literal)
|
||||
)
|
||||
)),
|
||||
repeat(choice(
|
||||
|
@ -213,62 +251,19 @@ module.exports = grammar({
|
|||
optional($.heredoc_body)
|
||||
)),
|
||||
|
||||
command_name: $ => $._expression,
|
||||
|
||||
bracket_command: $ => {
|
||||
const args = repeat1(choice(
|
||||
$._expression,
|
||||
seq(
|
||||
choice('=~', '=='),
|
||||
choice($.regex, $._expression)
|
||||
)
|
||||
))
|
||||
|
||||
return seq(
|
||||
choice(
|
||||
seq('[', args, ']'),
|
||||
seq('[[', args, ']]')
|
||||
),
|
||||
repeat(choice(
|
||||
$.file_redirect,
|
||||
$.heredoc_redirect,
|
||||
$.herestring_redirect
|
||||
))
|
||||
)
|
||||
},
|
||||
command_name: $ => $._literal,
|
||||
|
||||
variable_assignment: $ => seq(
|
||||
choice(
|
||||
$.variable_name,
|
||||
$.subscript
|
||||
),
|
||||
$._assignment
|
||||
),
|
||||
|
||||
declaration_command: $ => prec.left(seq(
|
||||
choice('declare', 'typeset', 'export', 'readonly', 'local'),
|
||||
repeat(choice(
|
||||
$._expression,
|
||||
$._simple_variable_name,
|
||||
$.variable_assignment
|
||||
))
|
||||
)),
|
||||
|
||||
unset_command: $ => prec.left(seq(
|
||||
choice('unset', 'unsetenv'),
|
||||
repeat(choice(
|
||||
$._expression,
|
||||
$._simple_variable_name
|
||||
))
|
||||
)),
|
||||
|
||||
_assignment: $ => seq(
|
||||
choice(
|
||||
'=',
|
||||
'+='
|
||||
),
|
||||
choice(
|
||||
$._expression,
|
||||
$._literal,
|
||||
$.array,
|
||||
$._empty_value
|
||||
)
|
||||
|
@ -277,7 +272,7 @@ module.exports = grammar({
|
|||
subscript: $ => seq(
|
||||
$.variable_name,
|
||||
'[',
|
||||
$._expression,
|
||||
$._literal,
|
||||
optional($._concat),
|
||||
']',
|
||||
optional($._concat)
|
||||
|
@ -286,7 +281,7 @@ module.exports = grammar({
|
|||
file_redirect: $ => prec.left(seq(
|
||||
optional($.file_descriptor),
|
||||
choice('<', '>', '>>', '&>', '&>>', '<&', '>&'),
|
||||
$._expression
|
||||
$._literal
|
||||
)),
|
||||
|
||||
heredoc_redirect: $ => seq(
|
||||
|
@ -309,12 +304,45 @@ module.exports = grammar({
|
|||
|
||||
herestring_redirect: $ => seq(
|
||||
'<<<',
|
||||
$._expression
|
||||
$._literal
|
||||
),
|
||||
|
||||
// Expressions
|
||||
|
||||
_expression: $ => choice(
|
||||
$._literal,
|
||||
$.unary_expression,
|
||||
$.binary_expression,
|
||||
$.parenthesized_expression
|
||||
),
|
||||
|
||||
binary_expression: $ => prec.left(choice(
|
||||
seq(
|
||||
$._expression,
|
||||
choice('==', '=', '=~', '!=', '<', '>', '||', '&&', $.test_operator),
|
||||
$._expression
|
||||
),
|
||||
seq(
|
||||
$._expression,
|
||||
choice('==', '=~'),
|
||||
$.regex
|
||||
)
|
||||
)),
|
||||
|
||||
unary_expression: $ => prec.right(seq(
|
||||
choice('!', $.test_operator),
|
||||
$._expression
|
||||
)),
|
||||
|
||||
parenthesized_expression: $ => seq(
|
||||
'(',
|
||||
$._expression,
|
||||
')'
|
||||
),
|
||||
|
||||
// Literals
|
||||
|
||||
_literal: $ => choice(
|
||||
$.concatenation,
|
||||
$._primary_expression,
|
||||
alias(prec(-2, $._special_characters), $.word)
|
||||
|
@ -365,7 +393,7 @@ module.exports = grammar({
|
|||
|
||||
array: $ => seq(
|
||||
'(',
|
||||
repeat($._expression),
|
||||
repeat($._literal),
|
||||
')'
|
||||
),
|
||||
|
||||
|
@ -389,7 +417,7 @@ module.exports = grammar({
|
|||
seq(
|
||||
$.variable_name,
|
||||
'=',
|
||||
optional($._expression)
|
||||
optional($._literal)
|
||||
),
|
||||
seq(
|
||||
choice(
|
||||
|
@ -402,7 +430,7 @@ module.exports = grammar({
|
|||
alias($.regex_without_right_brace, $.regex)
|
||||
)),
|
||||
repeat(choice(
|
||||
$._expression,
|
||||
$._literal,
|
||||
':', ':?', '=', ':-', '%', '-', '#'
|
||||
))
|
||||
),
|
||||
|
@ -432,7 +460,10 @@ module.exports = grammar({
|
|||
seq('\\', noneOf('\\s'))
|
||||
))),
|
||||
|
||||
test_operator: $ => token(prec(1, seq('-', /[a-zA-Z]+/))),
|
||||
|
||||
regex: $ => /([^"\s]|\\.)([^\s]|\\.)*/,
|
||||
|
||||
regex_without_right_brace: $ => /([^"\s}]|\\.)([^\s}]|\\.)*/,
|
||||
|
||||
_terminator: $ => choice(';', ';;', '\n', '&')
|
||||
|
|
|
@ -1,24 +1,19 @@
|
|||
examples/bash-it/plugins/available/git.plugin.bash
|
||||
examples/bash-it/plugins/available/extract.plugin.bash
|
||||
examples/bash-it/plugins/available/z_autoenv.plugin.bash
|
||||
examples/bash-it/plugins/available/sshagent.plugin.bash
|
||||
examples/bash-it/plugins/available/go.plugin.bash
|
||||
examples/bash-it/install.sh
|
||||
examples/bash-it/completion/available/terraform.completion.bash
|
||||
examples/bash-it/completion/available/go.completion.bash
|
||||
examples/bash-it/completion/available/maven.completion.bash
|
||||
examples/bash-it/completion/available/svn.completion.bash
|
||||
examples/bash-it/completion/available/docker-compose.completion.bash
|
||||
examples/bash-it/completion/available/jboss7.completion.bash
|
||||
examples/bash-it/completion/available/todo.completion.bash
|
||||
examples/bash-it/completion/available/gh.completion.bash
|
||||
examples/bash-it/completion/available/bundler.completion.bash
|
||||
examples/bash-it/completion/available/gradle.completion.bash
|
||||
examples/bash-it/completion/available/drush.completion.bash
|
||||
examples/bash-it/completion/available/test_kitchen.completion.bash
|
||||
examples/bash-it/completion/available/hub.completion.bash
|
||||
examples/bash-it/completion/available/docker-machine.completion.bash
|
||||
examples/bash-it/completion/available/fabric-completion.bash
|
||||
examples/bash-it/completion/available/git.completion.bash
|
||||
examples/bash-it/completion/available/vagrant.completion.bash
|
||||
examples/bash-it/completion/available/defaults.completion.bash
|
||||
|
@ -27,7 +22,6 @@ examples/bash-it/completion/available/salt.completion.bash
|
|||
examples/bash-it/completion/available/vault.completion.bash
|
||||
examples/bash-it/completion/available/docker.completion.bash
|
||||
examples/bash-it/completion/available/tmux.completion.bash
|
||||
examples/bash-it/completion/available/projects.completion.bash
|
||||
examples/bash-it/completion/available/virsh.completion.bash
|
||||
examples/bash-it/completion/available/apm.completion.bash
|
||||
examples/bash-it/completion/available/git_flow.completion.bash
|
||||
|
@ -39,7 +33,6 @@ examples/bash-it/test_lib/bats-support/src/output.bash
|
|||
examples/bash-it/test_lib/bats-assert/src/assert.bash
|
||||
examples/bash-it/test_lib/bats-file/src/temp.bash
|
||||
examples/bash-it/themes/hawaii50/hawaii50.theme.bash
|
||||
examples/bash-it/themes/iterate/iterate.theme.bash
|
||||
examples/bash-it/themes/dulcie/dulcie.theme.bash
|
||||
examples/bash-it/themes/colors.theme.bash
|
||||
examples/bash-it/themes/rana/rana.theme.bash
|
||||
|
|
|
@ -42,7 +42,11 @@
|
|||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "bracket_command"
|
||||
"name": "test_command"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "negated_command"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
|
@ -103,7 +107,7 @@
|
|||
"type": "REPEAT1",
|
||||
"content": {
|
||||
"type": "SYMBOL",
|
||||
"name": "_expression"
|
||||
"name": "_literal"
|
||||
}
|
||||
}
|
||||
]
|
||||
|
@ -288,7 +292,7 @@
|
|||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_expression"
|
||||
"name": "_literal"
|
||||
},
|
||||
{
|
||||
"type": "CHOICE",
|
||||
|
@ -350,7 +354,7 @@
|
|||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_expression"
|
||||
"name": "_literal"
|
||||
},
|
||||
{
|
||||
"type": "REPEAT",
|
||||
|
@ -363,7 +367,7 @@
|
|||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_expression"
|
||||
"name": "_literal"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -419,7 +423,7 @@
|
|||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_expression"
|
||||
"name": "_literal"
|
||||
},
|
||||
{
|
||||
"type": "REPEAT",
|
||||
|
@ -432,7 +436,7 @@
|
|||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_expression"
|
||||
"name": "_literal"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -684,6 +688,184 @@
|
|||
]
|
||||
}
|
||||
},
|
||||
"negated_command": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "!"
|
||||
},
|
||||
{
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "command"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "test_command"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"test_command": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "["
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_expression"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "]"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "[["
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_expression"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "]]"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "REPEAT",
|
||||
"content": {
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "file_redirect"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "heredoc_redirect"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "herestring_redirect"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"declaration_command": {
|
||||
"type": "PREC_LEFT",
|
||||
"value": 0,
|
||||
"content": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "declare"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "typeset"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "export"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "readonly"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "local"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "REPEAT",
|
||||
"content": {
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_literal"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_simple_variable_name"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "variable_assignment"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"unset_command": {
|
||||
"type": "PREC_LEFT",
|
||||
"value": 0,
|
||||
"content": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "unset"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "unsetenv"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "REPEAT",
|
||||
"content": {
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_literal"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_simple_variable_name"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"command": {
|
||||
"type": "PREC_LEFT",
|
||||
"value": 0,
|
||||
|
@ -717,7 +899,7 @@
|
|||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_expression"
|
||||
"name": "_literal"
|
||||
},
|
||||
{
|
||||
"type": "SEQ",
|
||||
|
@ -744,7 +926,7 @@
|
|||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_expression"
|
||||
"name": "_literal"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -790,149 +972,7 @@
|
|||
},
|
||||
"command_name": {
|
||||
"type": "SYMBOL",
|
||||
"name": "_expression"
|
||||
},
|
||||
"bracket_command": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "["
|
||||
},
|
||||
{
|
||||
"type": "REPEAT1",
|
||||
"content": {
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_expression"
|
||||
},
|
||||
{
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "=~"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "=="
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "regex"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_expression"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "]"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "[["
|
||||
},
|
||||
{
|
||||
"type": "REPEAT1",
|
||||
"content": {
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_expression"
|
||||
},
|
||||
{
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "=~"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "=="
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "regex"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_expression"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "]]"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "REPEAT",
|
||||
"content": {
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "file_redirect"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "heredoc_redirect"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "herestring_redirect"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
"name": "_literal"
|
||||
},
|
||||
"variable_assignment": {
|
||||
"type": "SEQ",
|
||||
|
@ -950,107 +990,6 @@
|
|||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_assignment"
|
||||
}
|
||||
]
|
||||
},
|
||||
"declaration_command": {
|
||||
"type": "PREC_LEFT",
|
||||
"value": 0,
|
||||
"content": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "declare"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "typeset"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "export"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "readonly"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "local"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "REPEAT",
|
||||
"content": {
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_expression"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_simple_variable_name"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "variable_assignment"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"unset_command": {
|
||||
"type": "PREC_LEFT",
|
||||
"value": 0,
|
||||
"content": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "unset"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "unsetenv"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "REPEAT",
|
||||
"content": {
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_expression"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_simple_variable_name"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"_assignment": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
|
@ -1069,7 +1008,7 @@
|
|||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_expression"
|
||||
"name": "_literal"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
|
@ -1096,7 +1035,7 @@
|
|||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_expression"
|
||||
"name": "_literal"
|
||||
},
|
||||
{
|
||||
"type": "CHOICE",
|
||||
|
@ -1181,7 +1120,7 @@
|
|||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_expression"
|
||||
"name": "_literal"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -1259,11 +1198,164 @@
|
|||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_expression"
|
||||
"name": "_literal"
|
||||
}
|
||||
]
|
||||
},
|
||||
"_expression": {
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_literal"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "unary_expression"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "binary_expression"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "parenthesized_expression"
|
||||
}
|
||||
]
|
||||
},
|
||||
"binary_expression": {
|
||||
"type": "PREC_LEFT",
|
||||
"value": 0,
|
||||
"content": {
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_expression"
|
||||
},
|
||||
{
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "=="
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "="
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "=~"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "!="
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "<"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": ">"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "||"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "&&"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "test_operator"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_expression"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_expression"
|
||||
},
|
||||
{
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "=="
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "=~"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "regex"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"unary_expression": {
|
||||
"type": "PREC_RIGHT",
|
||||
"value": 0,
|
||||
"content": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "!"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "test_operator"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_expression"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"parenthesized_expression": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "("
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_expression"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": ")"
|
||||
}
|
||||
]
|
||||
},
|
||||
"_literal": {
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
|
@ -1501,7 +1593,7 @@
|
|||
"type": "REPEAT",
|
||||
"content": {
|
||||
"type": "SYMBOL",
|
||||
"name": "_expression"
|
||||
"name": "_literal"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -1605,7 +1697,7 @@
|
|||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_expression"
|
||||
"name": "_literal"
|
||||
},
|
||||
{
|
||||
"type": "BLANK"
|
||||
|
@ -1674,7 +1766,7 @@
|
|||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_expression"
|
||||
"name": "_literal"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
|
@ -1872,6 +1964,26 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"test_operator": {
|
||||
"type": "TOKEN",
|
||||
"content": {
|
||||
"type": "PREC",
|
||||
"value": 1,
|
||||
"content": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "-"
|
||||
},
|
||||
{
|
||||
"type": "PATTERN",
|
||||
"value": "[a-zA-Z]+"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"regex": {
|
||||
"type": "PATTERN",
|
||||
"value": "([^\"\\s]|\\\\.)([^\\s]|\\\\.)*"
|
||||
|
@ -1978,7 +2090,7 @@
|
|||
"inline": [
|
||||
"_statement",
|
||||
"_terminator",
|
||||
"_expression",
|
||||
"_literal",
|
||||
"_primary_expression",
|
||||
"_simple_variable_name",
|
||||
"_special_variable_name"
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -9,13 +9,14 @@ extern "C" {
|
|||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
typedef uint16_t TSSymbol;
|
||||
typedef uint16_t TSStateId;
|
||||
|
||||
#define ts_builtin_sym_error ((TSSymbol)-1)
|
||||
#define ts_builtin_sym_end 0
|
||||
#define TREE_SITTER_SERIALIZATION_BUFFER_SIZE 1024
|
||||
|
||||
typedef uint16_t TSSymbol;
|
||||
|
||||
typedef uint16_t TSStateId;
|
||||
|
||||
typedef struct {
|
||||
bool visible : 1;
|
||||
bool named : 1;
|
||||
|
@ -129,6 +130,7 @@ typedef struct TSLanguage {
|
|||
*/
|
||||
|
||||
#define STATE(id) id
|
||||
|
||||
#define ACTIONS(id) id
|
||||
|
||||
#define SHIFT(state_value) \
|
||||
|
|
Loading…
Reference in New Issue