aboutsummaryrefslogtreecommitdiff
path: root/src/lexer
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-01-01 15:58:46 +0000
committerAleksey Kladov <[email protected]>2018-01-01 15:58:46 +0000
commitcb362626f326a565aca34c1a11c95dcb7152b798 (patch)
tree5a1cc081e36b4061f8e9275db9bf14ed71e924f9 /src/lexer
parent0af33a2587e4fb96e5001492792f1e926d576e27 (diff)
Parser: guess what? Groundwork!
Diffstat (limited to 'src/lexer')
-rw-r--r--src/lexer/mod.rs3
-rw-r--r--src/lexer/ptr.rs5
2 files changed, 8 insertions, 0 deletions
diff --git a/src/lexer/mod.rs b/src/lexer/mod.rs
index 7c4259763..bc5344b5f 100644
--- a/src/lexer/mod.rs
+++ b/src/lexer/mod.rs
@@ -187,6 +187,9 @@ fn scan_ident(c: char, ptr: &mut Ptr) -> SyntaxKind {
187 return if c == '_' { UNDERSCORE } else { IDENT }; 187 return if c == '_' { UNDERSCORE } else { IDENT };
188 } 188 }
189 ptr.bump_while(is_ident_continue); 189 ptr.bump_while(is_ident_continue);
190 if let Some(kind) = ident_to_keyword(ptr.current_token_text()) {
191 return kind;
192 }
190 IDENT 193 IDENT
191} 194}
192 195
diff --git a/src/lexer/ptr.rs b/src/lexer/ptr.rs
index 2f759119a..ff6ef11fc 100644
--- a/src/lexer/ptr.rs
+++ b/src/lexer/ptr.rs
@@ -59,6 +59,11 @@ impl<'s> Ptr<'s> {
59 } 59 }
60 } 60 }
61 61
62 pub fn current_token_text(&self) -> &str {
63 let len: u32 = self.len.into();
64 &self.text[..len as usize]
65 }
66
62 fn chars(&self) -> Chars { 67 fn chars(&self) -> Chars {
63 let len: u32 = self.len.into(); 68 let len: u32 = self.len.into();
64 self.text[len as usize ..].chars() 69 self.text[len as usize ..].chars()