Ran `cargo fix --allow-dirty --lib` to automatically remove unused imports across the codebase. This cleanup is standard maintenance and improves code hygiene. **Files Modified**: - instruction_rewriter.rs: Removed 6 unused imports - block_remapper::remap_block_id - LoweringDecision - ParameterBindingBox - propagate_value_type_for_inst (2 occurrences) - apply_remapped_terminator - PhiAdjustment, ParameterBinding from scan_box - Other files: Minor unused import cleanup (12 files total) **No Functional Changes**: Pure cleanup, all tests expected to pass. Phase 286C-5 progress: 3/4 steps complete Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
50 lines
1.6 KiB
Rust
50 lines
1.6 KiB
Rust
/*!
|
|
* Function declaration parsing
|
|
*/
|
|
|
|
use crate::ast::{ASTNode, Span};
|
|
use crate::parser::common::ParserUtils;
|
|
use crate::parser::{NyashParser, ParseError};
|
|
use crate::tokenizer::TokenType;
|
|
|
|
impl NyashParser {
|
|
/// function宣言をパース: function name(params) { body }
|
|
pub fn parse_function_declaration(&mut self) -> Result<ASTNode, ParseError> {
|
|
self.consume(TokenType::FUNCTION)?;
|
|
|
|
// 関数名を取得
|
|
let name = if let TokenType::IDENTIFIER(name) = &self.current_token().token_type {
|
|
let name = name.clone();
|
|
self.advance();
|
|
name
|
|
} else {
|
|
let line = self.current_token().line;
|
|
return Err(ParseError::UnexpectedToken {
|
|
found: self.current_token().token_type.clone(),
|
|
expected: "function name".to_string(),
|
|
line,
|
|
});
|
|
};
|
|
|
|
// パラメータリストをパース
|
|
self.consume(TokenType::LPAREN)?;
|
|
|
|
// Phase 285A1.5: Use shared helper to prevent parser hangs on unsupported type annotations
|
|
let params = crate::parser::common::params::parse_param_name_list(self, "function")?;
|
|
|
|
self.consume(TokenType::RPAREN)?;
|
|
|
|
// 関数本体をパース(共通ブロックヘルパー)
|
|
let body = self.parse_block_statements()?;
|
|
|
|
Ok(ASTNode::FunctionDeclaration {
|
|
name,
|
|
params,
|
|
body,
|
|
is_static: false, // 通常の関数は静的でない
|
|
is_override: false, // デフォルトは非オーバーライド
|
|
span: Span::unknown(),
|
|
})
|
|
}
|
|
}
|