Skip to content

Commit

Permalink
fix(null-filter): minor fix to make it work
Browse files Browse the repository at this point in the history
It's still far from perfect, but a good proof of concept
  • Loading branch information
Byron committed May 7, 2015
1 parent 97adcb8 commit e489bff
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/filter_null.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ impl<I: Iterator<Item=Token>> FilterNull<I> {
pub fn new(src: I) -> FilterNull<I> {
FilterNull {
src: src,
buf: VecDeque::with_capacity(3),
buf: VecDeque::with_capacity(2),
}
}
}
Expand All @@ -28,18 +28,16 @@ impl<I> Iterator for FilterNull<I> where I: Iterator<Item=Token>{
Some(first_str_candidate) => {
match first_str_candidate.kind {
TokenType::String => {
// self.buf.push_back(token);
let first_str_token = first_str_candidate;
match self.src.next() {
Some(colon_candidate) => {
// self.buf.push_back(token);
match colon_candidate.kind {
TokenType::Colon => {
let colon = colon_candidate;
match self.src.next() {
Some(second_str_candidate) => {
// self.buf.push_back(token);
match second_str_candidate.kind {
TokenType::String => {
TokenType::Null => {
// WE HAVE A STR : STR triplete, and we forget it
// This works by just not putting it onto the ringbuffer
// See if there is a (optional) comma
Expand All @@ -54,14 +52,14 @@ impl<I> Iterator for FilterNull<I> where I: Iterator<Item=Token>{
}
},
_ => {
self.buf.push_back(colon_candidate);
self.buf.push_back(colon);
self.buf.push_back(second_str_candidate);
Some(first_str_token)
}
}
},
None => {
self.buf.push_back(colon_candidate);
self.buf.push_back(colon);
Some(first_str_token)
}
}
Expand Down

0 comments on commit e489bff

Please sign in to comment.