- C 99.8%
| .forgejo/workflows | ||
| .github/workflows | ||
| ci | ||
| queries | ||
| src | ||
| test/corpus | ||
| .editorconfig | ||
| .gitignore | ||
| .gitlab-ci.yml | ||
| .prettierrc.yml | ||
| CLAUDE.md | ||
| CMakeLists.txt | ||
| grammar.js | ||
| LICENSE | ||
| package-lock.json | ||
| package.json | ||
| README.md | ||
| tree-sitter.json | ||
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
- Node.js >= 18
- tree-sitter CLI >= 0.25
- C compiler (gcc or clang)
- CMake >= 3.13
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
- Base grammar: tree-sitter-rpmspec by Andreas Schneider
- ALT Linux extensions: Alexey Shabalin