This commit is contained in:
parent
a74b520231
commit
eb4b8963fc
1 changed files with 12 additions and 1 deletions
13
src/lib.rs
13
src/lib.rs
|
@ -95,12 +95,17 @@ impl Lexer {
|
|||
tokens.push(self.consume_comment());
|
||||
} else {
|
||||
match c {
|
||||
// TODO Implement operands like +=
|
||||
'+' | '-' | '*' | '/' | '%' | '&' | '|' | '^' | '!' | '=' | '<' | '>' | '?' => {
|
||||
tokens.push(self.consume_operator());
|
||||
}
|
||||
_ => {
|
||||
'{' | '}' | '(' | ')' | '#' | ',' | ';' => {
|
||||
tokens.push(self.consume_symbol());
|
||||
}
|
||||
|
||||
_ => {
|
||||
tokens.push(self.consume_unknown());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -125,6 +130,12 @@ impl Lexer {
|
|||
}
|
||||
}
|
||||
|
||||
fn consume_unknown(&mut self) -> Token {
|
||||
let unknown = self.current_char.unwrap();
|
||||
self.advance();
|
||||
Token::Unknown(unknown)
|
||||
}
|
||||
|
||||
fn consume_identifier_or_keyword(&mut self) -> Token {
|
||||
let mut identifier = String::new();
|
||||
while let Some(c) = self.current_char {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue