From 9dff9146a20ce7ad3f85f1b47898842e53bc9592 Mon Sep 17 00:00:00 2001 From: LunaStev Date: Mon, 23 Dec 2024 20:07:16 +0900 Subject: [PATCH] Isolate AST test code from AST code --- src/main.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index c2859cb..ffd328c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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) -> String { @@ -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)); } \ No newline at end of file