Created
November 1, 2018 19:05
-
-
Save sejr/3daf793408f16963b5b5989a500b1c0b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// When we reach a non-alphanumeric symbol (e.g. `;`, `:`, `.`), we must treat the previous | |
/// current token as a finalized token and push it to our result vector accordingly. This ensures | |
/// that we don't come across a parsing error if someone forgets to use spaces as intended. | |
fn push_token(current: &mut String, result: &mut Vec<Token>, token: Token) { | |
if !current.is_empty() { | |
let current_token = Token::Identifier(current.clone()); | |
result.push(current_token); | |
current.clear(); | |
} | |
result.push(token); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment