diff options
author | Aleksey Kladov <[email protected]> | 2017-12-29 21:48:47 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2017-12-29 21:48:47 +0000 |
commit | 770ecd4ecd61f04597d9478001848b703d915cce (patch) | |
tree | 6ca644dbc10bb8c183cd174fcd035545ec42f7b3 /src/lexer/ptr.rs | |
parent | 171baf4c4863f035384c6c63a5f0ce531b01cf9d (diff) |
Cleanup character classes
Diffstat (limited to 'src/lexer/ptr.rs')
-rw-r--r-- | src/lexer/ptr.rs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/lexer/ptr.rs b/src/lexer/ptr.rs index 4638dac21..e8aa6f37b 100644 --- a/src/lexer/ptr.rs +++ b/src/lexer/ptr.rs | |||
@@ -32,6 +32,17 @@ impl<'s> Ptr<'s> { | |||
32 | Some(ch) | 32 | Some(ch) |
33 | } | 33 | } |
34 | 34 | ||
35 | pub fn bump_while<F: Fn(char) -> bool>(&mut self, pred: F) { | ||
36 | loop { | ||
37 | match self.next() { | ||
38 | Some(c) if pred(c) => { | ||
39 | self.bump(); | ||
40 | }, | ||
41 | _ => return, | ||
42 | } | ||
43 | } | ||
44 | } | ||
45 | |||
35 | fn chars(&self) -> Chars { | 46 | fn chars(&self) -> Chars { |
36 | self.text[self.len.0 as usize ..].chars() | 47 | self.text[self.len.0 as usize ..].chars() |
37 | } | 48 | } |