Enum erg_common::error::Location
source · pub enum Location {
Range {
ln_begin: u32,
col_begin: u32,
ln_end: u32,
col_end: u32,
},
LineRange(u32, u32),
Line(u32),
Unknown,
}
Expand description
Points the location (of an error) in a code. The beginning and end of each row and column where the error occurred. Basically, the beginning and end of each row and column where the error occurred is kept.
Variants§
Range
Location used for basic errors
// erg
a = 1
a = 2
// Value assigned to the structure
Location::Range {
ln_begin: 2,
col_begin: 0,
ln_end: 2,
col_end: 1,
}
LineRange(u32, u32)
Used for loss of location information when desugared. If there are guaranteed to be multiple rows
Line(u32)
Used when Location information is lost when desugared If it is guaranteed to be a single line
Unknown
Used by default in case of loss of Location information
Implementations§
source§impl Location
impl Location
pub fn concat<L: Locational, R: Locational>(l: &L, r: &R) -> Self
pub fn stream<L: Locational>(ls: &[L]) -> Self
pub const fn range( ln_begin: u32, col_begin: u32, ln_end: u32, col_end: u32 ) -> Self
pub const fn is_unknown(&self) -> bool
pub const fn unknown_or(&self, other: Self) -> Self
pub const fn ln_begin(&self) -> Option<u32>
pub const fn ln_end(&self) -> Option<u32>
pub const fn col_begin(&self) -> Option<u32>
pub const fn col_end(&self) -> Option<u32>
pub const fn length(&self) -> Option<u32>
sourcepub fn contains(&self, other: Self) -> bool
pub fn contains(&self, other: Self) -> bool
let loc = Location::range(1, 3, 1, 7);
assert_eq!(loc.ln_begin(), Some(1));
assert!(loc.contains(Location::range(1, 4, 1, 5)));
let loc = Location::range(1, 3, 3, 2);
assert!(loc.contains(Location::range(1, 4, 1, 5)));
assert!(!loc.contains(Location::range(1, 4, 3, 5)));
assert!(loc.contains(Location::range(1, 4, 2, 5)));
assert!(!loc.contains(Location::range(1, 2, 2, 5)));
Trait Implementations§
source§impl Locational for Location
impl Locational for Location
source§fn loc(&self) -> Self
fn loc(&self) -> Self
NOTE:
loc
cannot be treated as a light method when self
is a large grammatical element.
If possible, delay the computation by passing &impl Locational
or other means.fn ln_begin(&self) -> Option<u32>
fn ln_end(&self) -> Option<u32>
fn col_begin(&self) -> Option<u32>
fn col_end(&self) -> Option<u32>
source§impl Ord for Location
impl Ord for Location
source§impl PartialEq<Location> for Location
impl PartialEq<Location> for Location
source§impl PartialOrd<Location> for Location
impl PartialOrd<Location> for Location
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read more