use super::token::Token;
use std::fmt::{self, Debug};
#[derive(Copy, Clone)]
pub enum ParseCondition {
CurrentToken { token: Token },
TokenPair { current: Token, next: Token },
}
impl ParseCondition {
#[inline]
pub fn current(token: Token) -> Self {
ParseCondition::CurrentToken { token }
}
#[inline]
pub fn token_pair(current: Token, next: Token) -> Self {
ParseCondition::TokenPair { current, next }
}
}
impl Debug for ParseCondition {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
ParseCondition::CurrentToken { token } => f
.debug_struct("CurrentToken")
.field("token", &token)
.finish(),
ParseCondition::TokenPair { current, next } => f
.debug_struct("TokenPair")
.field("current", ¤t)
.field("next", &next)
.finish(),
}
}
}