# Tree sitter grammar for CFEngine policy language
This tree-sitter grammar parses CFEngine policy language and turns it into an abstract syntax tree.
It is used to provide syntax highlighting in the Zed editor, via this extension:
https://github.com/olehermanse/zed-cfengine
The grammar currently supports all major features of the language, including:
- Bundle blocks
- Body blocks
- Promise type definition blocks
- Promise types, class guards, promises, stakeholders (promisees)
- Macros
- Function calls
- Lists, strings, expansions (with `$()` and `@()`)
## Todos
- Using the grammar for linting / syntax checking (language server)
- Highlighting inside strings and comments
- Recognizing when there is JSON inside policy
- Class guards which are quoted strings
- Using the grammar for code indentation
- Using the grammar for extensions to other editors
Before contributing for the first time, it's recommended to go through the tree-sitter tutorial for getting familiar with how everything works:
https://tree-sitter.github.io/tree-sitter/creating-parsers
Inspired by Lars Erik Wik's initial implementation available here:
https://github.com/larsewi/tree-sitter-cfengine
## Run containerized tests locally:
```
docker build --tag tree-sitter-cfengine .
```
## Making changes
After making changes to `grammar.js`, run the the commands below to generate, build, and test:
```
tree-sitter generate && tree-sitter build && tree-sitter test
```
In tree-sitter projects, it is normal to commit the files generated / edited by the tree-sitter tooling.
Once it is working and tests are passing, commit the changes (including `src/` folder with generated files).
## Creating a new release
Creating a release in GitHub **will not work**.
To create a new release, you need to make a commit and tag locally, and push it.
First ensure you have a clean git repo without any uncommitted changes.
Then, run the following commands:
```
tree-sitter version 1.2.3
git add -A
git commit -S -s -m "Bump to version 1.2.3"
git tag -s -a 1.2.3 -m 1.2.3
git push --tags
```
GitHub Actions will start when a tag is pushed, and the action will create the "Release" in GitHub, as well as pypi, npm, and crates.io:
- https://github.com/olehermanse/tree-sitter-cfengine/releases
- https://pypi.org/project/tree-sitter-cfengine
- https://www.npmjs.com/package/tree-sitter-cfengine
- https://crates.io/crates/tree-sitter-cfengine
Raw data
{
"_id": null,
"home_page": null,
"name": "tree-sitter-cfengine",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": null,
"keywords": "incremental, parsing, tree-sitter, cfengine",
"author": null,
"author_email": "Ole Herman Schumacher Elgesem <oleherman93@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/73/68/9a523138eaea81dfcbf05568b2d28247c7bc580473a5001d68972b055661/tree_sitter_cfengine-1.0.12.tar.gz",
"platform": null,
"description": "# Tree sitter grammar for CFEngine policy language\n\nThis tree-sitter grammar parses CFEngine policy language and turns it into an abstract syntax tree.\nIt is used to provide syntax highlighting in the Zed editor, via this extension:\n\nhttps://github.com/olehermanse/zed-cfengine\n\nThe grammar currently supports all major features of the language, including:\n\n- Bundle blocks\n- Body blocks\n- Promise type definition blocks\n- Promise types, class guards, promises, stakeholders (promisees)\n- Macros\n- Function calls\n- Lists, strings, expansions (with `$()` and `@()`)\n\n## Todos\n\n- Using the grammar for linting / syntax checking (language server)\n- Highlighting inside strings and comments\n- Recognizing when there is JSON inside policy\n- Class guards which are quoted strings\n- Using the grammar for code indentation\n- Using the grammar for extensions to other editors\n\nBefore contributing for the first time, it's recommended to go through the tree-sitter tutorial for getting familiar with how everything works:\n\nhttps://tree-sitter.github.io/tree-sitter/creating-parsers\n\nInspired by Lars Erik Wik's initial implementation available here:\n\nhttps://github.com/larsewi/tree-sitter-cfengine\n\n\n## Run containerized tests locally:\n\n```\ndocker build --tag tree-sitter-cfengine .\n```\n\n## Making changes\n\nAfter making changes to `grammar.js`, run the the commands below to generate, build, and test:\n\n```\ntree-sitter generate && tree-sitter build && tree-sitter test\n```\n\nIn tree-sitter projects, it is normal to commit the files generated / edited by the tree-sitter tooling.\nOnce it is working and tests are passing, commit the changes (including `src/` folder with generated files).\n\n## Creating a new release\n\nCreating a release in GitHub **will not work**.\nTo create a new release, you need to make a commit and tag locally, and push it.\nFirst ensure you have a clean git repo without any uncommitted changes.\nThen, run the following commands:\n\n```\ntree-sitter version 1.2.3\ngit add -A\ngit commit -S -s -m \"Bump to version 1.2.3\"\ngit tag -s -a 1.2.3 -m 1.2.3\ngit push --tags\n```\n\nGitHub Actions will start when a tag is pushed, and the action will create the \"Release\" in GitHub, as well as pypi, npm, and crates.io:\n\n- https://github.com/olehermanse/tree-sitter-cfengine/releases\n- https://pypi.org/project/tree-sitter-cfengine\n- https://www.npmjs.com/package/tree-sitter-cfengine\n- https://crates.io/crates/tree-sitter-cfengine\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "CFEngine grammar for tree-sitter",
"version": "1.0.12",
"project_urls": {
"Homepage": "https://github.com/olehermanse/tree-sitter-cfengine"
},
"split_keywords": [
"incremental",
" parsing",
" tree-sitter",
" cfengine"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "0bf720a18d0e64034e64998c46f6b39b48b544314e286fc4d31080c4ddd2ced3",
"md5": "ef58c90fb6bfbe9c61da49bc35b9b76e",
"sha256": "3906fa402bc7cc8c97e1db6e5bd5e116f027c043826f109d524556798bb478c0"
},
"downloads": -1,
"filename": "tree_sitter_cfengine-1.0.12-cp39-abi3-macosx_10_9_x86_64.whl",
"has_sig": false,
"md5_digest": "ef58c90fb6bfbe9c61da49bc35b9b76e",
"packagetype": "bdist_wheel",
"python_version": "cp39",
"requires_python": ">=3.9",
"size": 12272,
"upload_time": "2025-08-07T12:46:38",
"upload_time_iso_8601": "2025-08-07T12:46:38.358951Z",
"url": "https://files.pythonhosted.org/packages/0b/f7/20a18d0e64034e64998c46f6b39b48b544314e286fc4d31080c4ddd2ced3/tree_sitter_cfengine-1.0.12-cp39-abi3-macosx_10_9_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "081390520939609fa0240ef7f3edd9c83f9b193cdb1ed97939c61547701c3eae",
"md5": "1f6e52de9c04dc9ffe416946de7c5cc6",
"sha256": "9ed53cff54ba31de420ade9ec74f3e18b0f1c4407c1e055e7899eebaf8250555"
},
"downloads": -1,
"filename": "tree_sitter_cfengine-1.0.12-cp39-abi3-macosx_11_0_arm64.whl",
"has_sig": false,
"md5_digest": "1f6e52de9c04dc9ffe416946de7c5cc6",
"packagetype": "bdist_wheel",
"python_version": "cp39",
"requires_python": ">=3.9",
"size": 12613,
"upload_time": "2025-08-07T12:46:39",
"upload_time_iso_8601": "2025-08-07T12:46:39.331329Z",
"url": "https://files.pythonhosted.org/packages/08/13/90520939609fa0240ef7f3edd9c83f9b193cdb1ed97939c61547701c3eae/tree_sitter_cfengine-1.0.12-cp39-abi3-macosx_11_0_arm64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "032f34735ddb8ad59721fba58169c8e7dad3a5db5f28a817264fbf8c525447b3",
"md5": "29cb4f9264b5989e80bb09e62d0a2e92",
"sha256": "876044c5ac6cff81bafe1818f61a5cb5bbe1b761535d096816cb7b05d8ebecba"
},
"downloads": -1,
"filename": "tree_sitter_cfengine-1.0.12-cp39-abi3-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl",
"has_sig": false,
"md5_digest": "29cb4f9264b5989e80bb09e62d0a2e92",
"packagetype": "bdist_wheel",
"python_version": "cp39",
"requires_python": ">=3.9",
"size": 23018,
"upload_time": "2025-08-07T12:46:40",
"upload_time_iso_8601": "2025-08-07T12:46:40.678413Z",
"url": "https://files.pythonhosted.org/packages/03/2f/34735ddb8ad59721fba58169c8e7dad3a5db5f28a817264fbf8c525447b3/tree_sitter_cfengine-1.0.12-cp39-abi3-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "eb1b6bbd88fb3f54b84a7d9a49173534b964a2f7985758f334addd698069a188",
"md5": "84e180ff20014f3aadf203e7fbf1c86e",
"sha256": "1c7afb31a8525ee4a8b7dbd55471f25ff9a39a491fc82690774c6a291dcac0b8"
},
"downloads": -1,
"filename": "tree_sitter_cfengine-1.0.12-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl",
"has_sig": false,
"md5_digest": "84e180ff20014f3aadf203e7fbf1c86e",
"packagetype": "bdist_wheel",
"python_version": "cp39",
"requires_python": ">=3.9",
"size": 24548,
"upload_time": "2025-08-07T12:46:41",
"upload_time_iso_8601": "2025-08-07T12:46:41.822873Z",
"url": "https://files.pythonhosted.org/packages/eb/1b/6bbd88fb3f54b84a7d9a49173534b964a2f7985758f334addd698069a188/tree_sitter_cfengine-1.0.12-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "8de83c03a654333c7067ffb7b50e1bfc67b4fc1164a273edc68e86ee41ea3beb",
"md5": "b2f1f158d3e66314824537c732f5022f",
"sha256": "74a40c0497e79173c45422fadaa0640f9cf3d394e895256237dd2ffe56955e7a"
},
"downloads": -1,
"filename": "tree_sitter_cfengine-1.0.12-cp39-abi3-musllinux_1_2_x86_64.whl",
"has_sig": false,
"md5_digest": "b2f1f158d3e66314824537c732f5022f",
"packagetype": "bdist_wheel",
"python_version": "cp39",
"requires_python": ">=3.9",
"size": 22840,
"upload_time": "2025-08-07T12:46:42",
"upload_time_iso_8601": "2025-08-07T12:46:42.902412Z",
"url": "https://files.pythonhosted.org/packages/8d/e8/3c03a654333c7067ffb7b50e1bfc67b4fc1164a273edc68e86ee41ea3beb/tree_sitter_cfengine-1.0.12-cp39-abi3-musllinux_1_2_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "457daecd66b65373dbb27abd35997617b848a14f815ab12d824b0a23f0c0501e",
"md5": "60c1219d3e4b4f0bec0b325741d4ee7a",
"sha256": "beba35425906166f1473ea7491a6a03b3349caba399a09435bfb122da318ad1d"
},
"downloads": -1,
"filename": "tree_sitter_cfengine-1.0.12-cp39-abi3-win_amd64.whl",
"has_sig": false,
"md5_digest": "60c1219d3e4b4f0bec0b325741d4ee7a",
"packagetype": "bdist_wheel",
"python_version": "cp39",
"requires_python": ">=3.9",
"size": 15212,
"upload_time": "2025-08-07T12:46:44",
"upload_time_iso_8601": "2025-08-07T12:46:44.051806Z",
"url": "https://files.pythonhosted.org/packages/45/7d/aecd66b65373dbb27abd35997617b848a14f815ab12d824b0a23f0c0501e/tree_sitter_cfengine-1.0.12-cp39-abi3-win_amd64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "ff5025244963e59ccb40f0fdb0e3a1ab63134cc8a3f04be4dbb4ff71d4d0a7e1",
"md5": "95a22c665566fa2255fc48d227b6856c",
"sha256": "c2d3c5c1b89504cbe65e3a4b950700e8928eb09a370a303eb986462be3e82d0b"
},
"downloads": -1,
"filename": "tree_sitter_cfengine-1.0.12-cp39-abi3-win_arm64.whl",
"has_sig": false,
"md5_digest": "95a22c665566fa2255fc48d227b6856c",
"packagetype": "bdist_wheel",
"python_version": "cp39",
"requires_python": ">=3.9",
"size": 14047,
"upload_time": "2025-08-07T12:46:45",
"upload_time_iso_8601": "2025-08-07T12:46:45.199505Z",
"url": "https://files.pythonhosted.org/packages/ff/50/25244963e59ccb40f0fdb0e3a1ab63134cc8a3f04be4dbb4ff71d4d0a7e1/tree_sitter_cfengine-1.0.12-cp39-abi3-win_arm64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "73689a523138eaea81dfcbf05568b2d28247c7bc580473a5001d68972b055661",
"md5": "25304004cd5bdfdc993b0dbd4e6f2870",
"sha256": "312f8b5c584ab4a5e4620b3f12aede8011e7a31c3b6a3b769e00d1448773785d"
},
"downloads": -1,
"filename": "tree_sitter_cfengine-1.0.12.tar.gz",
"has_sig": false,
"md5_digest": "25304004cd5bdfdc993b0dbd4e6f2870",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 15160,
"upload_time": "2025-08-07T12:46:45",
"upload_time_iso_8601": "2025-08-07T12:46:45.917596Z",
"url": "https://files.pythonhosted.org/packages/73/68/9a523138eaea81dfcbf05568b2d28247c7bc580473a5001d68972b055661/tree_sitter_cfengine-1.0.12.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-08-07 12:46:45",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "olehermanse",
"github_project": "tree-sitter-cfengine",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "tree-sitter-cfengine"
}