Skip to main content

Tree Sitter Grammar for ASN.1

This is a complete and working ASN.1 grammar for tree-sitter. It is based off of the BNF provided in the ITU-T Recommendations X.680 through X.683.

It fully supports parameterization, XML values, information objects, defined syntax, encoding control notation (ECN), etc.

The queries highlights.scm and folds.scm works with nvim-treesitter to provide highlighting and folding. Indents are currently experimental with nvim-treesitter, and didn't work quite right from my experience, and I don't think textobjects.scm is really used anywhere.

Building and testing

Install Node.js dependencies (this also compiles the Node addon):

npm install

After changing grammar.js (or src/scanner.c), regenerate the parser and rebuild the Node addon. tree-sitter test uses the CLI parser; the Node tests in bindings/node load build/Release/tree_sitter_asn1_binding.node, which is not updated by tree-sitter generate alone.

npx tree-sitter generate
npx node-gyp rebuild

There are three overlapping test entry points:

Command What it runs
npx tree-sitter test Corpus only: each example in test/corpus must parse to the expected syntax tree.
make test Corpus, then tree-sitter parse --quiet --stat on every test/asn1/*.asn1 and *.asn file (must parse with no errors; trees are not checked). Uses tree-sitter from PATH, or TS=....
npm test Corpus, then the Node tests in bindings/node/*_test.js: load the native addon, a few CST assertions, and the same test/asn1 fixtures parsed through Node.

make test and npx tree-sitter test both use the CLI parser. npm test uses that CLI for the corpus, then the Node addon for everything else, so regenerate and npx node-gyp rebuild after grammar changes before relying on npm test.

CMake’s ts-test target matches make test. Other language bindings have their own tests (cargo test, go test, and so on).

The playground is npm start (tree-sitter build --wasm then tree-sitter playground).

Why did you have to include an external parser?

This custom parser exists to deal with a very specific issue. If the AssignedIdentifier is not used in the GlobalModuleReference production, and the GlobalModuleReference production is followed by another SymbolsFromModule production that starts with an imported symbol that starts with a lowercased letter, said symbol may be interpreted as the DefinedValue alternative of the AssignedIdentifier production. Then the parser would read a comma or FROM after the symbol and fail, because it expected another symbol.

The solution to this is to read ahead and check if the next non-whitespace token is a comma or FROM. If either of these cases are true, we know that we just read a symbol from the subsequent SymbolsFromModule production rather than a DefinedValue for the AssignedIdentifier production.

Publishing to Various Package Repositories

  • Maven Central (I would have to create the bindings myself, and I have not used Java in 10 years.)
  • jsr.io The NodeJS bindings currently use CommonJS, but JSR requires ESM.

Metadata

Release files for tree-sitter-asn1 1.0.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-asn1 1.0.0
File Size Uploaded
tree_sitter_asn1-1.0.0.tar.gz 205.8 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for tree-sitter-asn1 1.0.0
File
tree_sitter_asn1-1.0.0-cp310-abi3-win_arm64.whl CPython 3.10 abi3 Windows ARM64 Details
tree_sitter_asn1-1.0.0-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details
tree_sitter_asn1-1.0.0-cp310-abi3-musllinux_1_2_x86_64.whl CPython 3.10 abi3 Linux musl 1.2+ x86-64 Details
tree_sitter_asn1-1.0.0-cp310-abi3-musllinux_1_2_aarch64.whl CPython 3.10 abi3 Linux musl 1.2+ ARM64 Details
tree_sitter_asn1-1.0.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
tree_sitter_asn1-1.0.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
tree_sitter_asn1-1.0.0-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details
tree_sitter_asn1-1.0.0-cp310-abi3-macosx_10_9_x86_64.whl CPython 3.10 abi3 macOS 10.9+ x86-64 Details

Total release size: 1.2 MB

Release files / tree_sitter_asn1-1.0.0.tar.gz

Download URL tree_sitter_asn1-1.0.0.tar.gz
Size 205.8 kB
Tags Source
SHA-256 checksum
How to use checksums
67e83da4537fe4ea536e464256d483d1e3fe2200e93dc9c283bf41a58374ba98
BLAKE2b-256 checksum
How to use checksums
4ab03b6c3336c222de706563479094005811601b984d06be047c2a2ebe5a82ff
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 7, 2026.

Transparency log

Release files / tree_sitter_asn1-1.0.0-cp310-abi3-win_arm64.whl

Download URL tree_sitter_asn1-1.0.0-cp310-abi3-win_arm64.whl
Size 109.2 kB
Tags CPython 3.10 Windows ARM64 abi3
SHA-256 checksum
How to use checksums
3e84c5c4feb63c8b54c011b7c26cb7c432f89738a63685cec0abdde89dfa268e
BLAKE2b-256 checksum
How to use checksums
79c70995f6c28735b6ae9b12f1989582eea59ce21b40b3b7859b9d8c2b620434
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 7, 2026.

Transparency log

Release files / tree_sitter_asn1-1.0.0-cp310-abi3-win_amd64.whl

Download URL tree_sitter_asn1-1.0.0-cp310-abi3-win_amd64.whl
Size 111.8 kB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
265cc8890c671c2ef5a61286f378e202c2f103be12190511bfb0873bbc703565
BLAKE2b-256 checksum
How to use checksums
d3b82a164d905475541923b5d30e92bc29abad6b03f961b9936a77cf455a51c7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 7, 2026.

Transparency log

Release files / tree_sitter_asn1-1.0.0-cp310-abi3-musllinux_1_2_x86_64.whl

Download URL tree_sitter_asn1-1.0.0-cp310-abi3-musllinux_1_2_x86_64.whl
Size 130.2 kB
Tags CPython 3.10 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
89589e11afbeffedbade2a5f1f3c494832d2f909aed7a51a2ba3f7c982496350
BLAKE2b-256 checksum
How to use checksums
f1338e2dc310ecaad5ff6211afa8e84603923192484c77f92b3aad99b692c616
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 7, 2026.

Transparency log

Release files / tree_sitter_asn1-1.0.0-cp310-abi3-musllinux_1_2_aarch64.whl

Download URL tree_sitter_asn1-1.0.0-cp310-abi3-musllinux_1_2_aarch64.whl
Size 127.8 kB
Tags CPython 3.10 Linux musl 1.2+ ARM64 abi3
SHA-256 checksum
How to use checksums
d5393f33289ac2bb1176dbd420e47e976097d6f7966963bda09d208aaaa3f3bf
BLAKE2b-256 checksum
How to use checksums
64883f831940232d30808c6d6f8ea8b5ea95e1f32bb3f753c1d9f98622fb9035
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 7, 2026.

Transparency log

Release files / tree_sitter_asn1-1.0.0-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl

Download URL tree_sitter_asn1-1.0.0-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Size 128.8 kB
Tags CPython 3.10 Linux glibc 2.17+ ARM64 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
c644390cfcdb9134c811d7d89a8ba094e070ce13effc17cf3fd2b5615b0015b9
BLAKE2b-256 checksum
How to use checksums
c2e536c39aa2cb487899ff851cfac65468f7586376506d256e68e5ac6d828dda
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 7, 2026.

Transparency log

Release files / tree_sitter_asn1-1.0.0-cp310-abi3-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl

Download URL tree_sitter_asn1-1.0.0-cp310-abi3-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Size 130.9 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
36a77b0e875760cfba30e9f5c7d7f6417e24fc710468dcbff7237ae04fd03dbf
BLAKE2b-256 checksum
How to use checksums
12a6f60159901f208c45eaf013a5b37e3ccea51ee8ebba26fffd83b50c3d04d6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 7, 2026.

Transparency log

Release files / tree_sitter_asn1-1.0.0-cp310-abi3-macosx_11_0_arm64.whl

Download URL tree_sitter_asn1-1.0.0-cp310-abi3-macosx_11_0_arm64.whl
Size 114.7 kB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
946de9951f81cba19ad5aa85ede49f3c20e73ad531e8c7061e9c4e5e3a588187
BLAKE2b-256 checksum
How to use checksums
5b8cd0345b0a8c4a50231a43aeae6bf19f1561a867c858e9cabfef1f8d2bb1ab
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 7, 2026.

Transparency log

Release files / tree_sitter_asn1-1.0.0-cp310-abi3-macosx_10_9_x86_64.whl

Download URL tree_sitter_asn1-1.0.0-cp310-abi3-macosx_10_9_x86_64.whl
Size 107.8 kB
Tags CPython 3.10 abi3 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
fa7ca1ffb1e772e4c0d849ffac47022e16dad40b9f270fef61a4c4572c06b6fe
BLAKE2b-256 checksum
How to use checksums
75b36fc52535924d691c664556073bd33da5a9a3052fb6894bf50c354d3d8704
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 7, 2026.

Transparency log

Release history Release notifications | RSS feed

1.0.4

9 release files

1.0.3

9 release files

1.0.2

9 release files

1.0.1

9 release files

This release

1.0.0 This release

9 release files

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