From 8e3016e9fee8539428421b0de0675db80ee2a9d8 Mon Sep 17 00:00:00 2001 From: PaddiM8 Date: Wed, 9 Dec 2020 10:47:46 +0100 Subject: [PATCH] allow letters after underscore in variables, eg. x_a --- Cargo.lock | 4 ++-- kalk/Cargo.toml | 2 +- kalk/src/lexer.rs | 4 ++-- kalk_cli/Cargo.toml | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e1bd00a..8e91693 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -92,7 +92,7 @@ dependencies = [ [[package]] name = "kalk" -version = "0.2.1" +version = "0.2.2" dependencies = [ "lazy_static", "phf", @@ -103,7 +103,7 @@ dependencies = [ [[package]] name = "kalk_cli" -version = "0.2.1" +version = "0.2.2" dependencies = [ "ansi_term", "kalk", diff --git a/kalk/Cargo.toml b/kalk/Cargo.toml index 2d0f275..1ac72c7 100644 --- a/kalk/Cargo.toml +++ b/kalk/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "kalk" -version = "0.2.1" +version = "0.2.2" authors = ["PaddiM8"] edition = "2018" readme = "README.md" diff --git a/kalk/src/lexer.rs b/kalk/src/lexer.rs index be0ef66..590c2b6 100644 --- a/kalk/src/lexer.rs +++ b/kalk/src/lexer.rs @@ -153,11 +153,11 @@ impl<'a> Lexer<'a> { while is_valid_identifier(self.peek()) { let c = *self.peek().unwrap(); - // If the current character is an underscore, expect a number next. + // If the current character is an underscore, allow a number next. // This is to allow the notation like the following: x_1 if c == '_' { self.advance(); - let num = self.next_number_literal().value; + let num = self.next().value; value.push('_'); value.push_str(&num.trim_end()); // Trim, since the number_literal function allows whitespace, which identifiers should not contain. break; diff --git a/kalk_cli/Cargo.toml b/kalk_cli/Cargo.toml index 3b5acda..481aba1 100644 --- a/kalk_cli/Cargo.toml +++ b/kalk_cli/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "kalk_cli" -version = "0.2.1" +version = "0.2.2" authors = ["PaddiM8"] edition = "2018" readme = "../README.md" @@ -15,7 +15,7 @@ path = "src/main.rs" name = "kalk" [dependencies] -kalk = { path = "../kalk", version = "^0.2.1" } +kalk = { path = "../kalk", version = "^0.2.2" } rustyline = "6.1.2" ansi_term = "0.12" regex = "1"