use crate::{ParseError, TokenIter};
pub trait ConsumableToken: Clone+ std::fmt::Debug + Parsable<Self>{
}
pub trait Parsable<TToken>: std::fmt::Debug
where
TToken: Parsable<TToken>,
Self: Sized,
TToken: ConsumableToken
{
type ApplyMatchTo: Parsable<TToken> = Self;
fn parse(iter: &mut TokenIter<TToken>) -> Result<Self, ParseError<TToken>>;
#[allow(unused_variables)]
fn parse_if_match<F: Fn(&Self::ApplyMatchTo) -> bool>(
iter: &mut TokenIter<TToken>,
matches: F,
pattern: Option<&'static str>
) -> Result<Self, ParseError<TToken>>
where
Self: Sized {
todo!("parse_if_match not yet implemented for {:?}", Self::identifier());
}
fn identifier() -> &'static str {
std::any::type_name::<Self>()
}
}