Investigate `lark` as an alternative to `antlr4-python3-runtime` in `openqasm3.parser`
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
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 の本文から書いたものです。
説明
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
- Fork the OpenQASM repository.
- Create a feature branch (e.g.,
lark-parser-prototype).
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
Transformerto 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
openqasm3if the maintainers are willing. If not, we can merge this as a parser component withinpyqasmitself.
References
- 主要言語
- Python
- スター
- 29
- フォーク
- 33
- 平均マージ
- 2日 4時間
- マージ済み PR(30日)
- 15
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
qBraid/pyqasm のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 63/100
メンテナーはふだん 1 日以内に返信
-
enhancement error-handling program-validation
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
メンテナーはふだん 1 日以内に返信
-
Move the QASM 2 printer and its branch pre-processing out of qasm2.py対応中かも @danielgaskins が 7 日前に担当しました。 オープンenhancement qasm2
難易度 4/5 3〜5日 初心者へのやさしさ 22/100
qBraid/pyqasm#447 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
[BUG] dumps() emits extern calls without a semicolon, producing unparsable QASM対応中かも @Jah-yee が 15 日前に担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 25/100
qBraid/pyqasm#438 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Parse failures raise ValidationError with an empty message; the ANTLR diagnostic is lost対応中かも @tonycoder-hub が 9 日前に担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 22/100
qBraid/pyqasm#436 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
似ている issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
ansys/pyansys-common-mcp#213 ·
メンテナーはふだん 3 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100
freedomofpress/dangerzone#1594 ·
メンテナーはふだん 3 日以内に返信
-
priority:P1 status:in-review type:bug
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
randomparity/kdive#3317 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
area:ci
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
mesonbuild/meson#16281 ·
メンテナーはふだん 1 日以内に返信