fixed random spaces inside identifiers
This commit is contained in:
parent
4476e1db96
commit
054c8d2fb7
2 changed files with 11 additions and 9 deletions
10
src/lexer.rs
10
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>)
|
|||
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;
|
||||
|
|
10
test.as
10
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
|
||||
gethelj a = 1
|
||||
gethelj b = a + 2
|
Loading…
Add table
Add a link
Reference in a new issue