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

    Module Lexing

    Main lexer interface for tokenizing QASM code

    The lexer is responsible for breaking down QASM source code into tokens that can be consumed by the parser. It supports both OpenQASM 2.0 and 3.0 syntax, with version-specific lexers handling the differences in token types and syntax rules.

    The specific Lexer implementations can be found at:

    Source CodeLexerTokensParserAST
    "h q[0];" → [Id, Id, LSParen, NNInteger, RSParen, Semicolon]
    import { lex } from './lexer';

    const qasmCode = 'OPENQASM 3.0; qubit q; h q;';
    const tokens = lex(qasmCode);
    console.log(tokens);
    // [
    // [Token.OpenQASM, undefined],
    // [Token.Id, 'qubit'],
    // [Token.Id, 'q'],
    // [Token.Semicolon, undefined],
    // [Token.Id, 'h'],
    // [Token.Id, 'q'],
    // [Token.Semicolon, undefined]
    // ]

    Lexing

    lex