补全:给声明标上层数
(每道题开头都有同一段:上一站的 parser(多记了位置)、show(),和错误类 SemError——错误写成一行「原因@行:列」。)
贯穿的源码:
let rate = 12 ;
let msg = "hi" ;
let total = rate * 3 ;
if ( total >= 30 ) { let big = 1 ; total = total - big ; } else { total = 0 ; }补全 walk(stmts, scope, depth, out):遇到 let 就登记,并往 out 追加「名字:类型@层数」;遇到 if 就对两个块以 depth+1 递归(块开新 Scope)。
全部评论