Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

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

Aperta
#196 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

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
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
python
Ambito
compilers

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

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

Lingua principale
Python
Stelle
29
Fork
33
Merge medio
2g 4h
PR unite (30g)
15

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di qBraid/pyqasm

Tutte le issue di qBraid/pyqasm

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.