- A grammar compatible with PowerShell Core language features.
- Follow tree-sitter's convention where applicable.
- Support legacy language features, such as
workflow. - Strictly follow official grammar specification(which is unmaintained and not always correct).
- Everything is expression: anything can evaluate to a assignable value is an "expression", including flow control statement(e.g.
if,forstatement etc.) - Parsing type identifiers: identifiers in type literals like
[Dictionary`2[[System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089], [System.String, mscorlib]]]are not part of the language but specific to .NET, they are still parsed structurally.
-
LHS list of elements in the assignment expression are not limited to location values, that means
1,2 = 1,2also parses. -
Parenthesized location value list not supported, e.g.
((($foo), ($bar)), $baz) = .... -
Contextual null-coalescing expression and ternary expression not always correct.
1??2 # command, good 1 ?? 2 # binary_expression, good 1?2:3 # command, good 1 ?2:3 # conditional_expression, good $foo = 1??2 # rhs is expected to be command but parsed as binary_expression $foo = 1?2:3 # rhs is expected to be command but parsed as conditional_expression
-
using ...declared in non-top-level positions are parsed as command while it's expected to be an error.using namespace System.Text # top-level, fine if (0) { # should be error but parsed as command using namespace System.Text }
With nvim-treesitter:
vim.api.nvim_create_autocmd('User', {
pattern = 'TSUpdate',
callback = function()
require('nvim-treesitter.parsers').powershell = {
install_info = {
url = 'https://github.com/sharpchen/tree-sitter-powershell',
generate = true,
queries = 'queries/nvim-treesitter',
},
}
end,
})Then you might need to run :TSInstall powershell.
- official spec(not always reliable)
- PowerShell(source code as the only truth)