Phase 32 L-2.1 complete implementation: 1. Stage-1 UsingResolver main line JoinIR connection - CFG-based LoopForm construction for resolve_for_source/5 - LoopToJoinLowerer integration with handwritten fallback - JSON snapshot tests 6/6 PASS 2. JoinIR/VM Bridge improvements - Simplified join_ir_vm_bridge.rs dispatch logic - Enhanced json.rs serialization - PHI core boxes cleanup (local_scope_inspector, loop_exit_liveness, loop_var_classifier) 3. Stage-1 CLI enhancements - Extended args.rs, groups.rs, mod.rs for new options - Improved stage1_bridge module (args, env, mod) - Updated stage1_cli.hako 4. MIR builder cleanup - Simplified if_form.rs control flow - Removed dead code from loop_builder.rs - Enhanced phi_merge.rs 5. Runner module updates - json_v0_bridge/lowering.rs improvements - dispatch.rs, selfhost.rs, modes/vm.rs cleanup 6. Documentation updates - CURRENT_TASK.md, AGENTS.md - Various docs/ updates 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
64 lines
2.1 KiB
Rust
64 lines
2.1 KiB
Rust
//! Shared helpers for members parsing (scaffold)
|
|
use crate::parser::common::ParserUtils;
|
|
use crate::parser::{NyashParser, ParseError};
|
|
use crate::tokenizer::TokenType;
|
|
|
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
pub(crate) enum MemberKind {
|
|
Field,
|
|
Method,
|
|
Constructor,
|
|
PropertyComputed,
|
|
#[allow(dead_code)] // Future: once property modifier
|
|
PropertyOnce,
|
|
#[allow(dead_code)] // Future: birth_once property modifier
|
|
PropertyBirthOnce,
|
|
}
|
|
|
|
/// Decide member kind via simple lookahead (scaffold placeholder)
|
|
pub(crate) fn classify_member(p: &mut NyashParser) -> Result<MemberKind, ParseError> {
|
|
// block-first: { body } as (once|birth_once)? name : Type
|
|
if crate::config::env::unified_members() && p.match_any_token(&[TokenType::LBRACE]) {
|
|
return Ok(MemberKind::PropertyComputed);
|
|
}
|
|
|
|
// Constructors by keyword or name
|
|
match &p.current_token().token_type {
|
|
TokenType::PACK | TokenType::BIRTH => {
|
|
if p.peek_token() == &TokenType::LPAREN {
|
|
return Ok(MemberKind::Constructor);
|
|
}
|
|
}
|
|
TokenType::IDENTIFIER(name)
|
|
if (name == "init" || name == "birth" || name == "pack")
|
|
&& p.peek_token() == &TokenType::LPAREN =>
|
|
{
|
|
return Ok(MemberKind::Constructor);
|
|
}
|
|
_ => {}
|
|
}
|
|
|
|
// Method: ident '(' ...
|
|
if matches!(&p.current_token().token_type, TokenType::IDENTIFIER(_))
|
|
&& p.peek_token() == &TokenType::LPAREN
|
|
{
|
|
return Ok(MemberKind::Method);
|
|
}
|
|
|
|
// Field: [weak] ident ':' Type
|
|
if p.match_any_token(&[TokenType::WEAK]) {
|
|
// weak IDENT ':'
|
|
// do not consume; use peek via offset: current is WEAK, next should be IDENT, then ':'
|
|
// We only classify; the main parser will handle errors.
|
|
return Ok(MemberKind::Field);
|
|
}
|
|
if matches!(&p.current_token().token_type, TokenType::IDENTIFIER(_))
|
|
&& p.peek_token() == &TokenType::COLON
|
|
{
|
|
return Ok(MemberKind::Field);
|
|
}
|
|
|
|
// Default: treat as method for graceful recovery
|
|
Ok(MemberKind::Method)
|
|
}
|