mirror of
https://github.com/Noratrieb/uwucc.git
synced 2026-01-14 16:45:07 +01:00
crates
This commit is contained in:
parent
f229dd7fdc
commit
92292c756c
8 changed files with 60 additions and 2 deletions
|
|
@ -12,6 +12,8 @@ mod pre;
|
|||
mod pretty;
|
||||
mod token;
|
||||
|
||||
pub use parser::Parser;
|
||||
|
||||
pub type Spanned<T> = (T, Span);
|
||||
|
||||
#[derive(PartialEq, Eq, Clone, Copy, Default)]
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ impl DebugPls for ParserError {
|
|||
|
||||
type Result<T, E = ParserError> = std::result::Result<T, E>;
|
||||
|
||||
struct Parser<'src, I>
|
||||
pub struct Parser<'src, I>
|
||||
where
|
||||
I: Iterator<Item = (Tok<'src>, Span)>,
|
||||
{
|
||||
|
|
@ -549,6 +549,22 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
impl<'src, I> Iterator for Parser<'src, I>
|
||||
where
|
||||
I: Iterator<Item = (Tok<'src>, Span)>,
|
||||
{
|
||||
type Item = Result<Spanned<ExternalDecl>>;
|
||||
|
||||
fn next(&mut self) -> Option<Self::Item> {
|
||||
if self.peek_t().is_ok() {
|
||||
let decl = self.external_declaration();
|
||||
Some(decl)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn parse_declarations<'src>(
|
||||
src: impl Iterator<Item = (Tok<'src>, Span)>,
|
||||
) -> Result<Vec<Spanned<ExternalDecl>>> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue