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

    Module qasm2/lexer

    OpenQASM 2.0 Lexical Analyzer

    This module implements the lexer for OpenQASM 2.0, which provides a simpler token set compared to OpenQASM 3.0. The lexer focuses on basic quantum circuit constructs without the advanced classical programming features of version 3.0.

    Key characteristics of OpenQASM 2.0 lexing:

    • Limited token set: Basic quantum and classical registers only
    • Simple operators: Basic arithmetic and comparison operators
    • No control flow: No tokens for loops, conditionals, or functions
    • Gate-focused: Emphasis on gate definitions and applications
    • Mathematical functions: Built-in math functions (sin, cos, etc.)

    Supported constructs:

    • Quantum registers (qreg) and classical registers (creg)
    • Gate definitions and applications
    • Measurements with arrow notation (->)
    • Basic arithmetic expressions for gate parameters
    • Include statements for library files
    const lexer = new Lexer('qreg q[2]; h q[0]; measure q -> c;');
    const tokens = lexer.lex();
    // Produces tokens for register declaration, gate, and measurement

    Classes

    default