feat(selfhost): Add Stage-3 LOCAL keyword support to ParserStmtBox
🔧 Problem: Selfhost ParserBox doesn't recognize LOCAL keyword - Only supports lowercase 'local' (Stage-1/2) - Stage-3 mode with HAKO_PARSER_STAGE3=1 not working ✅ Solution: Add LOCAL keyword recognition in ParserStmtBox - Check ctx.stage3_enabled() before parsing - Support both 'local' and 'LOCAL' keywords - Maintain backward compatibility with Stage-1/2 📍 Modified: lang/src/compiler/parser/stmt/parser_stmt_box.hako:109-149 - Added is_local_kw flag and kw_len variable - Check 'local' first (always) - Check 'LOCAL' if stage3_enabled() (conditional) 🐛 Current status: - Using-chain parsing: ✅ SUCCESS (2 files) - Stage-B test: ❌ Still failing with 'Unexpected token LOCAL at line 19' - Next: Investigate which file's line 19 is causing the error Related: #stageb-緑化 #phase-20.33 #selfhost-parser
This commit is contained in:
@ -106,9 +106,22 @@ static box ParserStmtBox {
|
||||
return "{\"type\":\"Return\",\"expr\":" + expr_json_ret + "}"
|
||||
}
|
||||
|
||||
// local declaration
|
||||
// local declaration (Stage-3 compatible: supports both 'local' and 'LOCAL')
|
||||
local is_local_kw = 0
|
||||
local kw_len = 0
|
||||
if ctx.starts_with_kw(src, j, "local") == 1 {
|
||||
j = j + 5
|
||||
is_local_kw = 1
|
||||
kw_len = 5
|
||||
}
|
||||
if is_local_kw == 0 && ctx.stage3_enabled() == 1 {
|
||||
if ctx.starts_with_kw(src, j, "LOCAL") == 1 {
|
||||
is_local_kw = 1
|
||||
kw_len = 5
|
||||
}
|
||||
}
|
||||
|
||||
if is_local_kw == 1 {
|
||||
j = j + kw_len
|
||||
j = ctx.skip_ws(src, j)
|
||||
local idp = ctx.read_ident2(src, j)
|
||||
local at = idp.lastIndexOf("@")
|
||||
|
||||
Reference in New Issue
Block a user