Compare commits
No commits in common. "3a793b84cd5d6ba891b874c8c9c85bf13d964ce0" and "9d9325f8f91e7567b23c97e523805993354a86ca" have entirely different histories.
3a793b84cd
...
9d9325f8f9
|
@ -1,7 +1,7 @@
|
||||||
[package]
|
[package]
|
||||||
name = "tree-sitter-bash"
|
name = "tree-sitter-bash"
|
||||||
description = "bash grammar for the tree-sitter parsing library"
|
description = "bash grammar for the tree-sitter parsing library"
|
||||||
version = "0.20.0"
|
version = "0.19.0"
|
||||||
keywords = ["incremental", "parsing", "bash"]
|
keywords = ["incremental", "parsing", "bash"]
|
||||||
categories = ["parsing", "text-editors"]
|
categories = ["parsing", "text-editors"]
|
||||||
repository = "https://github.com/tree-sitter/tree-sitter-bash"
|
repository = "https://github.com/tree-sitter/tree-sitter-bash"
|
||||||
|
@ -23,7 +23,7 @@ include = [
|
||||||
path = "bindings/rust/lib.rs"
|
path = "bindings/rust/lib.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
tree-sitter = "0.20"
|
tree-sitter = "0.19"
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
cc = "1.0"
|
cc = "1.0"
|
||||||
|
|
|
@ -35,7 +35,7 @@ pub const NODE_TYPES: &'static str = include_str!("../../src/node-types.json");
|
||||||
|
|
||||||
// Uncomment these to include any queries that this grammar contains
|
// Uncomment these to include any queries that this grammar contains
|
||||||
|
|
||||||
pub const HIGHLIGHTS_QUERY: &'static str = include_str!("../../queries/highlights.scm");
|
// pub const HIGHLIGHTS_QUERY: &'static str = include_str!("../../queries/highlights.scm");
|
||||||
// pub const INJECTIONS_QUERY: &'static str = include_str!("../../queries/injections.scm");
|
// pub const INJECTIONS_QUERY: &'static str = include_str!("../../queries/injections.scm");
|
||||||
// pub const LOCALS_QUERY: &'static str = include_str!("../../queries/locals.scm");
|
// pub const LOCALS_QUERY: &'static str = include_str!("../../queries/locals.scm");
|
||||||
// pub const TAGS_QUERY: &'static str = include_str!("../../queries/tags.scm");
|
// pub const TAGS_QUERY: &'static str = include_str!("../../queries/tags.scm");
|
||||||
|
|
|
@ -355,18 +355,3 @@ echo -ne "\033k$1\033\\" > /dev/stderr
|
||||||
(redirected_statement
|
(redirected_statement
|
||||||
(command (command_name (word)) (word) (string (simple_expansion (variable_name))))
|
(command (command_name (word)) (word) (string (simple_expansion (variable_name))))
|
||||||
(file_redirect (word))))
|
(file_redirect (word))))
|
||||||
|
|
||||||
================================================================================
|
|
||||||
Words containing bare '#'
|
|
||||||
================================================================================
|
|
||||||
|
|
||||||
curl -# localhost #comment without space
|
|
||||||
nix build nixpkgs#hello -v # comment with space
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
(program
|
|
||||||
(command (command_name (word)) (word) (word))
|
|
||||||
(comment)
|
|
||||||
(command (command_name (word)) (word) (word) (word))
|
|
||||||
(comment))
|
|
||||||
|
|
|
@ -1,35 +0,0 @@
|
||||||
# See https://zsh.sourceforge.io/Doc/Release/Expansion.html#Parameter-Expansion-Flags
|
|
||||||
=============================
|
|
||||||
Parameter Expansion Flags
|
|
||||||
=============================
|
|
||||||
echo ${(v)V}
|
|
||||||
echo ${(s.:.)V}
|
|
||||||
echo ${(@)V}
|
|
||||||
echo ${()V}
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
(program
|
|
||||||
(command (command_name (word)) (expansion (expansion_flags) (variable_name)))
|
|
||||||
(command (command_name (word)) (expansion (expansion_flags) (variable_name)))
|
|
||||||
(command (command_name (word)) (expansion (expansion_flags) (variable_name)))
|
|
||||||
(command (command_name (word)) (expansion (expansion_flags) (variable_name))))
|
|
||||||
|
|
||||||
=============================
|
|
||||||
Parameter Expansion Flags Quotes
|
|
||||||
=============================
|
|
||||||
echo "${(v_sldkfj_sdklfj)V}"
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
(program
|
|
||||||
(command (command_name (word)) (string (expansion (expansion_flags) (variable_name)))))
|
|
||||||
=============================
|
|
||||||
Parameter Expansion Invalid Flags
|
|
||||||
=============================
|
|
||||||
echo "${(())V}"
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
(program
|
|
||||||
(command (command_name (word)) (string (expansion (ERROR) (expansion_flags) (ERROR (word))))))
|
|
19
grammar.js
19
grammar.js
|
@ -8,6 +8,7 @@ const SPECIAL_CHARACTERS = [
|
||||||
'|', '&', ';',
|
'|', '&', ';',
|
||||||
'\\',
|
'\\',
|
||||||
'\\s',
|
'\\s',
|
||||||
|
'#',
|
||||||
];
|
];
|
||||||
|
|
||||||
module.exports = grammar({
|
module.exports = grammar({
|
||||||
|
@ -490,12 +491,8 @@ module.exports = grammar({
|
||||||
|
|
||||||
string_expansion: $ => seq('$', choice($.string, $.raw_string)),
|
string_expansion: $ => seq('$', choice($.string, $.raw_string)),
|
||||||
|
|
||||||
// See https://zsh.sourceforge.io/Doc/Release/Expansion.html#Parameter-Expansion-Flags
|
|
||||||
expansion_flags: ($) => seq("(", repeat(/[^()]/), ")"),
|
|
||||||
|
|
||||||
expansion: $ => seq(
|
expansion: $ => seq(
|
||||||
'${',
|
'${',
|
||||||
optional($.expansion_flags),
|
|
||||||
optional(choice('#', '!')),
|
optional(choice('#', '!')),
|
||||||
optional(choice(
|
optional(choice(
|
||||||
seq(
|
seq(
|
||||||
|
@ -540,16 +537,10 @@ module.exports = grammar({
|
||||||
|
|
||||||
_special_variable_name: $ => alias(choice('*', '@', '?', '-', '$', '0', '_'), $.special_variable_name),
|
_special_variable_name: $ => alias(choice('*', '@', '?', '-', '$', '0', '_'), $.special_variable_name),
|
||||||
|
|
||||||
word: $ => token(seq(
|
word: $ => token(repeat1(choice(
|
||||||
choice(
|
noneOf(...SPECIAL_CHARACTERS),
|
||||||
noneOf('#', ...SPECIAL_CHARACTERS),
|
seq('\\', noneOf('\\s'))
|
||||||
seq('\\', noneOf('\\s'))
|
))),
|
||||||
),
|
|
||||||
repeat(choice(
|
|
||||||
noneOf(...SPECIAL_CHARACTERS),
|
|
||||||
seq('\\', noneOf('\\s'))
|
|
||||||
))
|
|
||||||
)),
|
|
||||||
|
|
||||||
test_operator: $ => token(prec(1, seq('-', /[a-zA-Z]+/))),
|
test_operator: $ => token(prec(1, seq('-', /[a-zA-Z]+/))),
|
||||||
|
|
||||||
|
|
|
@ -30,8 +30,7 @@
|
||||||
"scope": "source.bash",
|
"scope": "source.bash",
|
||||||
"file-types": [
|
"file-types": [
|
||||||
"sh",
|
"sh",
|
||||||
"bash",
|
"bash"
|
||||||
"zsh"
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
|
@ -46,7 +46,6 @@
|
||||||
">>"
|
">>"
|
||||||
"<"
|
"<"
|
||||||
"|"
|
"|"
|
||||||
(expansion_flags)
|
|
||||||
] @operator
|
] @operator
|
||||||
|
|
||||||
(
|
(
|
||||||
|
|
|
@ -433,17 +433,8 @@
|
||||||
"type": "SEQ",
|
"type": "SEQ",
|
||||||
"members": [
|
"members": [
|
||||||
{
|
{
|
||||||
"type": "CHOICE",
|
"type": "STRING",
|
||||||
"members": [
|
"value": "while"
|
||||||
{
|
|
||||||
"type": "STRING",
|
|
||||||
"value": "while"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "STRING",
|
|
||||||
"value": "until"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "FIELD",
|
"type": "FIELD",
|
||||||
|
@ -2153,26 +2144,6 @@
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"expansion_flags": {
|
|
||||||
"type": "SEQ",
|
|
||||||
"members": [
|
|
||||||
{
|
|
||||||
"type": "STRING",
|
|
||||||
"value": "("
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "REPEAT",
|
|
||||||
"content": {
|
|
||||||
"type": "PATTERN",
|
|
||||||
"value": "[^()]"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "STRING",
|
|
||||||
"value": ")"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"expansion": {
|
"expansion": {
|
||||||
"type": "SEQ",
|
"type": "SEQ",
|
||||||
"members": [
|
"members": [
|
||||||
|
@ -2180,18 +2151,6 @@
|
||||||
"type": "STRING",
|
"type": "STRING",
|
||||||
"value": "${"
|
"value": "${"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"type": "CHOICE",
|
|
||||||
"members": [
|
|
||||||
{
|
|
||||||
"type": "SYMBOL",
|
|
||||||
"name": "expansion_flags"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "BLANK"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"type": "CHOICE",
|
"type": "CHOICE",
|
||||||
"members": [
|
"members": [
|
||||||
|
@ -2502,56 +2461,29 @@
|
||||||
"word": {
|
"word": {
|
||||||
"type": "TOKEN",
|
"type": "TOKEN",
|
||||||
"content": {
|
"content": {
|
||||||
"type": "SEQ",
|
"type": "REPEAT1",
|
||||||
"members": [
|
"content": {
|
||||||
{
|
"type": "CHOICE",
|
||||||
"type": "CHOICE",
|
"members": [
|
||||||
"members": [
|
{
|
||||||
{
|
"type": "PATTERN",
|
||||||
"type": "PATTERN",
|
"value": "[^'\"<>{}\\[\\]()`$|&;\\\\\\s#]"
|
||||||
"value": "[^#'\"<>{}\\[\\]()`$|&;\\\\\\s]"
|
},
|
||||||
},
|
{
|
||||||
{
|
"type": "SEQ",
|
||||||
"type": "SEQ",
|
|
||||||
"members": [
|
|
||||||
{
|
|
||||||
"type": "STRING",
|
|
||||||
"value": "\\"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "PATTERN",
|
|
||||||
"value": "[^\\s]"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "REPEAT",
|
|
||||||
"content": {
|
|
||||||
"type": "CHOICE",
|
|
||||||
"members": [
|
"members": [
|
||||||
{
|
{
|
||||||
"type": "PATTERN",
|
"type": "STRING",
|
||||||
"value": "[^'\"<>{}\\[\\]()`$|&;\\\\\\s]"
|
"value": "\\"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "SEQ",
|
"type": "PATTERN",
|
||||||
"members": [
|
"value": "[^\\s]"
|
||||||
{
|
|
||||||
"type": "STRING",
|
|
||||||
"value": "\\"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "PATTERN",
|
|
||||||
"value": "[^\\s]"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
]
|
||||||
]
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"test_operator": {
|
"test_operator": {
|
||||||
|
|
|
@ -638,10 +638,6 @@
|
||||||
"type": "concatenation",
|
"type": "concatenation",
|
||||||
"named": true
|
"named": true
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"type": "expansion_flags",
|
|
||||||
"named": true
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"type": "regex",
|
"type": "regex",
|
||||||
"named": true
|
"named": true
|
||||||
|
@ -661,11 +657,6 @@
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"type": "expansion_flags",
|
|
||||||
"named": true,
|
|
||||||
"fields": {}
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"type": "file_redirect",
|
"type": "file_redirect",
|
||||||
"named": true,
|
"named": true,
|
||||||
|
@ -1648,10 +1639,6 @@
|
||||||
"type": "unsetenv",
|
"type": "unsetenv",
|
||||||
"named": false
|
"named": false
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"type": "until",
|
|
||||||
"named": false
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"type": "variable_name",
|
"type": "variable_name",
|
||||||
"named": true
|
"named": true
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue