srccontains the compiler, interpreter, qasm emitter, backends, and cliplaygroundcontains the browser playgroundexamplescontains runnable sample programstestscontains lexer, parser, typechecker, codegen, integration, and config testsscriptscontains local development entry points
the cli and playground both rely on the same core flow:
- the lexer tokenises utf-8 source text from
src/lexer - the parser in
src/parserbuilds the ast - the type checker in
src/typecheckervalidates declarations, gate arity, measurement rules, and run arguments - the interpreter in
src/interpreterexecutes programs locally against the statevector simulator - the qasm emitter in
src/codegenlowers the same ast to openqasm 2.0 - the backends in
src/backendseither execute locally or submit qasm jobs to ibm quantum
src/shared/compiler.ts
- owns the compile pipeline from source text to a checked ast
src/cli
- exposes
run,compile,viz, andauth - reads IBM credentials from the environment,
.env, or~/.ket/config
src/simulator
- provides complex numbers, gate matrices, statevector operations, and measurement helpers
playground/src
- runs the compiler in a worker and renders the editor, circuit view, qasm output, and results panels
- the interpreter and qasm emitter share the same parsed program representation
- source-level backend annotations such as
run bell() on ibmare preserved in the ast and honoured by the cli unless a command-line override is supplied - measured qubits are tracked so later quantum operations fail fast instead of silently mutating collapsed state