From ae708091a636570bc4a2fae870f65986b1251df5 Mon Sep 17 00:00:00 2001 From: ConnorSkees <39542938+ConnorSkees@users.noreply.github.com> Date: Mon, 27 Jan 2020 17:21:18 -0500 Subject: [PATCH] Allow numbers in variable names --- src/lexer.rs | 2 +- tests/main.rs | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/lexer.rs b/src/lexer.rs index aa49ba6..9f25577 100644 --- a/src/lexer.rs +++ b/src/lexer.rs @@ -372,7 +372,7 @@ impl<'a> Lexer<'a> { self.pos.next_char(); let mut name = String::with_capacity(99); while let Some(c) = self.buf.peek() { - if !c.is_alphabetic() && c != &'-' && c != &'_' { + if !c.is_alphanumeric() && c != &'-' && c != &'_' { break; } let tok = self diff --git a/tests/main.rs b/tests/main.rs index 53e2cae..30ec77b 100644 --- a/tests/main.rs +++ b/tests/main.rs @@ -95,6 +95,11 @@ mod test_variables { "$a: red; a {\n color: #{#{$a}};\n}\n", "a {\n color: red;\n}\n" ); + test!( + numbers_in_variable, + "$var1: red; a {\n color: $var1;\n}\n", + "a {\n color: red;\n}\n" + ); } #[cfg(test)]