mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-30 15:21:12 +00:00
parse error infrastructure
This commit is contained in:
parent
e21cdfc689
commit
719ef5b70e
10 changed files with 646 additions and 568 deletions
39
compiler/reporting/src/error/parse.rs
Normal file
39
compiler/reporting/src/error/parse.rs
Normal file
|
@ -0,0 +1,39 @@
|
|||
use roc_parse::parser::{Fail, FailReason};
|
||||
use std::path::PathBuf;
|
||||
|
||||
use crate::report::{Report, RocDocAllocator};
|
||||
use ven_pretty::DocAllocator;
|
||||
|
||||
pub fn parse_problem<'b>(
|
||||
alloc: &'b RocDocAllocator<'b>,
|
||||
filename: PathBuf,
|
||||
problem: Fail,
|
||||
) -> Report<'b> {
|
||||
use FailReason::*;
|
||||
|
||||
match problem.reason {
|
||||
ArgumentsBeforeEquals => {
|
||||
let doc = alloc.text("Unexpected tokens in front of the `=` symbol:");
|
||||
|
||||
Report {
|
||||
filename,
|
||||
doc,
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue