ALT Linux dialect of the RPM spec grammar for tree-sitter. Extends tree-sitter-rpmspec with ALT Linux-specific features (BuildRequires(pre), etc.)
Find a file
2026-02-22 14:56:39 +03:00
.forgejo/workflows ci(forgejo): use system tree-sitter with npm --ignore-scripts 2026-02-22 01:15:55 +03:00
.github/workflows ci: add prettier format check to gitlab, github, and forgejo 2026-02-22 00:01:43 +03:00
ci ci(gitlab): add test pipeline with parser consistency checks 2026-02-18 03:42:12 +03:00
queries fix(changelog): avoid partial hash refs in suffixed # tokens 2026-02-21 23:56:58 +03:00
src fix(changelog): avoid partial hash refs in suffixed # tokens 2026-02-21 23:56:58 +03:00
test/corpus fix(changelog): avoid partial hash refs in suffixed # tokens 2026-02-21 23:56:58 +03:00
.editorconfig feat: initial tree-sitter-rpmspec-altlinux grammar 2026-02-13 20:04:10 +03:00
.gitignore feat: initial tree-sitter-rpmspec-altlinux grammar 2026-02-13 20:04:10 +03:00
.gitlab-ci.yml ci: add prettier format check to gitlab, github, and forgejo 2026-02-22 00:01:43 +03:00
.prettierrc.yml feat: initial tree-sitter-rpmspec-altlinux grammar 2026-02-13 20:04:10 +03:00
CLAUDE.md feat: initial tree-sitter-rpmspec-altlinux grammar 2026-02-13 20:04:10 +03:00
CMakeLists.txt chore: update project repository URLs to altlinux.space 2026-02-22 14:56:39 +03:00
grammar.js fix(ci): robust base-grammar fallback for forgejo ignore-scripts setup 2026-02-22 01:15:55 +03:00
LICENSE feat: initial tree-sitter-rpmspec-altlinux grammar 2026-02-13 20:04:10 +03:00
package-lock.json build(deps): switch tree-sitter-rpmspec devDependency to gitlab 2026-02-21 01:06:51 +03:00
package.json build(deps): switch tree-sitter-rpmspec devDependency to gitlab 2026-02-21 01:06:51 +03:00
README.md feat: initial tree-sitter-rpmspec-altlinux grammar 2026-02-13 20:04:10 +03:00
tree-sitter.json chore: update project repository URLs to altlinux.space 2026-02-22 14:56:39 +03:00

tree-sitter-rpmspec-altlinux

A tree-sitter grammar for ALT Linux RPM spec files. This grammar extends tree-sitter-rpmspec with ALT Linux-specific features that are not part of the rpm.org specification.

ALT Linux Extensions

BuildRequires(pre)

ALT Linux supports a (pre) qualifier on BuildRequires to declare packages needed for building the source RPM (.src.rpm), as opposed to full build dependencies. Typically these are RPM macro packages:

BuildRequires(pre): rpm-macros-cmake
BuildRequires(pre): rpm-macros-systemd
BuildRequires: cmake gcc-c++ systemd-devel

This is equivalent to the deprecated BuildPreReq tag but with explicit qualifier syntax. Standard RPM (rpm.org, RPM 6.x) does not support this tag and will reject it.

Planned Extensions

  • %if_enabled / %if_disabled — ALT Linux conditional macros

How It Works

This grammar uses tree-sitter's grammar inheritance mechanism — the same approach used by tree-sitter-cpp (extends tree-sitter-c) and tree-sitter-typescript (extends tree-sitter-javascript).

The grammar.js imports the base tree-sitter-rpmspec grammar and overrides only the rules that differ in ALT Linux:

const rpmspec = require('tree-sitter-rpmspec/rpmspec/grammar');

module.exports = grammar(rpmspec, {
    name: 'rpmspec_altlinux',
    rules: {
        _requires_tag: ($) => choice(
            // ... base rules plus ALT Linux extensions
        ),
    },
});

Development

Prerequisites

Setup

npm install

Building

# Regenerate the parser
tree-sitter generate

# Build the native library
cmake -B build
cmake --build build

Testing

# Run all tests
tree-sitter test

# Run specific tests
tree-sitter test -i "ALT Linux"

Code Quality

prettier -w grammar.js

License

MIT — see LICENSE.

Credits