use crate::input::Token;
use std::{fmt, hash};
#[derive(Clone, Copy, Eq, PartialOrd, Ord)]
pub enum Lookahead {
Eof,
Token(Token),
}
impl Lookahead {
fn plain(self) -> crate::indices::PlainToken {
match self {
Lookahead::Eof => 0,
Lookahead::Token(t) => t.get(),
}
}
}
impl PartialEq for Lookahead {
fn eq(&self, other: &Self) -> bool {
self.plain() == other.plain()
}
}
impl hash::Hash for Lookahead {
fn hash<H: hash::Hasher>(&self, state: &mut H) {
self.plain().hash(state);
}
}
impl fmt::Debug for Lookahead {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::Eof => write!(f, "Eof"),
Self::Token(t) => write!(f, "Token({:?})", t.get()),
}
}
}