move function

This commit is contained in:
nora 2022-07-18 17:47:57 +02:00
parent a0e33835ed
commit b74c11987b
2 changed files with 10 additions and 12 deletions

View file

@ -3,7 +3,7 @@
//! //!
//! Code might be bad. Possibly. //! Code might be bad. Possibly.
use std::{fmt::Display, iter::Enumerate, ops::Not, str::Bytes}; use std::{fmt::Display, ops::Not};
use peekmore::PeekMore; use peekmore::PeekMore;
@ -184,19 +184,17 @@ where
src: peekmore::PeekMoreIterator<I>, src: peekmore::PeekMoreIterator<I>,
} }
impl<'src> PLexer<'src, Enumerate<Bytes<'src>>> {
pub fn new(src_str: &'src str) -> Self {
Self {
src_str,
src: src_str.bytes().enumerate().peekmore(),
}
}
}
impl<'src, I> PLexer<'src, I> impl<'src, I> PLexer<'src, I>
where where
I: Iterator<Item = (usize, u8)>, I: Iterator<Item = (usize, u8)>,
{ {
pub fn new(src_str: &'src str, src_iter: I) -> Self {
Self {
src_str,
src: src_iter.peekmore(),
}
}
/// 6.4.2 Identifiers /// 6.4.2 Identifiers
/// TODO: 6.4.3 Universal character names /// TODO: 6.4.3 Universal character names
fn identifier(&mut self, mut last_span: usize) -> (PToken<'src>, usize) { fn identifier(&mut self, mut last_span: usize) -> (PToken<'src>, usize) {

View file

@ -19,7 +19,7 @@ trait FileResolver {
struct Todo; struct Todo;
impl FileResolver for Todo { impl FileResolver for Todo {
fn resolve_file(&self, file_name: &Path, kind: IncludeKind) -> io::Result<Vec<u8>> { fn resolve_file(&self, _file_name: &Path, _kind: IncludeKind) -> io::Result<Vec<u8>> {
todo!() todo!()
} }
} }
@ -41,7 +41,7 @@ where
} }
pub fn preprocess_tokens(src: &str) -> impl Iterator<Item = (PToken<'_>, Span)> { pub fn preprocess_tokens(src: &str) -> impl Iterator<Item = (PToken<'_>, Span)> {
let lexer = PLexer::new(src); let lexer = PLexer::new(src, src.bytes().enumerate());
let preprocessor = Preprocessor { let preprocessor = Preprocessor {
lexer, lexer,