Skip to main content

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, /A arithmetic, /P prompt, display-only without =), %VAR%, !VAR!, %%i, %~dp0, %VAR:old=new%, subscripted delayed expansion !ARR[%%i]!, for-variable modifiers %%~dpnxf %%~zS %%~$PATH:F, escaped forms %%VAR%% %%%%i
  • Echo — free-form text with literal ( ) ! %, inline strings, and variable references
  • Operators — pipes |, redirects > >> < 2> 2>&1 (fds 0-9, including variable handles >&%FD% / <&%FD%), conditional && ||, separator &
  • Line continuation — trailing caret ^ joins the current line with the next (e.g. "%JAVACMD%" ^ followed by indented arguments)
  • Commands — bare names, variable references as command, and quoted paths ("C:\path\app.exe" args, call "%SCRIPT%" %*)
  • Structure — labels :name, comments REM ::, parenthesized blocks (including @(...)), @ECHO OFF, macro invocations, DosTips idioms (call,) / (call;) / (call) for ERRORLEVEL manipulation
  • Scope — SETLOCAL/ENDLOCAL with ENABLEDELAYEDEXPANSION
  • Polyglot headers — tolerates batch/PowerShell <# ... #> header lines and batch/VBScript lines marked with a trailing 'VBS so SysToolsLib-style dual-language scripts parse cleanly
  • 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

License

MIT

Metadata

Release files for tree-sitter-batch 0.11.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tree-sitter-batch 0.11.1
File Size Uploaded Provenance
tree_sitter_batch-0.11.1.tar.gz 54.1 kB With provenance Details

Built distributions (wheels)

Table of built distributions (wheels) for tree-sitter-batch 0.11.1
File
tree_sitter_batch-0.11.1-cp310-abi3-win_arm64.whl CPython 3.10 abi3 Windows ARM64 Details
tree_sitter_batch-0.11.1-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details
tree_sitter_batch-0.11.1-cp310-abi3-musllinux_1_2_x86_64.whl CPython 3.10 abi3 Linux musl 1.2+ x86-64 Details
tree_sitter_batch-0.11.1-cp310-abi3-musllinux_1_2_aarch64.whl CPython 3.10 abi3 Linux musl 1.2+ ARM64 Details
tree_sitter_batch-0.11.1-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl CPython 3.10 abi3 Linux glibc 2.17+ ARM64, Linux glibc 2.28+ ARM64 Details
tree_sitter_batch-0.11.1-cp310-abi3-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl CPython 3.10 abi3 Linux glibc 2.28+ x86-64, Linux glibc 2.5+ x86-64 Details
tree_sitter_batch-0.11.1-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details
tree_sitter_batch-0.11.1-cp310-abi3-macosx_10_9_x86_64.whl CPython 3.10 abi3 macOS 10.9+ x86-64 Details

Total release size: 451.5 kB

Release files / tree_sitter_batch-0.11.1.tar.gz

Download URL tree_sitter_batch-0.11.1.tar.gz
Size 54.1 kB
Tags Source
SHA-256 checksum
How to use checksums
752ddd015d9412ba2d4df058388dae84cd2c905c67057a039c0628425b4967ea
BLAKE2b-256 checksum
How to use checksums
876c5a296d17eb24270b68270afc70f1842ee626b8c7c71403aec2d88aeb1fd8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 21, 2026.

Transparency log

Release files / tree_sitter_batch-0.11.1-cp310-abi3-win_arm64.whl

Download URL tree_sitter_batch-0.11.1-cp310-abi3-win_arm64.whl
Size 44.3 kB
Tags CPython 3.10 Windows ARM64 abi3
SHA-256 checksum
How to use checksums
8997ca43a5d29e654546a72a5f70a0c2a6a606ca2bbe7538fda7d4a70d4b4e6d
BLAKE2b-256 checksum
How to use checksums
17250abbe6239285d848b5e41ba6fa8436504c2752cf8e6f590b91281790fa65
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 21, 2026.

Transparency log

Release files / tree_sitter_batch-0.11.1-cp310-abi3-win_amd64.whl

Download URL tree_sitter_batch-0.11.1-cp310-abi3-win_amd64.whl
Size 46.3 kB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
755ca1e2dcbc06e62e7e254fd99b40bcef8d35a927fb8f123c72c60baf4bc6f5
BLAKE2b-256 checksum
How to use checksums
7a9096feb639738854a4da7e4296bf6abec6b700b60b05d56238207b60fe1861
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 21, 2026.

Transparency log

Release files / tree_sitter_batch-0.11.1-cp310-abi3-musllinux_1_2_x86_64.whl

Download URL tree_sitter_batch-0.11.1-cp310-abi3-musllinux_1_2_x86_64.whl
Size 54.5 kB
Tags CPython 3.10 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
6633f51111cd439324d835284d742ca4ce12eb865372b006eb9857f6e73946f0
BLAKE2b-256 checksum
How to use checksums
35136e48f98733d12dc324225f7b85c858cbe3e5b455f0b60671a381619b6d00
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 21, 2026.

Transparency log

Release files / tree_sitter_batch-0.11.1-cp310-abi3-musllinux_1_2_aarch64.whl

Download URL tree_sitter_batch-0.11.1-cp310-abi3-musllinux_1_2_aarch64.whl
Size 54.4 kB
Tags CPython 3.10 Linux musl 1.2+ ARM64 abi3
SHA-256 checksum
How to use checksums
eea9c860e05e970f8b6405e27f0511eddf30fe64a5d6325bf619284314826373
BLAKE2b-256 checksum
How to use checksums
adff2df1be60d74e59e2b149dad2c14a6b18764fceee2bc81208fb71dbd222c3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 21, 2026.

Transparency log

Release files / tree_sitter_batch-0.11.1-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl

Download URL tree_sitter_batch-0.11.1-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Size 54.8 kB
Tags CPython 3.10 Linux glibc 2.17+ ARM64 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
cba9429978825a55e6b1acae9775b748c3cffbe4e3187ef41f72e1adf28877eb
BLAKE2b-256 checksum
How to use checksums
b1b673351c80ae8a539c82a07cf1e6baf10d13da9d82ded4a3b2c1ffbb0d7417
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 21, 2026.

Transparency log

Release files / tree_sitter_batch-0.11.1-cp310-abi3-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl

Download URL tree_sitter_batch-0.11.1-cp310-abi3-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Size 55.1 kB
Tags CPython 3.10 Linux glibc 2.28+ x86-64 Linux glibc 2.5+ x86-64 abi3
SHA-256 checksum
How to use checksums
03957e781f130e76843531719d731519db9eb1e8981c5ded44923b872b87f4b9
BLAKE2b-256 checksum
How to use checksums
cbd7ed1ef6c38d9021c2eb78d67c8c27a5c382b0fa0794f7a7477f9c2bd2cf56
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 21, 2026.

Transparency log

Release files / tree_sitter_batch-0.11.1-cp310-abi3-macosx_11_0_arm64.whl

Download URL tree_sitter_batch-0.11.1-cp310-abi3-macosx_11_0_arm64.whl
Size 45.0 kB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
38c56f96a5ed8ecc498da52e67fd1cfd4409e67270e9242d1c8a52cb55b9dfaf
BLAKE2b-256 checksum
How to use checksums
104beb0597855e7cd89c41e9214153fc03bb198f6e5689feba340b4e94963681
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 21, 2026.

Transparency log

Release files / tree_sitter_batch-0.11.1-cp310-abi3-macosx_10_9_x86_64.whl

Download URL tree_sitter_batch-0.11.1-cp310-abi3-macosx_10_9_x86_64.whl
Size 43.1 kB
Tags CPython 3.10 abi3 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
274097c4d0c1991f8ecec8af237526bc04543d232ad545d1f47b7090dc41d74f
BLAKE2b-256 checksum
How to use checksums
2d557f7857ca78c1ec6b50bfac0209e95060c5986a01886f1ec6b5f4a8bdd88a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 21, 2026.

Transparency log

Security for tree-sitter-batch 0.11.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 9 files in this release have been uploaded with provenance metadata.

Select from 9 files

Attestation for tree_sitter_batch-0.11.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 21, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page