aboutsummaryrefslogtreecommitdiff
path: root/src/lisp/lex.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/lisp/lex.rs')
-rw-r--r--src/lisp/lex.rs7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/lisp/lex.rs b/src/lisp/lex.rs
index 30f49fa..a7b9586 100644
--- a/src/lisp/lex.rs
+++ b/src/lisp/lex.rs
@@ -115,11 +115,13 @@ impl<'a> Lexer<'a> {
115 115
116fn parse_number<'a>(mut input: &'a str) -> Result<(usize, Token<'a>), LispError> { 116fn parse_number<'a>(mut input: &'a str) -> Result<(usize, Token<'a>), LispError> {
117 let mut dot = false; 117 let mut dot = false;
118 let mut minus = false;
118 let mut size = 0; 119 let mut size = 0;
119 let mut chars = input.chars(); 120 let mut chars = input.chars();
120 121
121 if let Some(v) = chars.next() { 122 if let Some(v) = chars.next() {
122 if v == '-' { 123 if v == '-' {
124 minus = true;
123 size += 1; 125 size += 1;
124 input = &input[1..]; 126 input = &input[1..];
125 } else if v.is_digit(10) { 127 } else if v.is_digit(10) {
@@ -143,7 +145,10 @@ fn parse_number<'a>(mut input: &'a str) -> Result<(usize, Token<'a>), LispError>
143 return Err(LispError::ParseError); 145 return Err(LispError::ParseError);
144 } 146 }
145 } 147 }
146 let tok = if dot { 148
149 let tok = if size == 1 && minus {
150 Token::Name("-")
151 } else if dot {
147 Token::Float(&input[..size]) 152 Token::Float(&input[..size])
148 } else { 153 } else {
149 Token::Integer(&input[..size]) 154 Token::Integer(&input[..size])