Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Investigate `lark` as an alternative to `antlr4-python3-runtime` in `openqasm3.parser`

未关闭
#196 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
12/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
停滞
技术栈
python
领域
compilers

调研方向

The work centers on parser.py in the OpenQASM3 repository, where the current ANTLR-based parser lives, and the target is a Lark grammar covering a small subset of statements and gate definitions. Start by mapping the parser's entry points and how it emits AST nodes, then sketch the Lark grammar and a Transformer. Done means a prototype that yields identical objects and error messages on sample files, plus a written benchmark against the original parser.

由索引模型根据 Issue 内容生成。

描述

enhancement optimization

Background

The current OpenQASM3 parser is a known performance bottleneck, especially for large or complex QASM files. Rather than a full migration, this issue proposes a focused experiment: fork the repo, implement a Lark-based parser in parser.py for a subset of the grammar, and evaluate feasibility, performance, and compatibility.

Goals

  • Evaluate if Lark can serve as a drop-in replacement for the current parser logic.
  • Maintain API and object compatibility with existing code.
  • Benchmark correctness and performance on OpenQASM3 files.

Proposed Steps

1. Fork and Prepare
2. Analyze parser.py
  • Identify key functions/classes responsible for:
    • Parsing input strings/files
    • Emitting AST or domain objects
    • Error handling and reporting
3. Develop Lark Grammar
  • Extract a minimal but representative subset of the OpenQASM3 grammar (e.g., statements, declarations, a few gate definitions).
  • Write the equivalent Lark EBNF grammar.
4. Implement Lark Parser
  • In parser.py, add a new parser class or function using Lark.
  • Use a Transformer to convert the Lark parse tree into the same AST or objects as the current parser.
  • Add a feature flag or environment variable to switch between the old and new parsers for testing.
5. Ensure API Compatibility
  • Match all public methods, return types, and error messages to the existing API.
  • Write or adapt unit tests to verify that the Lark-based parser produces identical results.
6. Benchmark and Report
  • Compare parsing speed and memory usage between the original and Lark-based parser.
  • Document any edge cases, limitations, or incompatibilities encountered.
7. Share Findings
  • Summarize results in a markdown file or GitHub issue.
  • If successful, outline next steps for incremental migration.
  • Eventually, we want this change to be merged upstream into openqasm3 if the maintainers are willing. If not, we can merge this as a parser component within pyqasm itself.

References

主要语言
Python
星标
29
派生
33
平均合并
2 天 4 小时
30 天内合并 PR
15

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

qBraid/pyqasm 的其他 Issue

查看 qBraid/pyqasm 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。