Skip to content

Commit

Permalink
修改输出方式(一行输出一个Token和一个Location)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ding Weihao committed Apr 19, 2024
1 parent e0ef9fd commit 10f1fee
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion source.c
Original file line number Diff line number Diff line change
@@ -1 +1 @@
int a = 2;
*a=2;
6 changes: 4 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1446,12 +1446,14 @@ fn main() {
let mut lexer = Lexer::new(&file_content);
match lexer.lex() {
Ok((tokens, tokens_location, errors)) => {
println!("Tokens: {:?}, location{:?}", tokens, tokens_location);
for (token, location) in tokens.iter().zip(tokens_location.iter()) {
println!("Tokens: {:?}, Location: {:?}", token, location);
}
// 处理错误信息
for err in errors {
eprintln!("Error: {}", err);
}
}
}
Err(err) => eprintln!("Error: {}", err),
}
}

0 comments on commit 10f1fee

Please sign in to comment.