## ✅ Fixed Issues ### 1. `local` keyword tokenization (commit 9aab64f7) - Added Stage-3 gate for LOCAL/TRY/CATCH/THROW keywords - LOCAL now only active when NYASH_PARSER_STAGE3=1 ### 2. `env.local.get` keyword conflict - File: `lang/src/compiler/entry/compiler_stageb.hako:21-23` - Problem: `.local` in member access tokenized as `.LOCAL` keyword - Fix: Commented out `env.local.get("HAKO_SOURCE")` line - Fallback: Use `--source` argument (still functional) ### 3. `flow` keyword missing - Added FLOW to TokenType enum (`src/tokenizer/kinds.rs`) - Added "flow" → TokenType::FLOW mapping (`src/tokenizer/lex_ident.rs`) - Added FLOW to Stage-3 gate (requires NYASH_PARSER_STAGE3=1) - Added FLOW to parser statement dispatch (`src/parser/statements/mod.rs`) - Added FLOW to declaration handler (`src/parser/statements/declarations.rs`) - Updated box_declaration parser to accept BOX or FLOW (`src/parser/declarations/box_definition.rs`) - Treat `flow FooBox {}` as syntactic sugar for `box FooBox {}` ### 4. Module namespace conversion - Renamed `lang.compiler.builder.ssa.local` → `localvar` (avoid keyword) - Renamed file `local.hako` → `local_ssa.hako` - Converted 152 path-based using statements to namespace format - Added 26+ entries to `nyash.toml` [modules] section ## ⚠️ Remaining Issues ### Stage-B selfhost compiler performance - Stage-B compiler not producing output (hangs/times out after 10+ seconds) - Excessive PHI debug output suggests compilation loop issue - Needs investigation: infinite loop or N² algorithm in hako compiler ### Fallback JSON version mismatch - Rust fallback (`--emit-mir-json`) emits MIR v1 JSON (schema_version: "1.0") - Smoke tests expect MIR v0 JSON (`"version":0, "kind":"Program"`) - stageb_helpers.sh fallback needs adjustment ## Test Status - Parse errors: FIXED ✅ - Keyword conflicts: FIXED ✅ - Stage-B smoke tests: STILL FAILING ❌ (performance issue) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
71 lines
2.4 KiB
Plaintext
71 lines
2.4 KiB
Plaintext
// UsingResolverBox — static, stateful resolver helpers(インスタンス禁止・VM互換)
|
||
// State layout (Map): {
|
||
// alias_paths: Map, alias_names: Map, alias_keys: Array,
|
||
// modules_map: Map, modules_keys: Array
|
||
// }
|
||
|
||
using selfhost.shared.common.string_helpers as StringHelpers
|
||
using selfhost.shared.common.box_helpers as BoxHelpers
|
||
using lang.compiler.pipeline_v2.regex_flow as RegexFlow
|
||
|
||
static box UsingResolverBox {
|
||
// Lightweight state as String: holds modules_json only
|
||
state_new() { return "" }
|
||
|
||
load_usings_json(state, usings_json) { return state }
|
||
|
||
load_modules_json(state, mod_json) { return ("" + mod_json) }
|
||
|
||
resolve_path_alias(state, alias) { return null }
|
||
|
||
resolve_namespace_alias(state, alias) {
|
||
if alias == null { return null }
|
||
local s = "" + state
|
||
// Prefer unique tail match by last segment
|
||
local i = 0
|
||
local start = 0
|
||
local found = null
|
||
loop(true) {
|
||
local kpos = RegexFlow.find_from(s, "\"", start)
|
||
if kpos < 0 { break }
|
||
local kend = RegexFlow.find_from(s, "\"", kpos + 1)
|
||
if kend < 0 { break }
|
||
local key = s.substring(kpos + 1, kend)
|
||
local dot = RegexFlow.last_index_of(key, ".")
|
||
local last = key
|
||
if dot >= 0 { last = key.substring(dot + 1, key.length()) }
|
||
if last == alias {
|
||
if found == null { found = key } else { return null }
|
||
} else {
|
||
// first-letter case-insensitive match
|
||
if last.length() == alias.length() && last.length() > 0 {
|
||
local l0 = last.substring(0,1)
|
||
local a0 = alias.substring(0,1)
|
||
local restl = last.substring(1, last.length())
|
||
local resta = alias.substring(1, alias.length())
|
||
if restl == resta {
|
||
local U = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; local L = "abcdefghijklmnopqrstuvwxyz"
|
||
local idxL = L.indexOf(l0); local idxU = U.indexOf(l0)
|
||
if (idxL >= 0 && U.substring(idxL, idxL+1) == a0) || (idxU >= 0 && L.substring(idxU, idxU+1) == a0) {
|
||
if found == null { found = key } else { return null }
|
||
}
|
||
}
|
||
}
|
||
}
|
||
start = kend + 1
|
||
}
|
||
return found
|
||
}
|
||
|
||
resolve_module_path_from_alias(state, alias) { return null }
|
||
|
||
guess_namespace_from_tail(state, tail) { return me.resolve_namespace_alias(state, tail) }
|
||
|
||
upgrade_aliases(state) { return 0 }
|
||
|
||
to_context_json(state) { return "{}" }
|
||
map_to_json(m) { return "{}" }
|
||
}
|
||
|
||
static box UsingResolverBoxMain { main(args) { return 0 } }
|