2024-08-08 12:25:12 +03:00
|
|
|
use ariadne::{Color, Label, Report, ReportKind, Source};
|
|
|
|
use chumsky::Parser;
|
2024-08-11 18:21:24 +03:00
|
|
|
use dalet::daleth::{format::format, lexer::full_lexer};
|
2024-08-08 12:25:12 +03:00
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let src_file = "daleth.dlth";
|
|
|
|
let src = include_str!("./daleth.dlth");
|
|
|
|
|
2024-08-11 18:21:24 +03:00
|
|
|
let parsed = full_lexer().parse(src);
|
2024-08-08 12:25:12 +03:00
|
|
|
|
|
|
|
match parsed.into_result() {
|
2024-08-09 18:24:42 +03:00
|
|
|
Ok(t) => {
|
|
|
|
println!("{:#?}", t);
|
|
|
|
println!("{}", format(&t));
|
|
|
|
}
|
2024-08-08 12:25:12 +03:00
|
|
|
Err(e) => e.into_iter().for_each(|e| {
|
|
|
|
Report::build(ReportKind::Error, src_file, e.span().start)
|
|
|
|
.with_code("Compiler")
|
|
|
|
.with_message(e.to_string().clone())
|
|
|
|
.with_label(
|
|
|
|
Label::new((src_file, e.span().into_range()))
|
|
|
|
.with_message(e.to_string())
|
|
|
|
.with_color(Color::Red),
|
|
|
|
)
|
|
|
|
.finish()
|
|
|
|
.print((src_file, Source::from(&src)))
|
|
|
|
.unwrap()
|
|
|
|
}),
|
2024-08-09 18:24:42 +03:00
|
|
|
};
|
2024-08-08 12:25:12 +03:00
|
|
|
}
|