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

Abierto
#24 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
Medio día
Aptitud para principiantes
55/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Tranquilo
Stack tecnológico
python
Área
compilers

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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 कार्य.

Lenguaje dominante
Python
Estrellas
1
Forks
4
Merge medio
12 d 21 h
PR fusionados (30 d)
1

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de alphacrack/python-maithili-dsl

Todos los issues de alphacrack/python-maithili-dsl

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.