| Filename | Latest commit message | Latest commit date |
|---|---|---|
|
Some checks failed
wai-quantum editors / does this change touch it (push) Successful in 16s
wai-quantum contract / does this change touch it (push) Successful in 38s
wai-quantum editors / editors · macos (push) Successful in 1m28s
WAI breaking changes and the conformance runner / WAI breaking · does this change touch WAI (push) Successful in 11s
wai-quantum contract / the policy is linked, and the deprecations page reads (push) Successful in 6s
wai-quantum editors / editors · linux (push) Successful in 4m22s
wai-quantum contract / API compatibility · linux (push) Failing after 7m11s
wai-quantum contract / schemas and the committed tool lists · linux (push) Successful in 12m13s
WAI breaking changes and the conformance runner / WAI breaking · wire, record and API against main · linux (push) Successful in 50s
WAI breaking changes and the conformance runner / WAI breaking and conform · their tests, and the independent verifiers through wai conform · linux (push) Successful in 3m53s
repository checks / lockfiles, advisories, tests in CI, workflow hygiene, spec and section references, public text (push) Successful in 2m13s
The three headers in src/tree_sitter/ are tree-sitter's: parser.h is the library's own, alloc.h and array.h the generator's templates, all under its MIT licence, which asks that its notice go with every copy. That notice is now src/tree_sitter/LICENSE, byte for byte the LICENSE of tree-sitter 0.26.13, the version package.json pins. src/ is in the package's published files, so the notice ships with the headers, and the generator writes only the three headers, so regenerating leaves it in place. The README's row and the changelog entry name it. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
| .. | ||
| queries | ||
| script | ||
| src | ||
| test | ||
| .gitignore | ||
| grammar.js | ||
| package-lock.json | ||
| package.json | ||
| README.md | ||
| tree-sitter.json | ||
tree-sitter-openqasm
OpenQASM 3, and the OpenQASM 2 forms in common use, as a tree-sitter grammar:
for highlighting, folding and structural selection in any editor that reads
tree-sitter grammars. The language service (wai-quantum lsp) gives the
engine's diagnostics, completion, hover and renames; this grammar gives the
editor the program's structure as it is typed.
| Path | What it is |
|---|---|
grammar.js |
The grammar: every statement of OpenQASM 3.1 (declarations of every type, gates, subroutines, modifiers, control flow, timing, calibrations kept as text, pragmas, annotations) and OpenQASM 2's qreg, creg, opaque, measure q -> c and if(c==1) |
src/ |
The parser generated from it (ABI 14), committed so that an editor builds it with a C compiler alone. src/tree_sitter/ holds the headers the tree-sitter generator writes beside the parser, under that project's MIT licence, not this package's Apache-2.0; src/tree_sitter/LICENSE is that licence's notice, kept with the headers wherever they are copied |
queries/highlights.scm |
Highlighting, in the common capture names (@keyword, @type, @function, @number, …) |
queries/locals.scm |
Scopes, definitions and references |
queries/folds.scm |
Foldable blocks |
test/corpus/ |
The parse of every construct, checked tree for tree |
test/highlight/ |
Highlighting checked capture by capture |
script/check-programs.mjs |
Parses every program in the repository's conformance material and examples, and fails on any error |
The grammar reads what is written. It does not say what a program means: the engine's reader decides that, and the language server reports it.
Building and testing
With Node.js 22 and a C compiler:
npm ci # the pinned tree-sitter command line
npx tree-sitter generate --abi 14 # src/ from grammar.js
npx tree-sitter test # the corpus and the highlighting
node script/check-programs.mjs # every program in the repository
src/ must be regenerated and committed with any change to grammar.js; CI
regenerates it and fails if the committed parser differs.
Versions
The names of the grammar's nodes and fields are what queries name, so they are its public surface: one is renamed or removed only in a major release, as WAI Quantum's policy says, and listed in the deprecations at least one minor release before.
Using it in an editor
The editor configurations in ../wai-quantum-editor/editors/
point at this directory, and the editors guide
says how to install each.