[BUG] Tokenizer mishandles triple-quoted strings — keywords replaced inside them

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

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
Mezza giornata
Idoneità per principianti
55/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Tranquilla
Stack tecnologico
python
Ambito
compilers

Direzione di ricerca

The bug lives in _tokenize_preserving_strings in maithili_dsl/transpiler/transpile.py, which only matches single-line quoted strings and # comments. Reproduce by transpiling x = """क " में " ख""" and confirm में is replaced inside the literal. Extend the tokenizer regex to match triple-quoted strings ("""...""" and '''...''', spanning newlines) before the single-quote alternatives, then add tests for keywords inside triple quotes, inner quotes, and a multi-line docstring. Done when those cases pass unchanged and existing transpiler tests still pass.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

area:transpiler bug P2

File: maithili_dsl/transpiler/transpile.py (_tokenize_preserving_strings)

The tokenizer only knows single-line "..." / '...' strings and # comments. Triple-quoted strings are parsed as pairs of empty strings, so when the content itself contains a quote, part of the string body is treated as code and keywords inside it get replaced:

Input:  x = """क " में " ख"""
Output: x = """क " in " ख"""   # में replaced inside a string literal

(Verified against v0.3.0. Simple triple-quoted strings without inner quotes survive only by accident.)

Fix: extend the tokenizer regex to match """...""" and '''...''' (with re.DOTALL-style content) before the single-quote alternatives. Consider f-string prefixes (f"...") while in there.

Tests: triple-quoted string with keywords, with inner quotes, multi-line docstring on a कार्य.

Lingua principale
Python
Stelle
1
Fork
4
Merge medio
12g 21h
PR unite (30g)
1

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 alphacrack/python-maithili-dsl

Tutte le issue di alphacrack/python-maithili-dsl

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.