aboutsummaryrefslogtreecommitdiff
path: root/crates/libsyntax2/src/parser_impl/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/libsyntax2/src/parser_impl/mod.rs')
-rw-r--r--crates/libsyntax2/src/parser_impl/mod.rs25
1 files changed, 18 insertions, 7 deletions
diff --git a/crates/libsyntax2/src/parser_impl/mod.rs b/crates/libsyntax2/src/parser_impl/mod.rs
index 06c16cdb4..14cceced5 100644
--- a/crates/libsyntax2/src/parser_impl/mod.rs
+++ b/crates/libsyntax2/src/parser_impl/mod.rs
@@ -65,15 +65,26 @@ impl<'t> ParserImpl<'t> {
65 self.events 65 self.events
66 } 66 }
67 67
68 pub(super) fn at_compound2(&self, c1: SyntaxKind, c2: SyntaxKind) -> bool { 68 pub(super) fn next2(&self) -> Option<(SyntaxKind, SyntaxKind)> {
69 self.inp.kind(self.pos) == c1 && self.inp.kind(self.pos + 1) == c2 69 let c1 = self.inp.kind(self.pos);
70 && self.inp.start(self.pos + 1) == self.inp.start(self.pos) + self.inp.len(self.pos) 70 let c2 = self.inp.kind(self.pos + 1);
71 if self.inp.start(self.pos + 1) == self.inp.start(self.pos) + self.inp.len(self.pos) {
72 Some((c1, c2))
73 } else {
74 None
75 }
71 } 76 }
72 77
73 pub(super) fn at_compound3(&self, c1: SyntaxKind, c2: SyntaxKind, c3: SyntaxKind) -> bool { 78 pub(super) fn next3(&self) -> Option<(SyntaxKind, SyntaxKind, SyntaxKind)> {
74 self.inp.kind(self.pos) == c1 && self.inp.kind(self.pos + 1) == c2 && self.inp.kind(self.pos + 2) == c3 79 let c1 = self.inp.kind(self.pos);
75 && self.inp.start(self.pos + 1) == self.inp.start(self.pos) + self.inp.len(self.pos) 80 let c2 = self.inp.kind(self.pos + 1);
76 && self.inp.start(self.pos + 2) == self.inp.start(self.pos + 1) + self.inp.len(self.pos + 1) 81 let c3 = self.inp.kind(self.pos + 2);
82 if self.inp.start(self.pos + 1) == self.inp.start(self.pos) + self.inp.len(self.pos)
83 && self.inp.start(self.pos + 2) == self.inp.start(self.pos + 1) + self.inp.len(self.pos + 1){
84 Some((c1, c2, c3))
85 } else {
86 None
87 }
77 } 88 }
78 89
79 pub(super) fn nth(&self, n: u32) -> SyntaxKind { 90 pub(super) fn nth(&self, n: u32) -> SyntaxKind {