Created
June 1, 2019 00:03
-
-
Save alejandrolechuga/2432f48b129026692f98ae5417b64eb7 to your computer and use it in GitHub Desktop.
This file contains 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
diff --git a/lexer/src/lib.rs b/lexer/src/lib.rs | |
index 45d6b38..88495f9 100644 | |
--- a/lexer/src/lib.rs | |
+++ b/lexer/src/lib.rs | |
@@ -163,11 +163,22 @@ where I: Iterator<Item = char>, | |
// matches constructs beginning with a digit, e.g. 0.123 or 10e+42 | |
fn digit(&mut self) -> Result<TokenType, LexError> { | |
let mut s = String::new(); | |
+ // is digit 0 | |
+ // is the next thing x | |
+ // next thing should hex digits | |
+ match self.peek() { | |
+ Some(c) if c == 'x'|| c == 'X' => { | |
+ s.push(c); | |
+ return Ok(TokenType::Number(s)); | |
+ }, | |
+ None => return Err(self.unexpected_eof()), | |
+ Some(_) => () | |
+ } | |
// integer part | |
self.push_while(&mut s, is_digit); | |
- // decmal part | |
+ // decimal part | |
if let Some('.') = self.peek() { | |
match self.decimal() { | |
Ok(d) => s.push_str(&d), |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment