add null, prepare for function
This commit is contained in:
parent
b56bb9a48c
commit
315ccc1504
2 changed files with 34 additions and 8 deletions
10
src/lexer.rs
10
src/lexer.rs
|
@ -40,11 +40,11 @@ fn is_sep(char: &str) -> bool {
|
|||
let chars = vec!["(",")","[","]","{","}",",",".","="];
|
||||
return chars.contains(&char);
|
||||
}
|
||||
fn is_mul_sep(char: &str, next_char: &str) -> bool {
|
||||
/*fn is_mul_sep(char: &str, next_char: &str) -> bool {
|
||||
let chars = vec!["=>"];
|
||||
let check = String::from(char) + next_char;
|
||||
return chars.contains(&check.as_str());
|
||||
}
|
||||
}*/
|
||||
|
||||
fn read_string(splitted: &Vec<&str>, pos: &mut usize, out: &mut Vec<Token>) {
|
||||
let mut str = String::from("");
|
||||
|
@ -100,7 +100,7 @@ fn generate_combinations(words: Vec<&str>) -> Vec<String> {
|
|||
return result;
|
||||
}
|
||||
fn read_identifier(splitted: &Vec<&str>, pos: &mut usize, out: &mut Vec<Token>) {
|
||||
let keywords = vec!["kraf","piszolj","ha nem geny akkor geny","ha nem geny","nem piszv","kopva","gethelj","ha geny","jukadban","lőcsve","nem reti","csecs","megint","reti","piszv","amíg geny"];
|
||||
let keywords = vec!["kraf","piszolj","ha nem geny akkor geny","ha nem geny","nem piszv","kopva","gethelj","ha geny","jukadban","lőcsve","nem reti","csecs","megint","reti","piszv","amíg geny","nincs hám"];
|
||||
let mut raw_keywords: Vec<String> = vec![];
|
||||
for keyword in &keywords {
|
||||
let spi: Vec<&str> = keyword.split(" ").collect();
|
||||
|
@ -239,10 +239,12 @@ pub fn lex(input: String) -> Vec<Token> {
|
|||
read_comment(&splitted, &mut pos, true);
|
||||
} else if is_mul_operator(char, splitted[pos]) {
|
||||
out.push(Token { typ: TokenType::OPERATOR, value: String::from(char) + splitted[pos], pos: pos-1 });
|
||||
pos += 1;
|
||||
} else if is_operator(char) {
|
||||
out.push(Token { typ: TokenType::OPERATOR, value: String::from(char), pos: pos-1 });
|
||||
} else if is_mul_sep(char, splitted[pos]) {
|
||||
/*} else if is_mul_sep(char, splitted[pos]) {
|
||||
out.push(Token { typ: TokenType::SEPARATOR, value: String::from(char) + splitted[pos], pos: pos-1 });
|
||||
pos += 1;*/
|
||||
} else if is_sep(char) {
|
||||
out.push(Token { typ: TokenType::SEPARATOR, value: String::from(char), pos: pos-1 });
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue