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

    Function parseFile

    • Parses OpenQASM code from a file and returns the abstract syntax tree.

      Parameters

      • file: string

        The path to the .qasm file to parse

      • Optionalversion: number | OpenQASMVersion

        The OpenQASM version to use (defaults to 3.0)

      • Optionalverbose: boolean

        Whether to include class names in the output (defaults to false)

      • Optionalstringify: boolean

        Whether to return stringified JSON (defaults to false)

      Returns any

      The corresponding AST as an array of nodes, or stringified JSON if stringify is true

      import { parseFile } from 'qasm-ts';

      // Parse OpenQASM 3.0 file
      const ast = parseFile('./my-circuit.qasm');

      // Parse OpenQASM 2.0 file
      const ast2 = parseFile('./legacy-circuit.qasm', 2);
      const ast = parseFile('./circuit.qasm', 3, true);
      // Includes detailed class information for each AST node