allow letters after underscore in variables, eg. x_a

This commit is contained in:
PaddiM8 2020-12-09 10:47:46 +01:00
parent ee6a4066da
commit 4d17210b49
4 changed files with 7 additions and 7 deletions

4
Cargo.lock generated
View File

@ -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",

View File

@ -1,6 +1,6 @@
[package]
name = "kalk"
version = "0.2.1"
version = "0.2.2"
authors = ["PaddiM8"]
edition = "2018"
readme = "README.md"

View File

@ -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;

View File

@ -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"