mirror of
https://github.com/Noratrieb/uwucc.git
synced 2026-01-14 16:45:07 +01:00
add file resolver
This commit is contained in:
parent
cfb6ef500a
commit
a0e33835ed
1 changed files with 24 additions and 1 deletions
|
|
@ -1,12 +1,32 @@
|
|||
mod lexer;
|
||||
|
||||
use std::{io, path::Path};
|
||||
|
||||
use lexer::PLexer;
|
||||
pub use lexer::{PToken, Punctuator};
|
||||
|
||||
use crate::Span;
|
||||
|
||||
enum IncludeKind {
|
||||
AngleBracketed,
|
||||
Quoted,
|
||||
}
|
||||
|
||||
trait FileResolver {
|
||||
fn resolve_file(&self, file_name: &Path, kind: IncludeKind) -> io::Result<Vec<u8>>;
|
||||
}
|
||||
|
||||
struct Todo;
|
||||
|
||||
impl FileResolver for Todo {
|
||||
fn resolve_file(&self, file_name: &Path, kind: IncludeKind) -> io::Result<Vec<u8>> {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
pub struct Preprocessor<L> {
|
||||
lexer: L,
|
||||
resolver: Box<dyn FileResolver>,
|
||||
}
|
||||
|
||||
impl<'src, L> Iterator for Preprocessor<L>
|
||||
|
|
@ -23,7 +43,10 @@ where
|
|||
pub fn preprocess_tokens(src: &str) -> impl Iterator<Item = (PToken<'_>, Span)> {
|
||||
let lexer = PLexer::new(src);
|
||||
|
||||
let preprocessor = Preprocessor { lexer };
|
||||
let preprocessor = Preprocessor {
|
||||
lexer,
|
||||
resolver: Box::new(Todo),
|
||||
};
|
||||
|
||||
preprocessor
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue