
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
tree-sitter-xquery
Advanced tools
A tree-sitter grammar is built for an as-you-type experience in a text editor.
The aim is to provide fast identification of syntax tree parts that enable text highlighting, indenting, folding, scope info and more for a text editor.
The incremental tree-sitter parse should be a step above text highlighting with regular expressions, however tree-sitter should not be confused with a validating parser. Unlike a validating parser, tree-sitter will not stop on-error, but continue to parse and provide a syntax highlighting.
Visit the interactive treesitter web playground to see the XQuery tree-sitter in action.
Both Make and Yarn are required to use this repo, so you will need to install both.
Clone and cd into this repo then run make install which will use Yarn to install the tree-sitter cli.
All the work is done in the grammar.js file
The repo contains a Makefile as I use make for treesitter aliases.
The default make target is an alias for tree-sitter generate which will create tree-sitter files from the grammar
To see other make targets type make help
An identifier in XQuery is a Extended QName, aka an EQName. The aim of the XQuery highlight captures for identifiers is show their syntactic role.
my:salary(),
(: highlight 'my' as 'namespace', 'salary' as 'function.call' :)
(salary, bonus),
(: highlight 'salary' and 'bonus' as type.name_test :)
I have attempted to make highlight captures indicates syntactic context
let $salary := 1000 return $salary
(:
first '$salary' as variable.let_binding
'return' as keyword.return.flwor
next '$salary' as variable.reference
:)
Note: This list is incomplete
"[" "]" predicate in postfix expression"[" "]" predicate in axis step"[" "]" square array constructor element in prolog declarations
element in computed element constructor
element in element kind test
function in prolog declarations 'default namespace declaration' and 'function declaration'
function in inline function expression
function in any function test
item in prolog declarations 'context item declarations'
item in any item test
make parse-all The parser SHOULD NOT throw a parse error with any valid XQuery module text.Tests are run via GitHub actions
The parsing examples that are derived from the W3C xQuery recommendation are found in the 'examples/spec' folder. Other parse examples are from the qt3tests suite and are in the examples/qt3tests folder
To peek at tree-sitter highlight captures in action, I run some query examples in GitHub actions, which you might want to look at.
Follow the instructions at GitHub: nvim-treesitter to use the xquery treesitter
local parser_config = require("nvim-treesitter.parsers").get_parser_configs()
parser_config.xquery = {
install_info = {
url = "~/projects/grantmacken/tree-sitter-xquery", -- where you have cloned this project
files = {"src/parser.c"}
}
}
Contributions and suggestions in form of issues are welcome.
FAQs
XQuery tree-sitter
The npm package tree-sitter-xquery receives a total of 1 weekly downloads. As such, tree-sitter-xquery popularity was classified as not popular.
We found that tree-sitter-xquery demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.