/* * SPDX-FileCopyrightText: 2023 Alain Zscheile * * SPDX-License-Identifier: Apache-2.0 */ //use bitflags::bitflags; pub mod parser; mod expr; pub use expr::Expr; mod pat; pub use pat::{FullPattern, Pattern}; mod record; pub use record::{Record, RecordEntry}; pub mod typeck; use core::{cmp, fmt}; use miette::SourceSpan; /// A SourceSpan which is always equal to all other SourceSpans /// (to be used to ignore span differences in expression comparisons) #[derive(Clone, Copy)] pub struct EvEqSourceSpan(pub SourceSpan); impl cmp::PartialEq for EvEqSourceSpan { #[inline(always)] fn eq(&self, _: &Self) -> bool { true } } impl fmt::Display for EvEqSourceSpan { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{}..+{}", self.0.offset(), self.0.len()) } } impl fmt::Debug for EvEqSourceSpan { #[inline(always)] fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { ::fmt(self, f) } } impl From<(usize, usize)> for EvEqSourceSpan { #[inline] fn from(x: (usize, usize)) -> Self { Self(x.into()) } } impl From> for EvEqSourceSpan { #[inline] fn from(x: core::ops::Range) -> Self { Self(x.into()) } } impl From for SourceSpan { #[inline(always)] fn from(x: EvEqSourceSpan) -> SourceSpan { x.0 } } impl<'a> From<&'a EvEqSourceSpan> for SourceSpan { #[inline(always)] fn from(x: &'a EvEqSourceSpan) -> SourceSpan { x.0 } } pub trait Subst { fn incr_refs(&mut self, keep: usize, offset: usize); fn subst(&mut self, bnest: usize, with_e: &Expr); }