fixed random spaces inside identifiers

This commit is contained in:
afonya2 2025-04-24 20:39:30 +02:00
parent 4476e1db96
commit 054c8d2fb7
Signed by: afonya
GPG key ID: EBB9C4CAFAAFB2DC
2 changed files with 11 additions and 9 deletions

View file

@ -27,7 +27,7 @@ fn is_operator(char: &str) -> bool {
return chars.contains(&char); return chars.contains(&char);
} }
fn is_sep(char: &str) -> bool { fn is_sep(char: &str) -> bool {
let chars = vec!["(",")","[","]","{","}",",","."]; let chars = vec!["(",")","[","]","{","}",",",".","="];
return chars.contains(&char); return chars.contains(&char);
} }
@ -162,6 +162,14 @@ fn read_identifier(splitted: &Vec<&str>, pos: &mut usize, out: &mut Vec<Token>)
token.typ = TokenType::IDENTIFIER; 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 //Check for identifiers next to each other
let mut i = 1; let mut i = 1;

10
test.as
View file

@ -1,8 +1,2 @@
szaft"Hello, World! gethelj a = 1
ugva"szaft gethelj b = a + 2
64
//ez egy komment
/*ez
is*/420
69+69
ez egy identifier ha nem geny piszolj lőcs