Investigate `lark` as an alternative to `antlr4-python3-runtime` in `openqasm3.parser`
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 12/100
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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
- Lingua principale
- Python
- Stelle
- 29
- Fork
- 33
- Merge medio
- 2g 4h
- PR unite (30g)
- 15
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di qBraid/pyqasm
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 63/100
I maintainer di solito rispondono entro 1 giorno
-
enhancement error-handling program-validation
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
I maintainer di solito rispondono entro 1 giorno
-
Move the QASM 2 printer and its branch pre-processing out of qasm2.pyForse già presa @danielgaskins l’ha presa 7 giorni fa. Apertaenhancement qasm2
Difficoltà 4/5 3-5 giorni Idoneità per principianti 22/100
qBraid/pyqasm#447 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
[BUG] dumps() emits extern calls without a semicolon, producing unparsable QASMForse già presa @Jah-yee l’ha presa 15 giorni fa. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 25/100
qBraid/pyqasm#438 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Parse failures raise ValidationError with an empty message; the ANTLR diagnostic is lostForse già presa @tonycoder-hub l’ha presa 9 giorni fa. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 22/100
qBraid/pyqasm#436 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di qBraid/pyqasm
Issue simili
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 80/100
521xueweihan/HelloGitHub#4063 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
Vanilla-OS/apx-gui#112 ·
-
Devstral and Voxtral: section 5 fails in us-east-1 with 400 "Model does not support audio modality"Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
aws-samples/sample-per-model-bedrock#409 ·
I maintainer di solito rispondono entro 1 giorno
-
DuckDB 2.0 breaks to_pyarrow_batchesForse già presa @DG47 l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
ibis-project/ibis#12196 ·
I maintainer di solito rispondono entro 1 giorno