Skip to main content

tree-sitter-hbk

CI npm crates.io PyPI

Грамматика 1C BSL в формате tree-sitter. Пакет также содержит отдельную грамматику sdbl для языка запросов 1C.

Попробовать

playground

Что входит

  • bsl: грамматика исходных файлов BSL (.bsl, .osl).
  • sdbl: грамматика самостоятельных текстов запросов 1C (.sdbl).
  • Query-файлы tree-sitter для подсветки BSL/SDBL и внедрения статических строковых литералов BSL, начинающихся с ВЫБРАТЬ, SELECT, УНИЧТОЖИТЬ или DROP, как sdbl.
  • Локальное dev-расширение Zed в editors/zed-bsl для проверки подсветки BSL, самостоятельного SDBL и внедренного SDBL.

BSL и SDBL остаются разными контрактами парсера. Грамматика BSL не встраивает SDBL в AST строковых литералов; разбор встроенных запросов выполняется через tree-sitter injections и композицию на стороне редактора.

Локальная разработка

Локальный tree-sitter playground запускается отдельно для каждой грамматики:

npm start
npm run start:bsl
npm run start:sdbl

npm start является псевдонимом для BSL playground. npm run start:sdbl запускает playground самостоятельной грамматики SDBL. При необходимости можно собрать оба WASM-парсера:

npm run build:wasm

Быстрая проверка дерева разбора:

npm run parse:bsl -- examples/playground/basic.bsl
npm run parse:sdbl -- examples/playground/select.sdbl

Небольшие примеры для playground лежат в examples/playground:

  • basic.bsl для синтаксиса исходных файлов BSL;
  • select.sdbl и query-package.sdbl для синтаксиса самостоятельных SDBL-запросов.

SDBL-примеры разбираются самостоятельной грамматикой SDBL. BSL-строки с текстом запроса остаются узлами строк BSL; разбор встроенного запроса относится к отдельному контракту injection/composition.

Основные команды проверки:

npm run test:corpus
npm test
npm run test:all

npm run test:corpus использует локальный для пакета tree-sitter-cli и проверяет оба набора corpus-тестов. Для системного tree-sitter CLI, который поддерживает -p, эквивалентные команды:

tree-sitter test -p grammars/bsl
tree-sitter test -p grammars/sdbl

Использование

Rust

Добавьте зависимость в Cargo.toml:

[dependencies]
tree-sitter = "0.25"
tree-sitter-hbk = "0.1"
use tree_sitter::Parser;

fn main() {
    let mut parser = Parser::new();
    parser
        .set_language(&tree_sitter_hbk::LANGUAGE.into())
        .expect("Error loading BSL grammar");

    let source = r#"
        Процедура Привет()
            Сообщить("Привет, мир!");
        КонецПроцедуры
    "#;

    let tree = parser.parse(source, None).unwrap();
    println!("{}", tree.root_node().to_sexp());
}

Node.js

Установите пакет:

npm install tree-sitter-hbk tree-sitter
const Parser = require("tree-sitter");
const BSL = require("tree-sitter-hbk");

const parser = new Parser();
parser.setLanguage(BSL);

const sourceCode = `
Процедура Привет()
    Сообщить("Привет, мир!");
КонецПроцедуры
`;

const tree = parser.parse(sourceCode);
console.log(tree.rootNode.toString());

Python

Установите пакет:

pip install tree-sitter-hbk tree-sitter
import tree_sitter_hbk as tshbk
from tree_sitter import Language, Parser

BSL_LANGUAGE = Language(tshbk.language())
parser = Parser(BSL_LANGUAGE)

source = """
Процедура Привет()
    Сообщить("Привет, мир!");
КонецПроцедуры
""".encode()

tree = parser.parse(source)
print(tree.root_node.sexp())

Грамматика запросов SDBL

Пакет также экспортирует самостоятельную грамматику языка запросов SDBL:

  • Node.js: require("tree-sitter-hbk").sdbl;
  • Rust: tree_sitter_hbk::SDBL_LANGUAGE;
  • Python: tree_sitter_hbk.SDBLLanguage() или низкоуровневая капсула tree_sitter_hbk.sdbl_language();
  • Go: tree_sitter_bsl.SDBLLanguage() from the existing Go binding package;
  • C: tree_sitter_sdbl() из tree-sitter-bsl.h и той же библиотеки.

Существующие точки входа BSL остаются языком пакета по умолчанию.

Пакет включает query-файлы tree-sitter для интеграций с редакторами:

  • grammars/bsl/queries/highlights.scm для подсветки BSL;
  • grammars/bsl/queries/injections.scm для внедрения статических строковых литералов BSL, начинающихся с ключевых слов SDBL-выражений, как sdbl;
  • grammars/sdbl/queries/highlights.scm для подсветки самостоятельного SDBL и текста запросов, внедренного из BSL.

Для Zed используется локальное dev extension: editors/zed-bsl. Оно регистрирует BSL, SDBL и специальную для Zed грамматику-носитель sdbl_embedded, чтобы исходный текст внедренной BSL-строки подсвечивался без изменения контракта самостоятельной грамматики .sdbl.

Ссылки

Metadata

Release files for tree-sitter-hbk 0.1.13

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-hbk 0.1.13
File Size Uploaded Provenance Actions
tree_sitter_hbk-0.1.13.tar.gz 177.7 kB With provenance Details for tree_sitter_hbk-0.1.13.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for tree-sitter-hbk 0.1.13
File Actions
tree_sitter_hbk-0.1.13-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details for tree_sitter_hbk-0.1.13-cp310-abi3-win_amd64.whl
tree_sitter_hbk-0.1.13-cp310-abi3-win32.whl CPython 3.10 abi3 Windows x86-32 Details for tree_sitter_hbk-0.1.13-cp310-abi3-win32.whl
tree_sitter_hbk-0.1.13-cp310-abi3-musllinux_1_2_x86_64.whl CPython 3.10 abi3 Linux musl 1.2+ x86-64 Details for tree_sitter_hbk-0.1.13-cp310-abi3-musllinux_1_2_x86_64.whl
tree_sitter_hbk-0.1.13-cp310-abi3-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl CPython 3.10 abi3 Linux glibc 2.5+ x86-64, Linux glibc 2.28+ x86-64 Details for tree_sitter_hbk-0.1.13-cp310-abi3-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
tree_sitter_hbk-0.1.13-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details for tree_sitter_hbk-0.1.13-cp310-abi3-macosx_11_0_arm64.whl

Total release size: 690.5 kB

Release files / tree_sitter_hbk-0.1.13.tar.gz

Download URL tree_sitter_hbk-0.1.13.tar.gz
Size 177.7 kB
Tags Source
SHA-256 checksum
How to use checksums
20882ff297ea748611d38721736419f0be71eeb1ef05d03819ccf9e48098ad1c
BLAKE2b-256 checksum
How to use checksums
f3ad03ecdaf620268fb4c01e0ad1d9f5f10f172ed3f0fa32fc4e942f5ee60bc5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 28, 2026.

Transparency log

Release files / tree_sitter_hbk-0.1.13-cp310-abi3-win_amd64.whl

Download URL tree_sitter_hbk-0.1.13-cp310-abi3-win_amd64.whl
Size 95.9 kB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
31299a084308ae9cc454b403d057c40867ed46ff12e92c15b0739aaea742a583
BLAKE2b-256 checksum
How to use checksums
2d17f6f90ee39bde3ea82eb521bb99e278b101e7b479e52391b7fc4cb699859f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 28, 2026.

Transparency log

Release files / tree_sitter_hbk-0.1.13-cp310-abi3-win32.whl

Download URL tree_sitter_hbk-0.1.13-cp310-abi3-win32.whl
Size 98.9 kB
Tags CPython 3.10 Windows x86-32 abi3
SHA-256 checksum
How to use checksums
89296967d8b85cd40694bcb2923d33770ad9c7e0426645212360cdb750b09b80
BLAKE2b-256 checksum
How to use checksums
b3f63a1ed5fb6426599b0da22dd3d31531a5ca47a8b1174564b4a28f9d4235c3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 28, 2026.

Transparency log

Release files / tree_sitter_hbk-0.1.13-cp310-abi3-musllinux_1_2_x86_64.whl

Download URL tree_sitter_hbk-0.1.13-cp310-abi3-musllinux_1_2_x86_64.whl
Size 109.9 kB
Tags CPython 3.10 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
46f4120cb8d70c368bc1e4dca69cce78367a084ea6f1bc7c07c10ddcacef9f75
BLAKE2b-256 checksum
How to use checksums
8bfe2951a6d3eb35fc1e0bf051700e368ef518f4c10901702353f3fc9ad3763a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 28, 2026.

Transparency log

Release files / tree_sitter_hbk-0.1.13-cp310-abi3-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl

Download URL tree_sitter_hbk-0.1.13-cp310-abi3-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Size 110.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
94b6c6710744e6ee5a7a877196a52d8cfbbb40516f13afe8a9124bb03306cf90
BLAKE2b-256 checksum
How to use checksums
9026881c8c5017c88b93b07cb8b4fb384f164b3f4f9c517984b295092f8eb4c1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 28, 2026.

Transparency log

Release files / tree_sitter_hbk-0.1.13-cp310-abi3-macosx_11_0_arm64.whl

Download URL tree_sitter_hbk-0.1.13-cp310-abi3-macosx_11_0_arm64.whl
Size 98.0 kB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
2c94206499606fc57dd1d175f1428c62f8781474375f84c4e6802865bd4e9bbc
BLAKE2b-256 checksum
How to use checksums
ab754732ab68f732c8d924d8fcbe930d30c20a003642672366aff9a43e6b2150
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 28, 2026.

Transparency log

Security for tree-sitter-hbk 0.1.13

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 6 files in this release have been uploaded with provenance metadata.

Select from 6 files

Attestation for tree_sitter_hbk-0.1.13.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 Nov 28, 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.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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