mirror of
https://github.com/rm-dr/daisy
synced 2025-02-22 23:19:22 -08:00
41 lines
849 B
Rust
41 lines
849 B
Rust
|
/// Specifies the location of a token in an input string.
|
||
|
#[derive(Debug)]
|
||
|
#[derive(Copy, Clone)]
|
||
|
pub struct LineLocation {
|
||
|
pub pos: usize,
|
||
|
pub len: usize
|
||
|
}
|
||
|
|
||
|
/// Types of parser errors.
|
||
|
/// If we cannot parse a string, one of these is returned.
|
||
|
#[derive(Debug)]
|
||
|
pub enum ParserError {
|
||
|
//MissingCloseParen,
|
||
|
ExtraCloseParen,
|
||
|
EmptyGroup,
|
||
|
Syntax,
|
||
|
BadNumber
|
||
|
}
|
||
|
|
||
|
impl ToString for ParserError {
|
||
|
fn to_string(&self) -> String {
|
||
|
match self {
|
||
|
//ParserError::MissingCloseParen => {
|
||
|
// String::from("This group is never closed")
|
||
|
//},
|
||
|
ParserError::ExtraCloseParen => {
|
||
|
String::from("Extra close parenthesis")
|
||
|
},
|
||
|
ParserError::EmptyGroup => {
|
||
|
String::from("Groups can't be empty")
|
||
|
},
|
||
|
ParserError::Syntax => {
|
||
|
String::from("Syntax")
|
||
|
},
|
||
|
ParserError::BadNumber => {
|
||
|
String::from("Invalid number")
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|