aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-02-20 12:03:31 +0000
committerAleksey Kladov <[email protected]>2019-02-20 12:03:31 +0000
commit9d0cda4bc84350961f3884e75a1c20e62c449ede (patch)
tree729e693ca2f457f60162effbb94639da5103e4a8 /crates
parentdf6efe62c573c98bd0ea9eb137b4c8a5838f5a4a (diff)
slightly better name
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_syntax/src/grammar/expressions.rs4
-rw-r--r--crates/ra_syntax/src/parser_api.rs24
-rw-r--r--crates/ra_syntax/src/parser_impl.rs4
3 files changed, 20 insertions, 12 deletions
diff --git a/crates/ra_syntax/src/grammar/expressions.rs b/crates/ra_syntax/src/grammar/expressions.rs
index 28fcb1f7d..d5a4f4d7b 100644
--- a/crates/ra_syntax/src/grammar/expressions.rs
+++ b/crates/ra_syntax/src/grammar/expressions.rs
@@ -138,7 +138,7 @@ enum Op {
138} 138}
139 139
140fn current_op(p: &Parser) -> (u8, Op) { 140fn current_op(p: &Parser) -> (u8, Op) {
141 if let Some(t) = p.next3() { 141 if let Some(t) = p.current3() {
142 match t { 142 match t {
143 (L_ANGLE, L_ANGLE, EQ) => return (1, Op::Composite(SHLEQ, 3)), 143 (L_ANGLE, L_ANGLE, EQ) => return (1, Op::Composite(SHLEQ, 3)),
144 (R_ANGLE, R_ANGLE, EQ) => return (1, Op::Composite(SHREQ, 3)), 144 (R_ANGLE, R_ANGLE, EQ) => return (1, Op::Composite(SHREQ, 3)),
@@ -146,7 +146,7 @@ fn current_op(p: &Parser) -> (u8, Op) {
146 } 146 }
147 } 147 }
148 148
149 if let Some(t) = p.next2() { 149 if let Some(t) = p.current2() {
150 match t { 150 match t {
151 (PLUS, EQ) => return (1, Op::Composite(PLUSEQ, 2)), 151 (PLUS, EQ) => return (1, Op::Composite(PLUSEQ, 2)),
152 (MINUS, EQ) => return (1, Op::Composite(MINUSEQ, 2)), 152 (MINUS, EQ) => return (1, Op::Composite(MINUSEQ, 2)),
diff --git a/crates/ra_syntax/src/parser_api.rs b/crates/ra_syntax/src/parser_api.rs
index 504df753e..dc556190d 100644
--- a/crates/ra_syntax/src/parser_api.rs
+++ b/crates/ra_syntax/src/parser_api.rs
@@ -25,6 +25,22 @@ impl<'t> Parser<'t> {
25 self.nth(0) 25 self.nth(0)
26 } 26 }
27 27
28 /// Returns the kinds of the current two tokens, if they are not separated
29 /// by trivia.
30 ///
31 /// Useful for parsing things like `>>`.
32 pub(crate) fn current2(&self) -> Option<(SyntaxKind, SyntaxKind)> {
33 self.0.current2()
34 }
35
36 /// Returns the kinds of the current three tokens, if they are not separated
37 /// by trivia.
38 ///
39 /// Useful for parsing things like `=>>`.
40 pub(crate) fn current3(&self) -> Option<(SyntaxKind, SyntaxKind, SyntaxKind)> {
41 self.0.current3()
42 }
43
28 /// Lookahead operation: returns the kind of the next nth 44 /// Lookahead operation: returns the kind of the next nth
29 /// token. 45 /// token.
30 pub(crate) fn nth(&self, n: u32) -> SyntaxKind { 46 pub(crate) fn nth(&self, n: u32) -> SyntaxKind {
@@ -41,14 +57,6 @@ impl<'t> Parser<'t> {
41 kinds.contains(self.current()) 57 kinds.contains(self.current())
42 } 58 }
43 59
44 pub(crate) fn next2(&self) -> Option<(SyntaxKind, SyntaxKind)> {
45 self.0.next2()
46 }
47
48 pub(crate) fn next3(&self) -> Option<(SyntaxKind, SyntaxKind, SyntaxKind)> {
49 self.0.next3()
50 }
51
52 /// Checks if the current token is contextual keyword with text `t`. 60 /// Checks if the current token is contextual keyword with text `t`.
53 pub(crate) fn at_contextual_kw(&self, t: &str) -> bool { 61 pub(crate) fn at_contextual_kw(&self, t: &str) -> bool {
54 self.0.at_kw(t) 62 self.0.at_kw(t)
diff --git a/crates/ra_syntax/src/parser_impl.rs b/crates/ra_syntax/src/parser_impl.rs
index 1f43aa9f9..01d156899 100644
--- a/crates/ra_syntax/src/parser_impl.rs
+++ b/crates/ra_syntax/src/parser_impl.rs
@@ -82,7 +82,7 @@ impl<'t> ParserImpl<'t> {
82 self.events 82 self.events
83 } 83 }
84 84
85 pub(super) fn next2(&self) -> Option<(SyntaxKind, SyntaxKind)> { 85 pub(super) fn current2(&self) -> Option<(SyntaxKind, SyntaxKind)> {
86 let c1 = self.parser_input.kind(self.pos); 86 let c1 = self.parser_input.kind(self.pos);
87 let c2 = self.parser_input.kind(self.pos + 1); 87 let c2 = self.parser_input.kind(self.pos + 1);
88 if self.parser_input.token_start_at(self.pos + 1) 88 if self.parser_input.token_start_at(self.pos + 1)
@@ -94,7 +94,7 @@ impl<'t> ParserImpl<'t> {
94 } 94 }
95 } 95 }
96 96
97 pub(super) fn next3(&self) -> Option<(SyntaxKind, SyntaxKind, SyntaxKind)> { 97 pub(super) fn current3(&self) -> Option<(SyntaxKind, SyntaxKind, SyntaxKind)> {
98 let c1 = self.parser_input.kind(self.pos); 98 let c1 = self.parser_input.kind(self.pos);
99 let c2 = self.parser_input.kind(self.pos + 1); 99 let c2 = self.parser_input.kind(self.pos + 1);
100 let c3 = self.parser_input.kind(self.pos + 2); 100 let c3 = self.parser_input.kind(self.pos + 2);