aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_syntax/src')
-rw-r--r--crates/ra_syntax/src/parsing/lexer.rs71
1 files changed, 12 insertions, 59 deletions
diff --git a/crates/ra_syntax/src/parsing/lexer.rs b/crates/ra_syntax/src/parsing/lexer.rs
index 3ae42912c..a3791b503 100644
--- a/crates/ra_syntax/src/parsing/lexer.rs
+++ b/crates/ra_syntax/src/parsing/lexer.rs
@@ -88,65 +88,18 @@ fn next_token_inner(c: char, ptr: &mut Ptr) -> SyntaxKind {
88 } 88 }
89 89
90 match c { 90 match c {
91 // Multi-byte tokens. 91 // Possiblily multi-byte tokens,
92 '.' => { 92 // but we only produce single byte token now
93 return match (ptr.current(), ptr.nth(1)) { 93 // DOTDOTDOT, DOTDOT, DOTDOTEQ, DOT
94 (Some('.'), Some('.')) => { 94 '.' => return DOT,
95 ptr.bump(); 95 // COLONCOLON COLON
96 ptr.bump(); 96 ':' => return COLON,
97 DOTDOTDOT 97 // EQEQ FATARROW EQ
98 } 98 '=' => return EQ,
99 (Some('.'), Some('=')) => { 99 // NEQ EXCL
100 ptr.bump(); 100 '!' => return EXCL,
101 ptr.bump(); 101 // THIN_ARROW MINUS
102 DOTDOTEQ 102 '-' => return MINUS,
103 }
104 (Some('.'), _) => {
105 ptr.bump();
106 DOTDOT
107 }
108 _ => DOT,
109 };
110 }
111 ':' => {
112 return match ptr.current() {
113 Some(':') => {
114 ptr.bump();
115 COLONCOLON
116 }
117 _ => COLON,
118 };
119 }
120 '=' => {
121 return match ptr.current() {
122 Some('=') => {
123 ptr.bump();
124 EQEQ
125 }
126 Some('>') => {
127 ptr.bump();
128 FAT_ARROW
129 }
130 _ => EQ,
131 };
132 }
133 '!' => {
134 return match ptr.current() {
135 Some('=') => {
136 ptr.bump();
137 NEQ
138 }
139 _ => EXCL,
140 };
141 }
142 '-' => {
143 return if ptr.at('>') {
144 ptr.bump();
145 THIN_ARROW
146 } else {
147 MINUS
148 };
149 }
150 103
151 // If the character is an ident start not followed by another single 104 // If the character is an ident start not followed by another single
152 // quote, then this is a lifetime name: 105 // quote, then this is a lifetime name: