schala/schala-lang/src/parsing/mod.rs

31 lines
547 B
Rust
Raw Normal View History

2021-10-19 22:24:27 -07:00
#![allow(clippy::upper_case_acronyms)]
2021-11-14 00:34:21 -08:00
pub mod new;
2021-11-04 21:11:19 -07:00
mod test;
use std::fmt;
2018-06-04 19:25:40 -07:00
/// Represents a parsing error
#[derive(Debug)]
2017-09-11 02:07:17 -07:00
pub struct ParseError {
pub msg: String,
2021-11-14 02:15:08 -08:00
pub location: Location,
}
#[derive(Debug, Clone, Copy, PartialEq, Default)]
pub struct Location {
pub(crate) offset: usize,
2017-09-11 02:07:17 -07:00
}
2017-09-09 00:31:15 -07:00
impl From<usize> for Location {
fn from(offset: usize) -> Self {
Self { offset }
}
2017-09-11 23:27:15 -07:00
}
impl fmt::Display for Location {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.offset)
}
2018-01-08 05:57:36 -08:00
}