mipl 0.2.1

Minimal Imperative Parsing Library
Documentation
use super::*;

impl PeekerItem for NewlineToken {
    fn from_tok(token: Token) -> Option<Self> {
        if let Token::Newline(NewlineToken) = token {
            Some(NewlineToken)
        } else {
            None
        }
    }
}

/// Match a newline. Works only if the tokenizer
/// consider the newline character `\n` among the [KeepDelimiters].
pub struct IsNewline;
impl Peeker for IsNewline {
    type Item = NewlineToken;

    fn peek_for_token(&self, parser: &mut Parser) -> Option<Token> {
        match parser.peek()? {
            Token::Newline(_) => Some(Token::Newline(NewlineToken)),
            _ => None
        }
    }
}
impl ContainerCp for IsNewline {
    type ContainedType = ();
    type Input = ();

    fn new_contained(_value: Self::Input) -> Self::ContainedType {
        ()
    }
    fn new(_value: Self::Input) -> Self {
        IsNewline
    }
}