This commit is contained in:
Folkert 2021-02-03 20:21:12 +01:00
parent 7b4378219e
commit d211ca7e61
30 changed files with 679 additions and 614 deletions

View file

@ -1,4 +1,5 @@
use roc_parse::parser::{Fail, FailReason};
use roc_parse::parser::{Bag, DeadEnd, FailReason, ParseProblem};
use roc_region::all::Region;
use std::path::PathBuf;
use crate::report::{Report, RocDocAllocator};
@ -7,12 +8,21 @@ use ven_pretty::DocAllocator;
pub fn parse_problem<'b>(
alloc: &'b RocDocAllocator<'b>,
filename: PathBuf,
problem: Fail,
starting_line: u32,
parse_problem: ParseProblem,
) -> Report<'b> {
use FailReason::*;
match problem.reason {
ArgumentsBeforeEquals(region) => {
let line = starting_line + parse_problem.line;
let region = Region {
start_line: line,
end_line: line,
start_col: parse_problem.column,
end_col: parse_problem.column,
};
match parse_problem.problem {
ConditionFailed => {
let doc = alloc.stack(vec![
alloc.reflow("Unexpected tokens in front of the `=` symbol:"),
alloc.region(region),
@ -24,19 +34,6 @@ pub fn parse_problem<'b>(
title: "PARSE PROBLEM".to_string(),
}
}
other => {
//
// Unexpected(char, Region),
// OutdentedTooFar,
// ConditionFailed,
// LineTooLong(u32 /* which line was too long */),
// TooManyLines,
// Eof(Region),
// InvalidPattern,
// ReservedKeyword(Region),
// ArgumentsBeforeEquals,
//}
todo!("unhandled parse error: {:?}", other)
}
_ => todo!("unhandled parse error: {:?}", parse_problem.problem),
}
}