From 054c8d2fb7b0e741da6eba6e0a59146e01481fb4 Mon Sep 17 00:00:00 2001 From: afonya2 Date: Thu, 24 Apr 2025 20:39:30 +0200 Subject: [PATCH] fixed random spaces inside identifiers --- src/lexer.rs | 10 +++++++++- test.as | 10 ++-------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/lexer.rs b/src/lexer.rs index a3047be..5c7295b 100644 --- a/src/lexer.rs +++ b/src/lexer.rs @@ -27,7 +27,7 @@ fn is_operator(char: &str) -> bool { return chars.contains(&char); } fn is_sep(char: &str) -> bool { - let chars = vec!["(",")","[","]","{","}",",","."]; + let chars = vec!["(",")","[","]","{","}",",",".","="]; return chars.contains(&char); } @@ -162,6 +162,14 @@ fn read_identifier(splitted: &Vec<&str>, pos: &mut usize, out: &mut Vec) token.typ = TokenType::IDENTIFIER; } } + if token.typ == TokenType::IDENTIFIER { + if token.value.starts_with(" ") { + token.value.remove(0); + } + if token.value.ends_with(" ") { + token.value.remove(token.value.len()-1); + } + } } //Check for identifiers next to each other let mut i = 1; diff --git a/test.as b/test.as index c14683c..858b213 100644 --- a/test.as +++ b/test.as @@ -1,8 +1,2 @@ -szaft"Hello, World! -ugva"szaft -64 -//ez egy komment -/*ez -is*/420 -69+69 -ez egy identifier ha nem geny piszolj lőcs \ No newline at end of file +gethelj a = 1 +gethelj b = a + 2 \ No newline at end of file