Skip to content

Commit

Permalink
For Loop ast not yet
Browse files Browse the repository at this point in the history
  • Loading branch information
LunaStev committed Dec 15, 2024
1 parent a6dad0e commit 8672985
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ impl<'a> Parser<'a> {
TokenType::FUN => self.function(&mut ast),
TokenType::VAR => self.variable(&mut ast),
TokenType::IF => self.if_statement(&mut ast),
TokenType::WHILE => self.while_statement(),
TokenType::FOR => self.for_statement(),
TokenType::WHILE => self.while_statement(&mut ast),
TokenType::FOR => self.for_statement(/* &mut ast */),
TokenType::IMPORT => self.import_statement(),
TokenType::PRINT | TokenType::PRINTLN => self.print_statement(&mut ast),
_ => self.advance(),
Expand Down Expand Up @@ -370,7 +370,7 @@ impl<'a> Parser<'a> {
})
}

fn for_statement(&mut self) {
fn for_statement(&mut self /*, ast: &mut AST */) {
// `for` 구문 처리
self.advance(); // 'for'

Expand Down Expand Up @@ -446,6 +446,15 @@ impl<'a> Parser<'a> {
self.advance();
}
self.advance(); // '}'

/*
ast.add_node(ASTNode::ForLoop {
init: Box::new(()),
condition: "".to_string(),
increment: Box::new(()),
body: vec![],
})
*/
}

fn import_statement(&mut self) {
Expand Down

0 comments on commit 8672985

Please # to comment.