Function lexical_scanner::lexer_as_str
source · [−]Expand description
Converts a string to tokens
Input -> text: &str
Return -> Vec
This is comonnly used for debugging and testing.
Example
pub use lexical_scanner::*;
pub use enums::*;
let text = "The number 5.0 is > 1;";
let token_list = lexical_scanner::lexer_as_str(text);
//Display tokens
for (i, token) in token_list.iter().enumerate(){
println!("{}. {:?}", i, token);
}
output ->
0. Word("The")
1. WhiteSpace
2. Word("number")
3. WhiteSpace
4. Floating("5.0")
5. WhiteSpace
6. Word("is")
7. WhiteSpace
8. Gt
9. WhiteSpace
10. Numeric("1")
11. Semi