mirror of
https://github.com/rust-lang/rust
synced 2024-11-05 20:45:15 +00:00
23 lines
391 B
Rust
23 lines
391 B
Rust
// check-pass
|
|
|
|
struct CNFParser {
|
|
token: char,
|
|
}
|
|
|
|
impl CNFParser {
|
|
fn is_whitespace(c: char) -> bool {
|
|
c == ' ' || c == '\n'
|
|
}
|
|
|
|
fn consume_whitespace(&mut self) {
|
|
self.consume_while(&(CNFParser::is_whitespace))
|
|
}
|
|
|
|
fn consume_while(&mut self, p: &dyn Fn(char) -> bool) {
|
|
while p(self.token) {
|
|
return
|
|
}
|
|
}
|
|
}
|
|
|
|
fn main() {}
|