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.

Ссылки

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tree_sitter_hbk-0.1.11.tar.gz (177.6 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

tree_sitter_hbk-0.1.11-cp310-abi3-win_amd64.whl (96.7 kB view details)

Uploaded CPython 3.10+Windows x86-64

tree_sitter_hbk-0.1.11-cp310-abi3-win32.whl (99.8 kB view details)

Uploaded CPython 3.10+Windows x86

tree_sitter_hbk-0.1.11-cp310-abi3-musllinux_1_2_x86_64.whl (109.7 kB view details)

Uploaded CPython 3.10+musllinux: musl 1.2+ x86-64

tree_sitter_hbk-0.1.11-cp310-abi3-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (109.9 kB view details)

Uploaded CPython 3.10+manylinux: glibc 2.28+ x86-64manylinux: glibc 2.5+ x86-64

tree_sitter_hbk-0.1.11-cp310-abi3-macosx_11_0_arm64.whl (98.0 kB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

File details

Details for the file tree_sitter_hbk-0.1.11.tar.gz.

File metadata

  • Download URL: tree_sitter_hbk-0.1.11.tar.gz
  • Upload date:
  • Size: 177.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for tree_sitter_hbk-0.1.11.tar.gz
Algorithm Hash digest
SHA256 0df19bcba100e01e8052b554bc0d3555413cedcfc4b3991b70e686735153be1d
MD5 6c3598592aa8b79a712968ea134ab5ca
BLAKE2b-256 ec14de41eff2e963ef94024e14b89c3366a611ad4ca5fe3e84fe954c3a518645

See more details on using hashes here.

Provenance

The following attestation bundles were made for tree_sitter_hbk-0.1.11.tar.gz:

Publisher: publish.yml on mussolene/tree-sitter-bsl

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tree_sitter_hbk-0.1.11-cp310-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for tree_sitter_hbk-0.1.11-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 0d63affb48ea1f0a69d5b993a52446aadac9e3d377a806182223663b6565695b
MD5 a2f029b2909b0346768e4ccfe1f86063
BLAKE2b-256 9dc36a2784230287fbf9866874f612ef4b3331d2db9a16ee21cdfa523af1be91

See more details on using hashes here.

Provenance

The following attestation bundles were made for tree_sitter_hbk-0.1.11-cp310-abi3-win_amd64.whl:

Publisher: publish.yml on mussolene/tree-sitter-bsl

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tree_sitter_hbk-0.1.11-cp310-abi3-win32.whl.

File metadata

File hashes

Hashes for tree_sitter_hbk-0.1.11-cp310-abi3-win32.whl
Algorithm Hash digest
SHA256 69f9f646f2a9cc6b57d4f81fc394e044c578fe470f81bf29efeb10bbae97daeb
MD5 9d9f0984615c398c0fd687d65fa59bd9
BLAKE2b-256 0ee41aa47d80623e8561687d259012d490a174859654507e2965657df1223afe

See more details on using hashes here.

Provenance

The following attestation bundles were made for tree_sitter_hbk-0.1.11-cp310-abi3-win32.whl:

Publisher: publish.yml on mussolene/tree-sitter-bsl

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tree_sitter_hbk-0.1.11-cp310-abi3-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for tree_sitter_hbk-0.1.11-cp310-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 d52a27ac4cf18bd35fcda64f8beda62487b796960ef9ab597b4bfeadeef8398c
MD5 8aa01533447518b70e2f63911c51a08c
BLAKE2b-256 624f34cd5eaad1de92e94088a44efb5e85951cb1e8126575b39365997a10cd27

See more details on using hashes here.

Provenance

The following attestation bundles were made for tree_sitter_hbk-0.1.11-cp310-abi3-musllinux_1_2_x86_64.whl:

Publisher: publish.yml on mussolene/tree-sitter-bsl

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tree_sitter_hbk-0.1.11-cp310-abi3-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl.

File metadata

File hashes

Hashes for tree_sitter_hbk-0.1.11-cp310-abi3-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 292e3d00b8d24268416be2f76b4b6d4c6c5cab723606166f67e772c98f24e561
MD5 0fa8cfb67d1c4fd12187fccbc9610a87
BLAKE2b-256 625ab8e402ca3ab542d8cd9d3530eb542e316a3cfccd84867f542ebc8c65d6e4

See more details on using hashes here.

Provenance

The following attestation bundles were made for tree_sitter_hbk-0.1.11-cp310-abi3-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl:

Publisher: publish.yml on mussolene/tree-sitter-bsl

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tree_sitter_hbk-0.1.11-cp310-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for tree_sitter_hbk-0.1.11-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 85a67ef160bedfbbe49698b7b01cd433f9172d4ee0f075988b359058f7285b29
MD5 504b3c2798c71e3cd009b9829b9f59d9
BLAKE2b-256 7926376e8427acd967a4e14a427c6332712e032895b55104ccbf51a5e3b8e6e4

See more details on using hashes here.

Provenance

The following attestation bundles were made for tree_sitter_hbk-0.1.11-cp310-abi3-macosx_11_0_arm64.whl:

Publisher: publish.yml on mussolene/tree-sitter-bsl

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.1.11 This release

6 files

0.1.10

6 files

0.1.8

1 file

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