diff options
author | Aleksey Kladov <[email protected]> | 2018-01-08 19:40:14 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2018-01-08 19:40:14 +0000 |
commit | 0cf2d6afee52fe248c8a032346c5bdb6dc7cd928 (patch) | |
tree | f98f950ada46f596502d8d9987efc67848c46321 /src/parser/event_parser/parser.rs | |
parent | bdddfc9eb89ee717c38a117383a313e5a49bb267 (diff) |
Generalized lookahead
Diffstat (limited to 'src/parser/event_parser/parser.rs')
-rw-r--r-- | src/parser/event_parser/parser.rs | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/src/parser/event_parser/parser.rs b/src/parser/event_parser/parser.rs index bec9dbab4..a1a0ebfea 100644 --- a/src/parser/event_parser/parser.rs +++ b/src/parser/event_parser/parser.rs | |||
@@ -88,12 +88,8 @@ impl<'t> Parser<'t> { | |||
88 | kind | 88 | kind |
89 | } | 89 | } |
90 | 90 | ||
91 | pub(crate) fn lookahead(&self, kinds: &[SyntaxKind]) -> bool { | 91 | pub(crate) fn raw_lookahead(&self, n: usize) -> SyntaxKind { |
92 | if self.tokens[self.pos..].len() < kinds.len() { | 92 | self.tokens.get(self.pos + n).map(|t| t.kind).unwrap_or(EOF) |
93 | return false | ||
94 | } | ||
95 | kinds.iter().zip(self.tokens[self.pos..].iter().map(|t| t.kind)) | ||
96 | .all(|(&k1, k2)| k1 == k2) | ||
97 | } | 93 | } |
98 | 94 | ||
99 | pub(crate) fn curly_block<F: FnOnce(&mut Parser)>(&mut self, f: F) -> bool { | 95 | pub(crate) fn curly_block<F: FnOnce(&mut Parser)>(&mut self, f: F) -> bool { |