A Windows Batch/CMD grammar for tree-sitter
Project description
tree-sitter-batch
Windows Batch/CMD grammar for tree-sitter.
Parses .bat and .cmd files into a concrete syntax tree for syntax highlighting, code navigation, and analysis.
Features
- Control flow —
IF/ELSE(EXIST, DEFINED, ERRORLEVEL, comparison with NOT),FOR(/D /R /L /F),GOTO,CALL,EXIT /B - Variables —
SET(plain,/Aarithmetic,/Pprompt),%VAR%,!VAR!,%%i,%~dp0,%VAR:old=new%, escaped forms%%VAR%%%%%%i - Echo — free-form text with literal
()!%, inline strings, and variable references - Operators — pipes
|, redirects>>>2>2>&1, conditional&&||, separator& - Structure — labels
:name, commentsREM::, parenthesized blocks,@ECHO OFF, macro invocations - Scope —
SETLOCAL/ENDLOCALwithENABLEDELAYEDEXPANSION - Case-insensitive — all keywords match regardless of casing
Example
@echo off
REM Build script
setlocal enabledelayedexpansion
set "PROJECT=MyApp"
set /a VERSION=1
if not exist "dist" (
mkdir dist
)
for %%f in (src\*.txt) do (
copy "%%f" "dist\"
)
if %ERRORLEVEL% == 0 (
echo Build successful
) else (
echo Build failed
exit /b 1
)
exit /b 0
Parsed tree:
(program
(echo_off)
(comment)
(setlocal_stmt)
(variable_assignment
(set_keyword) (variable_name) (assignment_value))
(variable_assignment
(set_keyword) (arithmetic_assignment (set_option) (arithmetic_expression)))
(if_stmt
(string)
(parenthesized
(cmd (command_name) (argument_list (argument_value)))))
(for_stmt
(for_variable)
(for_set (for_set_literal))
(parenthesized
(cmd (command_name) (argument_list (string) (string)))))
(if_stmt
(variable_reference)
(comparison_op)
(argument_value)
(parenthesized
(cmd (command_name) (argument_list (argument_value) (argument_value))))
(else_clause
(parenthesized
(cmd (command_name) (argument_list (argument_value) (argument_value)))
(exit_stmt (integer)))))
(exit_stmt (integer)))
Installation
npm
npm install tree-sitter-batch
Cargo
cargo add tree-sitter-batch
PyPI
pip install tree-sitter-batch
Go
import tree_sitter_batch "github.com/wharflab/tree-sitter-batch/bindings/go"
The root package also exports the bundled queries/highlights.scm via go:embed:
import batch "github.com/wharflab/tree-sitter-batch"
lang := batch.GetLanguage()
query, _ := batch.GetHighlightsQuery()
// or access the raw .scm source:
// raw := batch.HighlightsQuery
Usage
Node.js
import Parser from "tree-sitter";
import Batch from "tree-sitter-batch";
const parser = new Parser();
parser.setLanguage(Batch);
const tree = parser.parse(`@echo off\necho Hello World\n`);
console.log(tree.rootNode.toString());
Rust
let mut parser = tree_sitter::Parser::new();
let language = tree_sitter_batch::LANGUAGE;
parser.set_language(&language.into()).unwrap();
let tree = parser.parse("@echo off\necho Hello\n", None).unwrap();
println!("{}", tree.root_node().to_sexp());
Python
from tree_sitter import Language, Parser
import tree_sitter_batch
parser = Parser(Language(tree_sitter_batch.language()))
tree = parser.parse(b"@echo off\necho Hello\n")
print(tree.root_node.sexp())
Syntax Highlighting
The grammar ships with a queries/highlights.scm file for use in editors that support tree-sitter highlighting (Neovim, Helix, Zed, etc.).
References
- Grammar informed by Blinter batch file linter (159 rules)
- SS64 CMD reference
- Microsoft CMD documentation
License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tree_sitter_batch-0.10.1.tar.gz.
File metadata
- Download URL: tree_sitter_batch-0.10.1.tar.gz
- Upload date:
- Size: 42.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8a8b850943afdeb75a90a36423babae0d58b901647d0d76bee80624d737a9cfa
|
|
| MD5 |
2ab208396aeb9de361f73d9ee53b196c
|
|
| BLAKE2b-256 |
327081417e2c6fedfdb6f37be5bd511877ce251a22fa59fee9dbb8519f26622a
|
Provenance
The following attestation bundles were made for tree_sitter_batch-0.10.1.tar.gz:
Publisher:
publish_pypi.yml on wharflab/tree-sitter-batch
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tree_sitter_batch-0.10.1.tar.gz -
Subject digest:
8a8b850943afdeb75a90a36423babae0d58b901647d0d76bee80624d737a9cfa - Sigstore transparency entry: 1343350898
- Sigstore integration time:
-
Permalink:
wharflab/tree-sitter-batch@3d9baa112af201d4dff2e98d200c5adc6ec996c9 -
Branch / Tag:
refs/tags/v0.10.1 - Owner: https://github.com/wharflab
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish_pypi.yml@3d9baa112af201d4dff2e98d200c5adc6ec996c9 -
Trigger Event:
push
-
Statement type:
File details
Details for the file tree_sitter_batch-0.10.1-cp310-abi3-win_arm64.whl.
File metadata
- Download URL: tree_sitter_batch-0.10.1-cp310-abi3-win_arm64.whl
- Upload date:
- Size: 31.8 kB
- Tags: CPython 3.10+, Windows ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
02ce84eb28e6bcc75ce44f4ab938fa910f8e2c438aa9edc23e2b27f7e7cd2bf7
|
|
| MD5 |
93f354d9424bfcb2f678fb3a04c346cf
|
|
| BLAKE2b-256 |
ac6ada2590062afc369bade4f40913e63743c01a871a0acc425dd106851c4ecb
|
Provenance
The following attestation bundles were made for tree_sitter_batch-0.10.1-cp310-abi3-win_arm64.whl:
Publisher:
publish_pypi.yml on wharflab/tree-sitter-batch
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tree_sitter_batch-0.10.1-cp310-abi3-win_arm64.whl -
Subject digest:
02ce84eb28e6bcc75ce44f4ab938fa910f8e2c438aa9edc23e2b27f7e7cd2bf7 - Sigstore transparency entry: 1343351078
- Sigstore integration time:
-
Permalink:
wharflab/tree-sitter-batch@3d9baa112af201d4dff2e98d200c5adc6ec996c9 -
Branch / Tag:
refs/tags/v0.10.1 - Owner: https://github.com/wharflab
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish_pypi.yml@3d9baa112af201d4dff2e98d200c5adc6ec996c9 -
Trigger Event:
push
-
Statement type:
File details
Details for the file tree_sitter_batch-0.10.1-cp310-abi3-win_amd64.whl.
File metadata
- Download URL: tree_sitter_batch-0.10.1-cp310-abi3-win_amd64.whl
- Upload date:
- Size: 33.2 kB
- Tags: CPython 3.10+, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ce8f66f8c729aada529971240bb36f9c0d96ee0b70b481d0642b3157248c23c2
|
|
| MD5 |
7610e25e2544983acf5c7d578cd2c102
|
|
| BLAKE2b-256 |
7f98e4ced9b5d5bb8fe2975705d530a735fd58786439965fb8f7f4656f3295a0
|
Provenance
The following attestation bundles were made for tree_sitter_batch-0.10.1-cp310-abi3-win_amd64.whl:
Publisher:
publish_pypi.yml on wharflab/tree-sitter-batch
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tree_sitter_batch-0.10.1-cp310-abi3-win_amd64.whl -
Subject digest:
ce8f66f8c729aada529971240bb36f9c0d96ee0b70b481d0642b3157248c23c2 - Sigstore transparency entry: 1343350964
- Sigstore integration time:
-
Permalink:
wharflab/tree-sitter-batch@3d9baa112af201d4dff2e98d200c5adc6ec996c9 -
Branch / Tag:
refs/tags/v0.10.1 - Owner: https://github.com/wharflab
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish_pypi.yml@3d9baa112af201d4dff2e98d200c5adc6ec996c9 -
Trigger Event:
push
-
Statement type:
File details
Details for the file tree_sitter_batch-0.10.1-cp310-abi3-musllinux_1_2_x86_64.whl.
File metadata
- Download URL: tree_sitter_batch-0.10.1-cp310-abi3-musllinux_1_2_x86_64.whl
- Upload date:
- Size: 39.7 kB
- Tags: CPython 3.10+, musllinux: musl 1.2+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c4c1d6cd5b65276afea026fdbcf6ca0cb926c72c10139fbd2e1eddc9d26942ff
|
|
| MD5 |
15f5f9761e8c94f9a3f08a7ad54d95b7
|
|
| BLAKE2b-256 |
ea487a470d25c16bd3fc69fba221d8a2dde59fb9d132860be05b5b6d9d30ba05
|
Provenance
The following attestation bundles were made for tree_sitter_batch-0.10.1-cp310-abi3-musllinux_1_2_x86_64.whl:
Publisher:
publish_pypi.yml on wharflab/tree-sitter-batch
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tree_sitter_batch-0.10.1-cp310-abi3-musllinux_1_2_x86_64.whl -
Subject digest:
c4c1d6cd5b65276afea026fdbcf6ca0cb926c72c10139fbd2e1eddc9d26942ff - Sigstore transparency entry: 1343350919
- Sigstore integration time:
-
Permalink:
wharflab/tree-sitter-batch@3d9baa112af201d4dff2e98d200c5adc6ec996c9 -
Branch / Tag:
refs/tags/v0.10.1 - Owner: https://github.com/wharflab
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish_pypi.yml@3d9baa112af201d4dff2e98d200c5adc6ec996c9 -
Trigger Event:
push
-
Statement type:
File details
Details for the file tree_sitter_batch-0.10.1-cp310-abi3-musllinux_1_2_aarch64.whl.
File metadata
- Download URL: tree_sitter_batch-0.10.1-cp310-abi3-musllinux_1_2_aarch64.whl
- Upload date:
- Size: 39.9 kB
- Tags: CPython 3.10+, musllinux: musl 1.2+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d28eecae290c3ff3b501c1ce9b81decb317d5b9c41c25542edcb8f9766940d06
|
|
| MD5 |
de33ae7d5a52d4fd4a7e6bca0a37a4a9
|
|
| BLAKE2b-256 |
c5d9c212ceda6b0d3b2b9b0992f615917dff164a86a6d85194ca177ca50e8ab3
|
Provenance
The following attestation bundles were made for tree_sitter_batch-0.10.1-cp310-abi3-musllinux_1_2_aarch64.whl:
Publisher:
publish_pypi.yml on wharflab/tree-sitter-batch
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tree_sitter_batch-0.10.1-cp310-abi3-musllinux_1_2_aarch64.whl -
Subject digest:
d28eecae290c3ff3b501c1ce9b81decb317d5b9c41c25542edcb8f9766940d06 - Sigstore transparency entry: 1343350946
- Sigstore integration time:
-
Permalink:
wharflab/tree-sitter-batch@3d9baa112af201d4dff2e98d200c5adc6ec996c9 -
Branch / Tag:
refs/tags/v0.10.1 - Owner: https://github.com/wharflab
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish_pypi.yml@3d9baa112af201d4dff2e98d200c5adc6ec996c9 -
Trigger Event:
push
-
Statement type:
File details
Details for the file tree_sitter_batch-0.10.1-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl.
File metadata
- Download URL: tree_sitter_batch-0.10.1-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
- Upload date:
- Size: 40.3 kB
- Tags: CPython 3.10+, manylinux: glibc 2.17+ ARM64, manylinux: glibc 2.28+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f836d58568aee987aa9f977b5dd84d13948d3cbde79d79e57c2dc8db3b0494bb
|
|
| MD5 |
b34509d0c1c980d8462f468afb7fd648
|
|
| BLAKE2b-256 |
4790dde3ffc5325b001a975d7e9089d46d6a79a1273f1f2f649d0dc6f434de9c
|
Provenance
The following attestation bundles were made for tree_sitter_batch-0.10.1-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl:
Publisher:
publish_pypi.yml on wharflab/tree-sitter-batch
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tree_sitter_batch-0.10.1-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl -
Subject digest:
f836d58568aee987aa9f977b5dd84d13948d3cbde79d79e57c2dc8db3b0494bb - Sigstore transparency entry: 1343351098
- Sigstore integration time:
-
Permalink:
wharflab/tree-sitter-batch@3d9baa112af201d4dff2e98d200c5adc6ec996c9 -
Branch / Tag:
refs/tags/v0.10.1 - Owner: https://github.com/wharflab
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish_pypi.yml@3d9baa112af201d4dff2e98d200c5adc6ec996c9 -
Trigger Event:
push
-
Statement type:
File details
Details for the file tree_sitter_batch-0.10.1-cp310-abi3-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl.
File metadata
- Download URL: tree_sitter_batch-0.10.1-cp310-abi3-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
- Upload date:
- Size: 40.0 kB
- Tags: CPython 3.10+, manylinux: glibc 2.28+ x86-64, manylinux: glibc 2.5+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
351365b922e8b0d596deb43d363e40e67dfe04d513018d1df7e37c79ca52e169
|
|
| MD5 |
caee0d7335d7e17ead3c1dec3668104f
|
|
| BLAKE2b-256 |
736ef93942d0a4168f2046941d7280669543393dcef6f0d3ab857364ef7c6274
|
Provenance
The following attestation bundles were made for tree_sitter_batch-0.10.1-cp310-abi3-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl:
Publisher:
publish_pypi.yml on wharflab/tree-sitter-batch
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tree_sitter_batch-0.10.1-cp310-abi3-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl -
Subject digest:
351365b922e8b0d596deb43d363e40e67dfe04d513018d1df7e37c79ca52e169 - Sigstore transparency entry: 1343351017
- Sigstore integration time:
-
Permalink:
wharflab/tree-sitter-batch@3d9baa112af201d4dff2e98d200c5adc6ec996c9 -
Branch / Tag:
refs/tags/v0.10.1 - Owner: https://github.com/wharflab
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish_pypi.yml@3d9baa112af201d4dff2e98d200c5adc6ec996c9 -
Trigger Event:
push
-
Statement type:
File details
Details for the file tree_sitter_batch-0.10.1-cp310-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: tree_sitter_batch-0.10.1-cp310-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 31.7 kB
- Tags: CPython 3.10+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f97826d4c0f667b7681bfe7e09a84f560ddcac83feb6ea4cf6c1ea2ad9cc2ac9
|
|
| MD5 |
51fc0673a443aaf49723fe87af59f565
|
|
| BLAKE2b-256 |
25ca1e04993d0a5290b790498e3d50dad7322ced0b81389b5e58921d0c84ec12
|
Provenance
The following attestation bundles were made for tree_sitter_batch-0.10.1-cp310-abi3-macosx_11_0_arm64.whl:
Publisher:
publish_pypi.yml on wharflab/tree-sitter-batch
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tree_sitter_batch-0.10.1-cp310-abi3-macosx_11_0_arm64.whl -
Subject digest:
f97826d4c0f667b7681bfe7e09a84f560ddcac83feb6ea4cf6c1ea2ad9cc2ac9 - Sigstore transparency entry: 1343350991
- Sigstore integration time:
-
Permalink:
wharflab/tree-sitter-batch@3d9baa112af201d4dff2e98d200c5adc6ec996c9 -
Branch / Tag:
refs/tags/v0.10.1 - Owner: https://github.com/wharflab
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish_pypi.yml@3d9baa112af201d4dff2e98d200c5adc6ec996c9 -
Trigger Event:
push
-
Statement type:
File details
Details for the file tree_sitter_batch-0.10.1-cp310-abi3-macosx_10_9_x86_64.whl.
File metadata
- Download URL: tree_sitter_batch-0.10.1-cp310-abi3-macosx_10_9_x86_64.whl
- Upload date:
- Size: 30.3 kB
- Tags: CPython 3.10+, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c100b301e28589837e284d60afd536754125e8dec2bdc962c861bc6b6f0ee1db
|
|
| MD5 |
f0ead39c7391aeaae0fbb4c80866a0e0
|
|
| BLAKE2b-256 |
86e301f3d30afd0484312fa86c409847f543268681b5977ca889d1d446ae377c
|
Provenance
The following attestation bundles were made for tree_sitter_batch-0.10.1-cp310-abi3-macosx_10_9_x86_64.whl:
Publisher:
publish_pypi.yml on wharflab/tree-sitter-batch
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tree_sitter_batch-0.10.1-cp310-abi3-macosx_10_9_x86_64.whl -
Subject digest:
c100b301e28589837e284d60afd536754125e8dec2bdc962c861bc6b6f0ee1db - Sigstore transparency entry: 1343351047
- Sigstore integration time:
-
Permalink:
wharflab/tree-sitter-batch@3d9baa112af201d4dff2e98d200c5adc6ec996c9 -
Branch / Tag:
refs/tags/v0.10.1 - Owner: https://github.com/wharflab
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish_pypi.yml@3d9baa112af201d4dff2e98d200c5adc6ec996c9 -
Trigger Event:
push
-
Statement type: