Skip to content

Instantly share code, notes, and snippets.

@sejr
Created November 1, 2018 19:05
Show Gist options
  • Save sejr/3daf793408f16963b5b5989a500b1c0b to your computer and use it in GitHub Desktop.
Save sejr/3daf793408f16963b5b5989a500b1c0b to your computer and use it in GitHub Desktop.
/// 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