feat(charka): INSPECT — contar y reemplazar caracteres

El verbo de COBOL para analizar y limpiar campos de texto.

- IR: Stmt::Inspect { target, op } con InspectOp::TallyingForAll
  (cuenta apariciones y las suma a un contador) y
  InspectOp::ReplacingAll (reemplaza apariciones).
- Parser: INSPECT t TALLYING n FOR ALL lit y
  INSPECT t REPLACING ALL a BY b. Una forma no soportada cae a
  Stmt::Unknown.
- Codegen: TALLYING -> str::matches(..).count(); REPLACING ->
  str::replace.
- Shadow: el intérprete cuenta / reemplaza el texto.
- Corpus: programa nuevo 13-inspeccion. Verificado: el intérprete
  sombra y el crate compilado por scaffold dan la misma salida.

Alcance v1: TALLYING FOR ALL y REPLACING ALL; sin LEADING, FIRST,
CHARACTERS, BEFORE/AFTER.

Tests: charka-ir 26, charka-codegen 20, charka-shadow 18. fmt +
clippy limpios.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
sergio
2026-05-21 22:17:47 +00:00
parent 47c49acd47
commit 2728698f5e
13 changed files with 205 additions and 18 deletions
+2 -2
View File
@@ -290,13 +290,13 @@ mod tests {
let ir = ir_of(
"PROCEDURE DIVISION.\n\
MAIN.\n\
INSPECT WS-X TALLYING WS-N FOR ALL ' '.\n",
INITIALIZE WS-X.\n",
);
let mut verbs = Vec::new();
for proc in &ir.procedures {
collect_unknowns(&proc.body, &mut verbs);
}
assert_eq!(verbs, vec!["INSPECT".to_string()]);
assert_eq!(verbs, vec!["INITIALIZE".to_string()]);
}
#[test]