Struct rslua_march1917::lexer::Lexer
source · pub struct Lexer { /* private fields */ }Implementations§
source§impl<'a> Lexer
impl<'a> Lexer
pub fn new() -> Self
pub fn set_config(&mut self, config: LexerConfig)
pub fn run(&mut self, input: &'a str) -> Result<&Vec<Token>, LexError>
pub fn tokens(&self) -> &Vec<Token>
sourcepub fn str_to_int(s: &str) -> Option<IntType>
pub fn str_to_int(s: &str) -> Option<IntType>
sourcepub fn str_to_float(s: &str) -> Option<FloatType>
pub fn str_to_float(s: &str) -> Option<FloatType>
sourcepub fn str_to_hex_float(bytes: &[u8]) -> Option<FloatType>
pub fn str_to_hex_float(bytes: &[u8]) -> Option<FloatType>
Examples found in repository?
src/lexer.rs (line 747)
742 743 744 745 746 747 748 749 750 751 752 753 754
pub fn str_to_float(s: &str) -> Option<FloatType> {
let bytes = s.as_bytes();
let mut i = 0;
i = Lexer::skip_spaces(bytes, i);
if Lexer::starts_with_0x(bytes, i) {
Lexer::str_to_hex_float(&bytes[2..])
} else {
match s.parse::<FloatType>() {
Ok(f) => Some(f),
Err(_e) => None,
}
}
}