feat(charka): PERFORM VARYING — el bucle con variable de control

El bucle más usado de COBOL, que antes el parser degradaba a un
PERFORM vacío (un hueco de corrección real). Ahora atraviesa el
pipeline entero como una rebanada vertical.

- IR: PerformControl::Varying { var, from, by, until }.
- Parser: reconoce PERFORM VARYING var FROM x BY y UNTIL cond en
  línea (END-PERFORM) y fuera de línea (PERFORM párrafo VARYING ...).
- Codegen: emite var = from; while !(until) { cuerpo; var += by; }.
- Shadow: el intérprete inicializa la variable, evalúa la condición
  antes de cada vuelta e incrementa al final.
- Corpus: programa nuevo 08-varying (suma 1..10). Verificado: el
  intérprete sombra y el crate compilado por scaffold dan ambos
  SUMA 1 A 10 = 00055 — las dos rutas concuerdan.

Tests: charka-ir 18, charka-codegen 15, charka-shadow 13. fmt +
clippy limpios.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
sergio
2026-05-21 21:33:14 +00:00
parent b052c41e3c
commit 321e6f8e27
12 changed files with 177 additions and 7 deletions
@@ -197,4 +197,13 @@ pub enum PerformControl {
Times(Operand),
/// `UNTIL cond`.
Until(Cond),
/// `VARYING var FROM from BY by UNTIL until` — el bucle con
/// variable de control: `var = from`; mientras no se cumpla
/// `until`, ejecuta el cuerpo y hace `var = var + by`.
Varying {
var: String,
from: Operand,
by: Operand,
until: Cond,
},
}