Drop high-order stuff for good

This commit is contained in:
Aleksey Kladov 2018-01-28 01:13:27 +03:00
parent b7ae5bbba2
commit 3630aeb1ea
2 changed files with 0 additions and 40 deletions

View File

@ -46,39 +46,6 @@ fn alias(p: &mut Parser) -> bool {
true //FIXME: return false if three are errors
}
fn repeat<F: FnMut(&mut Parser) -> bool>(p: &mut Parser, mut f: F) {
loop {
let pos = p.pos();
if !f(p) {
return
}
if pos == p.pos() {
panic!("Infinite loop in parser")
}
}
}
fn comma_list<F: Fn(&mut Parser) -> bool>(p: &mut Parser, end: SyntaxKind, f: F) {
repeat(p, |p| {
if p.current() == end {
return false
}
let pos = p.pos();
f(p);
if p.pos() == pos {
return false
}
if p.current() == end {
p.eat(COMMA);
} else {
p.expect(COMMA);
}
true
})
}
impl<'p> Parser<'p> {
fn at<L: Lookahead>(&self, l: L) -> bool {
l.is_ahead(self)

View File

@ -105,9 +105,6 @@ pub(crate) struct Parser<'t> {
curly_limit: Option<i32>,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub(crate) struct Pos(u32);
impl<'t> Parser<'t> {
pub(crate) fn new(text: &'t str, raw_tokens: &'t [Token]) -> Parser<'t> {
let mut tokens = Vec::new();
@ -133,10 +130,6 @@ impl<'t> Parser<'t> {
}
}
pub(crate) fn pos(&self) -> Pos {
Pos(self.pos as u32)
}
pub(crate) fn into_events(self) -> Vec<Event> {
assert!(self.curly_limit.is_none());
assert_eq!(self.current(), EOF);