Compare commits
No commits in common. "3a793b84cd5d6ba891b874c8c9c85bf13d964ce0" and "9d9325f8f91e7567b23c97e523805993354a86ca" have entirely different histories.
3a793b84cd
...
9d9325f8f9
|
@ -1,7 +1,7 @@
|
|||
[package]
|
||||
name = "tree-sitter-bash"
|
||||
description = "bash grammar for the tree-sitter parsing library"
|
||||
version = "0.20.0"
|
||||
version = "0.19.0"
|
||||
keywords = ["incremental", "parsing", "bash"]
|
||||
categories = ["parsing", "text-editors"]
|
||||
repository = "https://github.com/tree-sitter/tree-sitter-bash"
|
||||
|
@ -23,7 +23,7 @@ include = [
|
|||
path = "bindings/rust/lib.rs"
|
||||
|
||||
[dependencies]
|
||||
tree-sitter = "0.20"
|
||||
tree-sitter = "0.19"
|
||||
|
||||
[build-dependencies]
|
||||
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
|
||||
|
||||
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 LOCALS_QUERY: &'static str = include_str!("../../queries/locals.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
|
||||
(command (command_name (word)) (word) (string (simple_expansion (variable_name))))
|
||||
(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))))))
|
15
grammar.js
15
grammar.js
|
@ -8,6 +8,7 @@ const SPECIAL_CHARACTERS = [
|
|||
'|', '&', ';',
|
||||
'\\',
|
||||
'\\s',
|
||||
'#',
|
||||
];
|
||||
|
||||
module.exports = grammar({
|
||||
|
@ -490,12 +491,8 @@ module.exports = grammar({
|
|||
|
||||
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(
|
||||
'${',
|
||||
optional($.expansion_flags),
|
||||
optional(choice('#', '!')),
|
||||
optional(choice(
|
||||
seq(
|
||||
|
@ -540,16 +537,10 @@ module.exports = grammar({
|
|||
|
||||
_special_variable_name: $ => alias(choice('*', '@', '?', '-', '$', '0', '_'), $.special_variable_name),
|
||||
|
||||
word: $ => token(seq(
|
||||
choice(
|
||||
noneOf('#', ...SPECIAL_CHARACTERS),
|
||||
seq('\\', noneOf('\\s'))
|
||||
),
|
||||
repeat(choice(
|
||||
word: $ => token(repeat1(choice(
|
||||
noneOf(...SPECIAL_CHARACTERS),
|
||||
seq('\\', noneOf('\\s'))
|
||||
))
|
||||
)),
|
||||
))),
|
||||
|
||||
test_operator: $ => token(prec(1, seq('-', /[a-zA-Z]+/))),
|
||||
|
||||
|
|
|
@ -30,8 +30,7 @@
|
|||
"scope": "source.bash",
|
||||
"file-types": [
|
||||
"sh",
|
||||
"bash",
|
||||
"zsh"
|
||||
"bash"
|
||||
]
|
||||
}
|
||||
]
|
||||
|
|
|
@ -46,7 +46,6 @@
|
|||
">>"
|
||||
"<"
|
||||
"|"
|
||||
(expansion_flags)
|
||||
] @operator
|
||||
|
||||
(
|
||||
|
|
|
@ -431,20 +431,11 @@
|
|||
},
|
||||
"while_statement": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "while"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "until"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "FIELD",
|
||||
"name": "condition",
|
||||
|
@ -2153,26 +2144,6 @@
|
|||
}
|
||||
]
|
||||
},
|
||||
"expansion_flags": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "("
|
||||
},
|
||||
{
|
||||
"type": "REPEAT",
|
||||
"content": {
|
||||
"type": "PATTERN",
|
||||
"value": "[^()]"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": ")"
|
||||
}
|
||||
]
|
||||
},
|
||||
"expansion": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
|
@ -2180,18 +2151,6 @@
|
|||
"type": "STRING",
|
||||
"value": "${"
|
||||
},
|
||||
{
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "expansion_flags"
|
||||
},
|
||||
{
|
||||
"type": "BLANK"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
|
@ -2502,38 +2461,13 @@
|
|||
"word": {
|
||||
"type": "TOKEN",
|
||||
"content": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "PATTERN",
|
||||
"value": "[^#'\"<>{}\\[\\]()`$|&;\\\\\\s]"
|
||||
},
|
||||
{
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "\\"
|
||||
},
|
||||
{
|
||||
"type": "PATTERN",
|
||||
"value": "[^\\s]"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "REPEAT",
|
||||
"type": "REPEAT1",
|
||||
"content": {
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "PATTERN",
|
||||
"value": "[^'\"<>{}\\[\\]()`$|&;\\\\\\s]"
|
||||
"value": "[^'\"<>{}\\[\\]()`$|&;\\\\\\s#]"
|
||||
},
|
||||
{
|
||||
"type": "SEQ",
|
||||
|
@ -2551,8 +2485,6 @@
|
|||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"test_operator": {
|
||||
"type": "TOKEN",
|
||||
|
|
|
@ -638,10 +638,6 @@
|
|||
"type": "concatenation",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "expansion_flags",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "regex",
|
||||
"named": true
|
||||
|
@ -661,11 +657,6 @@
|
|||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "expansion_flags",
|
||||
"named": true,
|
||||
"fields": {}
|
||||
},
|
||||
{
|
||||
"type": "file_redirect",
|
||||
"named": true,
|
||||
|
@ -1648,10 +1639,6 @@
|
|||
"type": "unsetenv",
|
||||
"named": false
|
||||
},
|
||||
{
|
||||
"type": "until",
|
||||
"named": false
|
||||
},
|
||||
{
|
||||
"type": "variable_name",
|
||||
"named": true
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue