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,33 @@
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_coalesce(&mut self) -> Result<ASTNode, ParseError> {
let mut expr = self.expr_parse_or()?;
while self.match_token(&TokenType::QmarkQmark) {
if !is_sugar_enabled() {
let line = self.current_token().line;
return Err(ParseError::UnexpectedToken {
found: self.current_token().token_type.clone(),
expected: "enable NYASH_SYNTAX_SUGAR_LEVEL=basic|full for '??'".to_string(),
line,
});
}
self.advance();
let rhs = self.expr_parse_or()?;
let scr = expr;
expr = ASTNode::PeekExpr {
scrutinee: Box::new(scr.clone()),
arms: vec![(crate::ast::LiteralValue::Null, rhs)],
else_expr: Box::new(scr),
span: Span::unknown(),
};
}
Ok(expr)
}
}