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
@@ -265,6 +265,28 @@ impl<'a> Machine<'a> {
return Flow::Stop;
}
},
PerformControl::Varying {
var,
from,
by,
until,
} => {
let start = self.eval_decimal(from);
self.store(var, start, false);
loop {
if self.tick() {
return Flow::Stop;
}
if self.eval_cond(until) {
return Flow::Normal;
}
if let Flow::Stop = self.run_target(&p.target) {
return Flow::Stop;
}
let next = self.field_value(var).add(&self.eval_decimal(by));
self.store(var, next, false);
}
}
}
}