about summary refs log tree commit diff
path: root/src/lex
diff options
context:
space:
mode:
authorMel <einebeere@gmail.com>2021-10-23 22:26:58 +0200
committerMel <einebeere@gmail.com>2021-10-23 22:26:58 +0200
commit249abe9c33dfd08afa6b09f3e53be91b0f445561 (patch)
tree9756f9bde10ed07e1b6a3f385984c3883cee4f1a /src/lex
parent8a6eb35a900081967db16d313ab7ed470de6570f (diff)
downloadrabbithole-249abe9c33dfd08afa6b09f3e53be91b0f445561.tar.zst
rabbithole-249abe9c33dfd08afa6b09f3e53be91b0f445561.zip
Allow _ in identifiers.
Diffstat (limited to 'src/lex')
-rw-r--r--src/lex/lexer.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/lex/lexer.rs b/src/lex/lexer.rs
index 60301c3..41384a9 100644
--- a/src/lex/lexer.rs
+++ b/src/lex/lexer.rs
@@ -32,7 +32,7 @@ impl Iterator for Lexer<'_> {
 
         let token = if c.is_numeric() {
             self.number()
-        } else if c.is_alphabetic() {
+        } else if c.is_alphabetic() || c == '_' {
             self.identifier()
         } else if c == '"' {
             self.str()
@@ -180,7 +180,7 @@ impl<'s> Lexer<'s> {
 
         let mut buffer = String::new();
 
-        while self.peek().map_or(false, |c| c.is_alphabetic()) {
+        while self.peek().map_or(false, |c| c.is_alphabetic() || c == '_') {
             let c = self.advance().unwrap();
             buffer.push(c);
         }