A tree-sitter grammar for Pkl.
# install dependencies
$ npm install
# build parser
$ npm run build
# parse some code
$ ./node_modules/.bin/tree-sitter parse test.pkl
Tree sitter comes with its own test framework. Files in test/corpus/
describe one test each. All tests in test/corpus/
are performed by the
command
$ tree-sitter test
If the grammar has changed, run tree-sitter test --update
to update the corpus.
The tests within test/corpus/snippetTests are generated from the core Pkl parser, and are not updated by tree-sitter test --update
.
These tests are generated by running ./gradlew createLanguageSnippetsCorpus
.
This task grabs all language snippet tests, and renders them into a format that can be processed by tree-sitter.
To fix any rendering issues, change SExprRenderer.
Upgrading tree-sitter involves upgrading the NPM package.
- Run
npm update tree-sitter
to install the newer version of tree-sitter. - Commit to main, and push.