Skip to content

Commit

Permalink
Isolate AST test code from AST code
Browse files Browse the repository at this point in the history
  • Loading branch information
LunaStev committed Dec 23, 2024
1 parent 9ea0583 commit 9dff914
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ mod error;
use std::fs;
use lexer::Lexer;
use parser::Parser;
use crate::ast::AST;
use crate::ast::{ASTNode, Value, AST};
use crate::lexer::Token;

fn format_tokens(tokens: &Vec<Token>) -> String {
Expand Down Expand Up @@ -55,9 +55,19 @@ fn main() {

// Parse the AST
let ast = parser.parse();
let mut asta = AST::new();

let node = ASTNode::Variable {
name: String::from("x"),
var_type: String::from(":i32"),
value: Value::Int(42),
};

asta.add_node(node);

// 형식화된 출력
println!("Tokens: {}", format_tokens(&tokens));
println!("\nParser: {}", format_parser(&parser));
println!("\nAST: {}", format_ast(&ast));
println!("\nTEST AST: {}", format_ast(&asta));
}

0 comments on commit 9dff914

Please # to comment.