Skip to content

Commit 96538e1

Browse files
committed
autotranslate/scratch: --list mode for the phase-1 inline gate
Optional `--list` flag prints the per-body phase-1 classification — each rewritten inline Scala-code env as `file:line (env) -> ok|skip` — so you can see exactly which sections compile after rename and which are skipped (compile in neither language = not standalone: neighbour context / signature-only / script style). Normal runs stay quiet. @main now takes varargs so `-- . --list` works in any order.
1 parent d7c6646 commit 96538e1

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

autotranslate/scratch/verify-mirror-examples.scala

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@
2727
// scala-cli run autotranslate/scratch/verify-mirror-examples.scala -- <introprog-root>
2828
// (exit 0 = clean, exit 1 = at least one regression or an untranslated ratified code-string)
2929

30-
@main def verifyMirrorExamples(rootStr: String): Unit =
30+
@main def verifyMirrorExamples(args: String*): Unit =
31+
val rootStr = args.find(a => !a.startsWith("--")).getOrElse(".")
32+
val listMode = args.contains("--list") // also print the per-body phase-1 classification (file:line (env))
33+
def lineOf(s: String, pos: Int): Int = s.substring(0, pos).count(_ == '\n') + 1
3134
val root = os.Path(rootStr, os.pwd)
3235
val dir = root / "compendium" / "examples" // workspace/ is served by the hand-maintained workspace-en
3336
val files =
@@ -89,6 +92,8 @@
8992
body.replaceFirst("(?s)\\A[ \\t]*\\[[^\\]]*\\]", "")
9093
var inChecked = 0; var inSkipped = 0; var replDeferred = 0; var nonCode = 0
9194
val inRegressions = collection.mutable.ArrayBuffer[String]()
95+
val inOk = collection.mutable.ArrayBuffer[String]() // file:line (env) of each OK body (for --list)
96+
val inSkip = collection.mutable.ArrayBuffer[String]() // file:line (env) of each skipped body (for --list)
9297
for f <- texFiles do
9398
val tex = os.read(f)
9499
val rel = f.relativeTo(root).toString
@@ -103,14 +108,19 @@
103108
if en != body then // only REWRITTEN bodies are gate-relevant
104109
if env.startsWith("REPL") then replDeferred += 1 // rewritten transcripts -> phase 2
105110
else if !phase1Envs(env) then nonCode += 1 // Trace/Output — not compilable Scala
106-
else if compiles(en, "Inline.scala") then inChecked += 1
111+
else if compiles(en, "Inline.scala") then { inChecked += 1; inOk += s"$rel:${lineOf(tex, m.start)} ($env)" }
107112
else if compiles(body, "Inline.scala") then
108113
inRegressions += s"$rel ($env)"
109114
println(s" INLINE REGRESSION: $rel ($env) — compiles in Swedish but NOT after rename")
110-
else inSkipped += 1
115+
else { inSkipped += 1; inSkip += s"$rel:${lineOf(tex, m.start)} ($env)" }
111116
println(s"\n=== inline .tex compile gate (phase 1): $inChecked ok, $inSkipped skipped (not standalone), " +
112117
s"$replDeferred REPL deferred to phase 2, $nonCode Trace/Output not gated, ${inRegressions.size} REGRESSIONS ===")
113118
if inRegressions.nonEmpty then println("FAIL — inline translation broke compilation in: " + inRegressions.mkString(", "))
114119
else println("PASS — every rewritten, self-contained inline Scala-code env still compiles.")
120+
if listMode then
121+
println(s"\n--- phase-1 OK (${inOk.size}) — rewritten inline envs that compile after rename ---")
122+
inOk.foreach(s => println(s" ok $s"))
123+
println(s"--- phase-1 SKIPPED (${inSkip.size}) — rewritten inline envs that compile in NEITHER language (not standalone) ---")
124+
inSkip.foreach(s => println(s" skip $s"))
115125

116126
if regressions.nonEmpty || leaks.nonEmpty || inRegressions.nonEmpty then sys.exit(1)

0 commit comments

Comments
 (0)