mirror of
https://github.com/Noratrieb/dilaria.git
synced 2026-01-14 17:35:03 +01:00
add parser
This commit is contained in:
parent
03fe10d7c0
commit
a0e17c6042
4 changed files with 163 additions and 38 deletions
34
src/lib.rs
34
src/lib.rs
|
|
@ -8,19 +8,23 @@ pub fn run_program(program: &str) {
|
|||
let lexer = lex::Lexer::lex(program);
|
||||
let (success, errors) = lexer.partition::<Vec<_>, _>(|result| result.is_ok());
|
||||
|
||||
if errors.is_empty() {
|
||||
println!(
|
||||
"{:#?}",
|
||||
success
|
||||
.into_iter()
|
||||
.map(Result::unwrap)
|
||||
.map(|token| token.kind)
|
||||
.collect::<Vec<_>>()
|
||||
);
|
||||
} else {
|
||||
errors
|
||||
.into_iter()
|
||||
.map(Result::unwrap_err)
|
||||
.for_each(|err| crate::errors::display_error(program, err));
|
||||
}
|
||||
// terrible, but works
|
||||
let tokens = success.into_iter().collect::<Result<_, _>>();
|
||||
let _ast = parse::parse(tokens.unwrap());
|
||||
|
||||
// if errors.is_empty() {
|
||||
// println!(
|
||||
// "{:#?}",
|
||||
// success
|
||||
// .into_iter()
|
||||
// .map(Result::unwrap)
|
||||
// .map(|token| token.kind)
|
||||
// .collect::<Vec<_>>()
|
||||
// );
|
||||
// } else {
|
||||
// errors
|
||||
// .into_iter()
|
||||
// .map(Result::unwrap_err)
|
||||
// .for_each(|err| crate::errors::display_error(program, err));
|
||||
// }
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue