Skip to content

Commit

Permalink
Print AST Temporary Update
Browse files Browse the repository at this point in the history
  • Loading branch information
LunaStev committed Dec 15, 2024
1 parent ab80ae7 commit cce0e46
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ impl<'a> Parser<'a> {
TokenType::WHILE => self.while_statement(),
TokenType::FOR => self.for_statement(),
TokenType::IMPORT => self.import_statement(),
TokenType::PRINT | TokenType::PRINTLN => self.print_statement(),
TokenType::PRINT | TokenType::PRINTLN => self.print_statement(&mut ast),
_ => self.advance(),
}
}
Expand Down Expand Up @@ -255,7 +255,7 @@ impl<'a> Parser<'a> {
}


fn print_statement(&mut self) {
fn print_statement(&mut self, ast: &mut AST) {
self.advance();
if let TokenType::STRING(_) = &self.current_token.token_type {
// It's a string, proceed with extracting the string.
Expand All @@ -273,6 +273,12 @@ impl<'a> Parser<'a> {
print!("{}", message);
}
self.advance();

ast.add_node(ASTNode::Print {
/* */
message: "".to_string(),
newline: false,
})
}

fn if_statement(&mut self) {
Expand Down

0 comments on commit cce0e46

Please # to comment.