npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

tree-sitter-bsl

v0.1.7

Published

1C (BSL) grammar for tree-sitter

Readme

tree-sitter-bsl

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:

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-bsl = "0.1"
use tree_sitter::Parser;

fn main() {
    let mut parser = Parser::new();
    parser
        .set_language(&tree_sitter_bsl::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-bsl tree-sitter
const Parser = require("tree-sitter");
const BSL = require("tree-sitter-bsl");

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

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

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

Python

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

pip install tree-sitter-bsl tree-sitter
import tree_sitter_bsl as tsbsl
from tree_sitter import Language, Parser

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

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

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

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

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

  • Node.js: require("tree-sitter-bsl").sdbl;
  • Rust: tree_sitter_bsl::SDBL_LANGUAGE;
  • Python: tree_sitter_bsl.SDBLLanguage() или низкоуровневая капсула tree_sitter_bsl.sdbl_language();
  • Go: tree_sitter_bsl.SDBLLanguage();
  • 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.

Ссылки