From b74c11987bfa8c4079fbb5ef611e210511a4f01d Mon Sep 17 00:00:00 2001 From: nils <48135649+Nilstrieb@users.noreply.github.com> Date: Mon, 18 Jul 2022 17:47:57 +0200 Subject: [PATCH] move function --- parser/src/pre/lexer.rs | 18 ++++++++---------- parser/src/pre/mod.rs | 4 ++-- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/parser/src/pre/lexer.rs b/parser/src/pre/lexer.rs index 2a6b259..a89b486 100644 --- a/parser/src/pre/lexer.rs +++ b/parser/src/pre/lexer.rs @@ -3,7 +3,7 @@ //! //! Code might be bad. Possibly. -use std::{fmt::Display, iter::Enumerate, ops::Not, str::Bytes}; +use std::{fmt::Display, ops::Not}; use peekmore::PeekMore; @@ -184,19 +184,17 @@ where src: peekmore::PeekMoreIterator, } -impl<'src> PLexer<'src, Enumerate>> { - pub fn new(src_str: &'src str) -> Self { - Self { - src_str, - src: src_str.bytes().enumerate().peekmore(), - } - } -} - impl<'src, I> PLexer<'src, I> where I: Iterator, { + pub fn new(src_str: &'src str, src_iter: I) -> Self { + Self { + src_str, + src: src_iter.peekmore(), + } + } + /// 6.4.2 Identifiers /// TODO: 6.4.3 Universal character names fn identifier(&mut self, mut last_span: usize) -> (PToken<'src>, usize) { diff --git a/parser/src/pre/mod.rs b/parser/src/pre/mod.rs index 1ff4bb3..56300f7 100644 --- a/parser/src/pre/mod.rs +++ b/parser/src/pre/mod.rs @@ -19,7 +19,7 @@ trait FileResolver { struct Todo; impl FileResolver for Todo { - fn resolve_file(&self, file_name: &Path, kind: IncludeKind) -> io::Result> { + fn resolve_file(&self, _file_name: &Path, _kind: IncludeKind) -> io::Result> { todo!() } } @@ -41,7 +41,7 @@ where } pub fn preprocess_tokens(src: &str) -> impl Iterator, Span)> { - let lexer = PLexer::new(src); + let lexer = PLexer::new(src, src.bytes().enumerate()); let preprocessor = Preprocessor { lexer,