Skip to content

Commit

Permalink
Code Organize
Browse files Browse the repository at this point in the history
  • Loading branch information
LunaStev committed Dec 21, 2024
1 parent b7504db commit 812076e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 22 deletions.
23 changes: 2 additions & 21 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,29 +42,10 @@ fn format_ast(ast: &AST) -> String {
}

fn main() {
// Sample code to parse and run
// Code part 1
let code_a = fs::read_to_string("test.wave").expect("Failed to read the file");

/*
// Code part 2 (the part causing error)
let code_b = r#"
fun main() {
var a: i32 = 10;
println("Hello World {}", a);
if (a == 10) {
println("10은 a랑 같다.");
} else if (a > 10) {
println("10은 a보다 작다.");
} else {
println("10은 a보다 크다.");
}
}
"#;
*/
let code = fs::read_to_string("test.wave").expect("Failed to read the file");

// Create a Lexer
let mut lexer = Lexer::new(code_a.as_str());
let mut lexer = Lexer::new(code.as_str());

// Tokenize the source code
let tokens = lexer.tokenize();
Expand Down
9 changes: 8 additions & 1 deletion test.wave
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
fun main() {
var a: i32 = 10;
println("Hello World {}", a);
for () {}
if (a == 10) {
println("fjf");
} else if (a > 10) {
println("fef");
} else {
println("ewe");
}

}

0 comments on commit 812076e

Please # to comment.