use crate::token::Atom;
use std::convert::Infallible;
use syan::parse::tape::Tape;
use syan::parse::ParseStream;
pub struct AtomStream {
tape: Tape<std::vec::IntoIter<Atom>>,
}
impl AtomStream {
pub fn new(atoms: Vec<Atom>) -> Self {
AtomStream {
tape: Tape::new(atoms.into_iter()),
}
}
}
impl ParseStream for AtomStream {
type Atom = Atom;
type Error = Infallible;
fn next(&mut self) -> Option<Self::Atom> {
self.tape.next()
}
fn peek(&mut self) -> Option<&Self::Atom> {
self.tape.peek()
}
fn push(&mut self, atom: Self::Atom) {
self.tape.push(atom);
}
fn checkpoint_raw(&mut self) -> u64 {
self.tape.checkpoint()
}
fn rollback_raw(&mut self, raw: u64) {
self.tape.rollback(raw);
}
fn commit_raw(&mut self, raw: u64) {
self.tape.commit(raw);
}
fn get_error(&mut self) -> Result<(), Self::Error> {
Ok(())
}
fn skip_sep(&mut self) -> bool {
false
}
}