refactor(855-E 2-E1): M01 화면 옛 시험 계산 · 옛 상세 몸 부품 걷음

- 지움(부르는 곳 0 — 저장소 TS · cjs · py · html 다시 찾음): UI_Logic_Drive.ts(driveRun · autoFill) · UI_Logic_CalcPick.ts · UI_LogicLab_Pill.ts · .css
- Logic_Api: runCalc · runText · fetchAuto · searchPrice · CalcAnswer · TextAnswer · TextLine · TextPiece 걷음
- LogicLab_Modal: 옛 재료 · 표 · 참조 · 글 모달 걷음 — 로직 열기 · headWord 만 남김(−550 줄)
- Logic_Note.explain · Side.hasMasterJump · 죽은 CSS 다섯 · 글 키 29(옛 시험 계산 · 모달 · 알약) 걷음
- 시험: 지운 파일 글자만 보던 test_750_2(빈 파일 됨) · test_799_2 구동 시험 · test_734 알약 · 풍선 시험 지움 · helper_717_1 · test_717_1 의 /calc · /text · /logic/auto 화면 길 줄 걷음
- typecheck 0 · 관련 50 통과

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-18 03:12:11 +09:00
co-authored by Claude Opus 5.5
parent 56650e0291
commit 9c78072971
17 changed files with 5 additions and 1164 deletions
+1 -64
View File
@@ -1,6 +1,6 @@
/* =============================================================================
* M01_MasterData_UI_Logic_Note.ts
* 원문 표 읽기(`loadTable`) · 식 쉬운 말 풀이(`explain`).
* 원문 표 읽기(`loadTable`) — 식 쉬운 말 풀이는 옛 상세 몸과 같이 걷음(855 2-E1).
*
* 순수 읽기 — `/elements` 로 표 파일을 찾고 `/table` 로 통째 읽음.
* ========================================================================== */
@@ -54,66 +54,3 @@ export function loadTable(key: string): Promise<TableRow | null> {
tableCache.set(key, job);
return job;
}
/* ── 식 속 찾기(표, 조건...).칸 ──────────────────────────────────────── */
const FIND_RE = /찾기\(\s*([A-Za-z0-9_]+)\s*,([^)]*)\)\s*\.\s*([A-Za-z0-9_가-힣]+)/g;
function splitConds(raw: string): [string, string][] {
return raw
.split(",")
.map((p) => p.trim())
.filter(Boolean)
.map((p): [string, string] => {
const i = p.indexOf("=");
return i < 0 ? [p, p] : [p.slice(0, i).trim(), p.slice(i + 1).trim()];
});
}
/* ── 쉬운 말 풀이 — 찾기()/만약() 을 문장으로, 안 되면 식 그대로 ─────────── */
function splitTop(s: string): string[] {
const out: string[] = [];
let depth = 0;
let cur = "";
for (const ch of s) {
if (ch === "(") depth++;
if (ch === ")") depth--;
if (ch === "," && depth === 0) {
out.push(cur);
cur = "";
} else cur += ch;
}
out.push(cur);
return out;
}
function expandIf(expr: string): string {
const at = expr.indexOf("만약(");
if (at < 0) return expr;
let depth = 0;
let j = at + 2; // "만약(" 의 '(' 자리
for (; j < expr.length; j++) {
if (expr[j] === "(") depth++;
else if (expr[j] === ")") {
depth--;
if (depth === 0) {
j++;
break;
}
}
}
const [cond, then, els] = splitTop(expr.slice(at + 3, j - 1)).map((p) => p.trim());
const said = `(${expandIf(cond)} 이면 ${expandIf(then)}, 아니면 ${expandIf(els ?? "")})`;
return expandIf(expr.slice(0, at) + said + expr.slice(j));
}
export function explain(expr: string): string {
const withFind = expr.replace(FIND_RE, (_all, table: string, conds: string, col: string) => {
const cs = splitConds(conds)
.map(([, rhs]) => rhs)
.join(" · ");
return `[${table} 표에서 ${cs} 에 맞는 「${col}」]`;
});
return expandIf(withFind).trim() || expr;
}