chore(semantic): print errors from examples/simple.rs

This commit is contained in:
Boshen 2024-08-23 22:57:26 +08:00
parent 4c88997727
commit 7cc2bbd293
No known key found for this signature in database
GPG key ID: 67715A371E534061

View file

@ -26,9 +26,8 @@ fn main() -> std::io::Result<()> {
let error_message: String = parser_ret
.errors
.into_iter()
.map(|error| error.with_source_code(Arc::clone(&source_text)).to_string())
.join("\n\n");
.map(|error| format!("{:?}", error.with_source_code(Arc::clone(&source_text))))
.join("\n");
println!("Parsing failed:\n\n{error_message}",);
return Ok(());
}
@ -36,6 +35,7 @@ fn main() -> std::io::Result<()> {
let program = allocator.alloc(parser_ret.program);
let semantic = SemanticBuilder::new(&source_text, source_type)
.build_module_record(path.to_path_buf(), program)
// Enable additional syntax checks not performed by the parser
.with_check_syntax_error(true)
// Inform Semantic about comments found while parsing
@ -46,9 +46,8 @@ fn main() -> std::io::Result<()> {
let error_message: String = semantic
.errors
.into_iter()
.map(|error| error.with_source_code(Arc::clone(&source_text)).to_string())
.join("\n\n");
.map(|error| format!("{:?}", error.with_source_code(Arc::clone(&source_text))))
.join("\n");
println!("Semantic analysis failed:\n\n{error_message}",);
}