marser 0.1.0

Parser combinator toolkit with matcher-level backtracking and rich error reporting.
//! Unconditional single-token consumption (if any input remains).

use crate::{
    error::{MatcherRunError, error_handler::ErrorHandler},
    input::{Input, InputStream},
    matcher::MatchRunner,
};

/// Matches exactly one token and advances; fails at end of input.
#[derive(Clone, Debug)]
pub struct AnyToken;

impl super::MatcherCombinator for AnyToken {}

impl<'src, Inp: Input<'src>, MRes> super::internal::MatcherImpl<'src, Inp, MRes> for AnyToken
where
    Inp: Input<'src>,
{
    const CAN_MATCH_DIRECTLY: bool = true;
    const HAS_PROPERTY: bool = false;
    const CAN_FAIL: bool = true;

    #[inline]
    fn match_with_runner<'a, Runner>(
        &'a self,
        _runner: &mut Runner,
        _error_handler: &mut impl ErrorHandler,
        input: &mut InputStream<'src, Inp>,
    ) -> Result<bool, MatcherRunError>
    where
        Runner: MatchRunner<'a, 'src, Inp, MRes = MRes>,
        'src: 'a,
    {
        Ok(input.next().is_some())
    }
}