This project uses just as a command runner.
Install it first:
cargo install justRun:
just --listYou should see a list of available recipes (such as ci, sourcegen, check_sourcegen and others).
- All pull requests must pass CI before being merged.
- Please commit regenerated files when modifying grammar or code generation.
- Use the provided
justrecipes to ensure consistency.
Set the environment variable QASM3_PATH to the directory containing the QASM 3 example you are working on.
Alternatively, in the examples below, you can use the fully qualified path to example.qasm.
Use semdemo to see how the parser/analyzer handles your example in example.qasm.
You will usually be concerned with two data structures, which we call the AST and the ASG.
In order to test construction of the ASG, the AST must be constructed without errors.
Run
cargo run --color always --example semdemo -- parse example.qasmIf parsing was successful, you should see something like
Found 3 stmts
Found 0 parse errors:
[]
followed by a representation of the AST.
If running semdemo with the option parse as above prints no syntax errors, then
you can proceed to the ASG. Run
cargo run --color always --example semdemo -- semantic example.qasmIf there were in fact syntax errors in producing the AST, then this command will pretty-print those errors, but will not attempt to construct the ASG. Otherwise the ASG will be constructed, and any semantic errors found will be printed.
Important
All pull requests must pass CI. To run the full suite locally, use:
just ciDo not run
cargo testdirectly — always usejust cito match CI.
Note, the github pipeline also verifies that generated sources are up to date:
just check_sourcegenClippy is included in the just ci recipe. For manual inspection with paging:
cargo clippy --color always |& less -RAn "ungrammar" (and here) describes a concrete syntax tree.
An ungrammar for OpenQASM 3 is in ./crates/oq3_syntax/openqasm3.ungram. For most work, it need not be edited.
If the file is modified, run:
just sourcegenThis triggers the
build.rsscript inoq3_parserwith thesourcegenfeature.
The following three source files may be updated:
- ./crates/oq3_parser/src/syntax_kind/syntax_kind_enum.rs
- ./crates/oq3_syntax/src/ast/generated/nodes.rs
- ./crates/oq3_syntax/src/ast/generated/tokens.rs
Commit regenerated files along with your changes.
- Code must be formatted with
cargo fmt. - Lints must pass with
cargo clippy(warnings are treated as errors). - Avoid committing debug macros (
dbg!) — they are denied in CI.