diff options
Diffstat (limited to 'crates/libsyntax2/src/lexer/mod.rs')
-rw-r--r-- | crates/libsyntax2/src/lexer/mod.rs | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/crates/libsyntax2/src/lexer/mod.rs b/crates/libsyntax2/src/lexer/mod.rs index f8fdc41ac..3e11db88b 100644 --- a/crates/libsyntax2/src/lexer/mod.rs +++ b/crates/libsyntax2/src/lexer/mod.rs | |||
@@ -67,7 +67,7 @@ fn next_token_inner(c: char, ptr: &mut Ptr) -> SyntaxKind { | |||
67 | _ => (), | 67 | _ => (), |
68 | } | 68 | } |
69 | 69 | ||
70 | let ident_start = is_ident_start(c) && !is_string_literal_start(c, ptr.next(), ptr.nnext()); | 70 | let ident_start = is_ident_start(c) && !is_string_literal_start(c, ptr.current(), ptr.nth(1)); |
71 | if ident_start { | 71 | if ident_start { |
72 | return scan_ident(c, ptr); | 72 | return scan_ident(c, ptr); |
73 | } | 73 | } |
@@ -86,7 +86,7 @@ fn next_token_inner(c: char, ptr: &mut Ptr) -> SyntaxKind { | |||
86 | match c { | 86 | match c { |
87 | // Multi-byte tokens. | 87 | // Multi-byte tokens. |
88 | '.' => { | 88 | '.' => { |
89 | return match (ptr.next(), ptr.nnext()) { | 89 | return match (ptr.current(), ptr.nth(1)) { |
90 | (Some('.'), Some('.')) => { | 90 | (Some('.'), Some('.')) => { |
91 | ptr.bump(); | 91 | ptr.bump(); |
92 | ptr.bump(); | 92 | ptr.bump(); |
@@ -105,7 +105,7 @@ fn next_token_inner(c: char, ptr: &mut Ptr) -> SyntaxKind { | |||
105 | }; | 105 | }; |
106 | } | 106 | } |
107 | ':' => { | 107 | ':' => { |
108 | return match ptr.next() { | 108 | return match ptr.current() { |
109 | Some(':') => { | 109 | Some(':') => { |
110 | ptr.bump(); | 110 | ptr.bump(); |
111 | COLONCOLON | 111 | COLONCOLON |
@@ -114,7 +114,7 @@ fn next_token_inner(c: char, ptr: &mut Ptr) -> SyntaxKind { | |||
114 | }; | 114 | }; |
115 | } | 115 | } |
116 | '=' => { | 116 | '=' => { |
117 | return match ptr.next() { | 117 | return match ptr.current() { |
118 | Some('=') => { | 118 | Some('=') => { |
119 | ptr.bump(); | 119 | ptr.bump(); |
120 | EQEQ | 120 | EQEQ |
@@ -127,7 +127,7 @@ fn next_token_inner(c: char, ptr: &mut Ptr) -> SyntaxKind { | |||
127 | }; | 127 | }; |
128 | } | 128 | } |
129 | '!' => { | 129 | '!' => { |
130 | return match ptr.next() { | 130 | return match ptr.current() { |
131 | Some('=') => { | 131 | Some('=') => { |
132 | ptr.bump(); | 132 | ptr.bump(); |
133 | NEQ | 133 | NEQ |
@@ -136,7 +136,7 @@ fn next_token_inner(c: char, ptr: &mut Ptr) -> SyntaxKind { | |||
136 | }; | 136 | }; |
137 | } | 137 | } |
138 | '-' => { | 138 | '-' => { |
139 | return if ptr.next_is('>') { | 139 | return if ptr.at('>') { |
140 | ptr.bump(); | 140 | ptr.bump(); |
141 | THIN_ARROW | 141 | THIN_ARROW |
142 | } else { | 142 | } else { |
@@ -147,14 +147,14 @@ fn next_token_inner(c: char, ptr: &mut Ptr) -> SyntaxKind { | |||
147 | // If the character is an ident start not followed by another single | 147 | // If the character is an ident start not followed by another single |
148 | // quote, then this is a lifetime name: | 148 | // quote, then this is a lifetime name: |
149 | '\'' => { | 149 | '\'' => { |
150 | return if ptr.next_is_p(is_ident_start) && !ptr.nnext_is('\'') { | 150 | return if ptr.at_p(is_ident_start) && !ptr.at_str("''") { |
151 | ptr.bump(); | 151 | ptr.bump(); |
152 | while ptr.next_is_p(is_ident_continue) { | 152 | while ptr.at_p(is_ident_continue) { |
153 | ptr.bump(); | 153 | ptr.bump(); |
154 | } | 154 | } |
155 | // lifetimes shouldn't end with a single quote | 155 | // lifetimes shouldn't end with a single quote |
156 | // if we find one, then this is an invalid character literal | 156 | // if we find one, then this is an invalid character literal |
157 | if ptr.next_is('\'') { | 157 | if ptr.at('\'') { |
158 | ptr.bump(); | 158 | ptr.bump(); |
159 | return CHAR; // TODO: error reporting | 159 | return CHAR; // TODO: error reporting |
160 | } | 160 | } |
@@ -186,7 +186,7 @@ fn next_token_inner(c: char, ptr: &mut Ptr) -> SyntaxKind { | |||
186 | } | 186 | } |
187 | 187 | ||
188 | fn scan_ident(c: char, ptr: &mut Ptr) -> SyntaxKind { | 188 | fn scan_ident(c: char, ptr: &mut Ptr) -> SyntaxKind { |
189 | let is_single_letter = match ptr.next() { | 189 | let is_single_letter = match ptr.current() { |
190 | None => true, | 190 | None => true, |
191 | Some(c) if !is_ident_continue(c) => true, | 191 | Some(c) if !is_ident_continue(c) => true, |
192 | _ => false, | 192 | _ => false, |
@@ -202,7 +202,7 @@ fn scan_ident(c: char, ptr: &mut Ptr) -> SyntaxKind { | |||
202 | } | 202 | } |
203 | 203 | ||
204 | fn scan_literal_suffix(ptr: &mut Ptr) { | 204 | fn scan_literal_suffix(ptr: &mut Ptr) { |
205 | if ptr.next_is_p(is_ident_start) { | 205 | if ptr.at_p(is_ident_start) { |
206 | ptr.bump(); | 206 | ptr.bump(); |
207 | } | 207 | } |
208 | ptr.bump_while(is_ident_continue); | 208 | ptr.bump_while(is_ident_continue); |