qasm-ts - v2.0.0
    Preparing search index...

    Module qasm3/parser

    OpenQASM 3.0 Parser Implementation

    This module implements a recursive descent parser for OpenQASM 3.0 that transforms a stream of tokens into an Abstract Syntax Tree (AST). The parser handles the full OpenQASM 3.0 language specification including classical programming constructs, control flow, quantum operations, and advanced features.

    Key parsing capabilities:

    • Classical types: int, uint, float, bool, bit, complex, angle
    • Control flow: if/else, for/while loops, switch/case statements
    • Functions: def, return, extern declarations, subroutine calls
    • Quantum operations: gate definitions/calls, measurements, barriers, delays
    • Advanced features: arrays, timing constructs, calibration grammar
    • Expressions: Arithmetic, logical, function calls with proper precedence

    The parser maintains context about:

    • Defined gates (built-in, standard library, custom)
    • Declared subroutines and external functions
    • Array declarations and aliases
    • Type information for validation
    const tokens = lexer.lex();
    const parser = new Parser(tokens);
    const ast = parser.parse();

    Classes

    default