refactor: split optimizer/verifier/parser modules (mainline); add runner trace/directives; add LLVM terminator/select scaffolds; extract AST Span; update CURRENT_TASK with remaining plan

This commit is contained in:
Selfhosting Dev
2025-09-17 05:56:33 +09:00
parent 154778fc57
commit 9dc5c9afb9
39 changed files with 1327 additions and 739 deletions

View File

@ -0,0 +1,26 @@
use crate::parser::{NyashParser, ParseError};
use crate::parser::common::ParserUtils;
use crate::tokenizer::TokenType;
use crate::ast::{ASTNode, Span};
#[inline]
fn is_sugar_enabled() -> bool { crate::parser::sugar_gate::is_enabled() }
impl NyashParser {
pub(crate) fn expr_parse_ternary(&mut self) -> Result<ASTNode, ParseError> {
let cond = self.expr_parse_coalesce()?;
if self.match_token(&TokenType::QUESTION) {
self.advance();
let then_expr = self.parse_expression()?;
self.consume(TokenType::COLON)?;
let else_expr = self.parse_expression()?;
return Ok(ASTNode::If {
condition: Box::new(cond),
then_body: vec![then_expr],
else_body: Some(vec![else_expr]),
span: Span::unknown(),
});
}
Ok(cond)
}
}