Skip to main content

tree-sitter-mib

CI

A tree-sitter grammar for SNMP MIB modules: the ASN.1 subset defined by the Structure of Management Information.

Covers RFCs
SMIv1 modules, OBJECT-TYPE, TRAP-TYPE 1155, 1212, 1215
SMIv2 MODULE-IDENTITY, OBJECT-IDENTITY, OBJECT-TYPE, NOTIFICATION-TYPE 2578
TEXTUAL-CONVENTION 2579
OBJECT-GROUP, NOTIFICATION-GROUP, MODULE-COMPLIANCE, AGENT-CAPABILITIES 2580
ASN.1 types (SEQUENCE, SEQUENCE OF, CHOICE, tagged [APPLICATION n] IMPLICIT), size/range constraints, MACRO definitions X.208 subset

Real-world coverage

The parser was run against three collections of MIBs:

Corpus Files Parsed without errors
net-snmp standard MIBs (/usr/share/snmp/mibs) 63 100%
VMware / IBM vendor MIBs 13 100%
netdisco-mibs (≈200 vendors) 4,849 99.77%

The 11 netdisco files that do not parse are malformed. They are listed, with the reason for each, in test/corpus-known-failures.txt. CI re-parses the whole collection on every change and fails on any new failure.

Being forgiving

The grammar aims to give a useful tree for the MIBs people actually have, rather than to validate them (use smilint for that). Specifically, it accepts:

  • clauses of a macro invocation in any order;
  • missing or trailing commas in IMPORTS, enumerations, SEQUENCE bodies and object lists;
  • object names with an upper-case initial (TrafficShield4100 OBJECT IDENTIFIER ::= …), which appear as ordinary identifier nodes;
  • type names with a lower-case initial (fooEntry ::= SEQUENCE …, SYNTAX SEQUENCE OF fooEntry);
  • enumeration labels that start with a digit (10mbitHalfDuplex(2));
  • identifiers as range bounds (Unsigned32 (1..maxGroups)).

Known simplifications:

  • A comment runs from -- to the end of the line. Strict ASN.1 also lets a second -- close a comment mid-line, but MIBs routinely draw lines of dashes and almost nothing relies on the strict rule, so this grammar follows what net-snmp does in practice.
  • The body of a MACRO ::= BEGIN … END definition (found only in the SMI base modules) is kept as a flat macro_body token stream.
  • A DEFVAL { … } holding a BITS set or an OID becomes a single braced_value node, because { a } can mean either.

Tree shape

ifIndex OBJECT-TYPE
    SYNTAX      InterfaceIndex
    MAX-ACCESS  read-only
    STATUS      current
    DESCRIPTION "A unique value for each interface."
    ::= { ifEntry 1 }
(object_type
  name: (identifier)
  (syntax_clause type: (defined_type name: (type_reference)))
  (access_clause value: (access))
  (status_clause value: (status))
  (description_clause value: (string))
  value: (object_identifier_value (identifier) (number)))

Using it from Python

pip install "tree-sitter-mib[core]"   # "core" pulls in the tree-sitter runtime
import tree_sitter_mib
from tree_sitter import Language, Parser, Query, QueryCursor

language = Language(tree_sitter_mib.language())
parser = Parser(language)
tree = parser.parse(open("IF-MIB.txt", "rb").read())

# Every object, notification, group, ... that is assigned an OID
tags = Query(language, tree_sitter_mib.TAGS_QUERY)
for node in QueryCursor(tags).captures(tree.root_node).get("name", []):
    print(node.text.decode())

tree_sitter_mib.HIGHLIGHTS_QUERY holds the highlighting query.

Queries

  • queries/highlights.scm: syntax highlighting. Generic captures come first and specific ones later, because later patterns win in both the tree-sitter CLI and Neovim.
  • queries/tags.scm: definitions (definition.module, definition.constant for anything assigned an OID, definition.type, definition.macro) and references, for code navigation.
  • queries/folds.scm: folding for macro invocations, imports and type bodies.

Development

The tree-sitter CLI is pinned to an exact version as tree-sitter-cli in package.json, and CI and the release workflow install that same version. CI fails if src/ differs from what it generates, so use the pinned CLI through npx rather than a globally installed one:

npm install
npx tree-sitter generate      # regenerate src/ after editing grammar.js
npx tree-sitter test          # corpus, highlight and tag tests
npx tree-sitter parse -q -s path/to/*.mib

# Re-run the real-world corpus check that CI runs
git clone https://github.com/netdisco/netdisco-mibs /tmp/netdisco-mibs
PATH="$PWD/node_modules/.bin:$PATH" scripts/check-corpus.sh /tmp/netdisco-mibs

To move to a newer CLI, change the pinned version in package.json, run npm install and npx tree-sitter generate, and commit the result.

The grammar is in grammar.js, the tests are in test/corpus, test/highlight and test/tags, and examples/ holds a sample module.

Bindings for C, Node, Python and Rust were generated by tree-sitter init. Everything is configured in tree-sitter.json.

CI and releases

  • CI (.github/workflows/ci.yml) runs on pushes to main and on pull requests, on Linux, macOS and Windows. It checks that src/ is up to date, runs tree-sitter test, tests the Rust, Node and Python bindings, and re-parses the netdisco-mibs corpus. It also builds the same Python sdist and wheels a release would upload (six platforms, each wheel installed and tested), without publishing them.

  • Release (.github/workflows/release.yml) runs when a release is published on GitHub (Releases → Draft a new release, choose a tag such as v0.2.0, then Publish release). The tag is the version: the package manifests in the repository stay at a 0.0.0 placeholder, and each release job writes the tag's version into them before building. Nothing needs to be bumped or committed beforehand.

    Every release gets a Wasm build and a complete source tarball attached, with build-provenance attestations. Publishing to package registries is opt-in per registry, and releases marked as a pre-release are never published to them. Tags must look like v1.2.3.

    Registry Turn on Credentials
    PyPI variable PUBLISH_PYPI=true none: Trusted Publishing with workflow release.yml and environment pypi
    npm variable PUBLISH_NPM=true secret NPM_TOKEN
    crates.io variable PUBLISH_CRATES=true secret CARGO_REGISTRY_TOKEN

License

MIT

Metadata

Release files for tree-sitter-mib 0.3.0

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-mib 0.3.0
File Size Uploaded Provenance Actions
tree_sitter_mib-0.3.0.tar.gz 58.9 kB With provenance Details for tree_sitter_mib-0.3.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for tree-sitter-mib 0.3.0
File Actions
tree_sitter_mib-0.3.0-cp310-abi3-win_arm64.whl CPython 3.10 abi3 Windows ARM64 Details for tree_sitter_mib-0.3.0-cp310-abi3-win_arm64.whl
tree_sitter_mib-0.3.0-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details for tree_sitter_mib-0.3.0-cp310-abi3-win_amd64.whl
tree_sitter_mib-0.3.0-cp310-abi3-musllinux_1_2_x86_64.whl CPython 3.10 abi3 Linux musl 1.2+ x86-64 Details for tree_sitter_mib-0.3.0-cp310-abi3-musllinux_1_2_x86_64.whl
tree_sitter_mib-0.3.0-cp310-abi3-musllinux_1_2_aarch64.whl CPython 3.10 abi3 Linux musl 1.2+ ARM64 Details for tree_sitter_mib-0.3.0-cp310-abi3-musllinux_1_2_aarch64.whl
tree_sitter_mib-0.3.0-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl CPython 3.10 abi3 Linux glibc 2.17+ ARM64, Linux glibc 2.28+ ARM64 Details for tree_sitter_mib-0.3.0-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
tree_sitter_mib-0.3.0-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_mib-0.3.0-cp310-abi3-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
tree_sitter_mib-0.3.0-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details for tree_sitter_mib-0.3.0-cp310-abi3-macosx_11_0_arm64.whl
tree_sitter_mib-0.3.0-cp310-abi3-macosx_10_9_x86_64.whl CPython 3.10 abi3 macOS 10.9+ x86-64 Details for tree_sitter_mib-0.3.0-cp310-abi3-macosx_10_9_x86_64.whl

Total release size: 429.5 kB

Release files / tree_sitter_mib-0.3.0.tar.gz

Download URL tree_sitter_mib-0.3.0.tar.gz
Size 58.9 kB
Tags Source
SHA-256 checksum
How to use checksums
e6d31937e7110d63d4ed89ecda2e1a8dacb322cfdd1c7d042161ab0dfd053111
BLAKE2b-256 checksum
How to use checksums
64db56b67ac3371a06e6a84b15257eaf2ffb6d68be5b1289503a896a766bf9b3
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 27, 2026.

Transparency log

Release files / tree_sitter_mib-0.3.0-cp310-abi3-win_arm64.whl

Download URL tree_sitter_mib-0.3.0-cp310-abi3-win_arm64.whl
Size 42.8 kB
Tags CPython 3.10 Windows ARM64 abi3
SHA-256 checksum
How to use checksums
3ff245cf1c4f3e872c115e1fc6424bdf100e99b46c3d87f1961bcce19c45e5c7
BLAKE2b-256 checksum
How to use checksums
3ceaeedf656eae9b4113b6e52fa6b6ee17bc7405a23eb5135f2223e228a7dee6
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 27, 2026.

Transparency log

Release files / tree_sitter_mib-0.3.0-cp310-abi3-win_amd64.whl

Download URL tree_sitter_mib-0.3.0-cp310-abi3-win_amd64.whl
Size 43.5 kB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
2c147f847090a11f390cc6679d3e1e88831d790b4a70579bb421eb8dc108141e
BLAKE2b-256 checksum
How to use checksums
0be96a593cb9b29b0a992d6ff12d4bb2d0d4db56aab51b32e011773456cda5f3
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 27, 2026.

Transparency log

Release files / tree_sitter_mib-0.3.0-cp310-abi3-musllinux_1_2_x86_64.whl

Download URL tree_sitter_mib-0.3.0-cp310-abi3-musllinux_1_2_x86_64.whl
Size 50.3 kB
Tags CPython 3.10 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
d7e3985b6e3da6899dfd79ad80fa7af90c72151ae0ec2aba934abf194401ca1a
BLAKE2b-256 checksum
How to use checksums
6aa2af5c6c93cb46f98d3af9757a9a2593697600314b559425db42502094c32d
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 27, 2026.

Transparency log

Release files / tree_sitter_mib-0.3.0-cp310-abi3-musllinux_1_2_aarch64.whl

Download URL tree_sitter_mib-0.3.0-cp310-abi3-musllinux_1_2_aarch64.whl
Size 50.3 kB
Tags CPython 3.10 Linux musl 1.2+ ARM64 abi3
SHA-256 checksum
How to use checksums
2e7cef0ad4701f42f90fbf3479f04e6b8057f0170cf0deb4890f4456e831e461
BLAKE2b-256 checksum
How to use checksums
7161c6904ac8709a87d54391a7bd6b4e63e10d0b5478e02b129cfb0c7640ccd8
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 27, 2026.

Transparency log

Release files / tree_sitter_mib-0.3.0-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl

Download URL tree_sitter_mib-0.3.0-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Size 50.8 kB
Tags CPython 3.10 Linux glibc 2.17+ ARM64 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
02c47e2f1cb0f9e0d7dc4d926d54db2019e6079f81153d28f052e93fe7ee966f
BLAKE2b-256 checksum
How to use checksums
10da2c99155dd004d75f18acbb01b58e2a0ecf1fcfbdf20b6a7bdfc417a73134
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 27, 2026.

Transparency log

Release files / tree_sitter_mib-0.3.0-cp310-abi3-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl

Download URL tree_sitter_mib-0.3.0-cp310-abi3-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Size 50.3 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
5e6d2af39a1b352659624f347974b1ed2b43603a1129b88524d44fc0de8e9e4b
BLAKE2b-256 checksum
How to use checksums
e6624d73ab2bcfefbaf89f5514bb3b9a26a9cb1ec6dff77ef060218a83b21b44
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 27, 2026.

Transparency log

Release files / tree_sitter_mib-0.3.0-cp310-abi3-macosx_11_0_arm64.whl

Download URL tree_sitter_mib-0.3.0-cp310-abi3-macosx_11_0_arm64.whl
Size 42.2 kB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
3a7488323de8e0e535eb9ba9ade66cbd7ae0562ed88ba1fe619fe6aeac7377d4
BLAKE2b-256 checksum
How to use checksums
9366672d2c2ccc3826ff1446c8552c66045097ff540950e0f31901b462890861
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 27, 2026.

Transparency log

Release files / tree_sitter_mib-0.3.0-cp310-abi3-macosx_10_9_x86_64.whl

Download URL tree_sitter_mib-0.3.0-cp310-abi3-macosx_10_9_x86_64.whl
Size 40.4 kB
Tags CPython 3.10 abi3 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
3155015694c42b0fe16d7c2fba632e6350128d114c1356e225051302747088de
BLAKE2b-256 checksum
How to use checksums
aaad55c221c79ce63fc3435056345c51edb4f6592149d7677538cb19d92fb660
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 27, 2026.

Transparency log

Security for tree-sitter-mib 0.3.0

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

Select from 9 files

Attestation for tree_sitter_mib-0.3.0.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 27, 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.

Release history Release notifications | RSS feed

This release

0.3.0 This release

9 release files Full provenance

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