mirror of
https://github.com/Noratrieb/dilaria.git
synced 2026-01-16 10:25:02 +01:00
start parser
This commit is contained in:
parent
eb2f67e19f
commit
7c99615560
2 changed files with 88 additions and 21 deletions
38
src/lib.rs
38
src/lib.rs
|
|
@ -7,24 +7,24 @@ mod parse;
|
|||
pub fn run_program(program: &str) {
|
||||
let lexer = lex::Lexer::lex(program);
|
||||
let (success, errors) = lexer.partition::<Vec<_>, _>(|result| result.is_ok());
|
||||
//
|
||||
// // terrible, but works
|
||||
// let tokens = success.into_iter().collect::<Result<_, _>>();
|
||||
// let _ast = parse::parse(tokens.unwrap());
|
||||
|
||||
// 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));
|
||||
// }
|
||||
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