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.rs8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/lisp/lex.rs b/src/lisp/lex.rs
index 1a34e53..e514d7f 100644
--- a/src/lisp/lex.rs
+++ b/src/lisp/lex.rs
@@ -210,6 +210,7 @@ fn parse_number<'a>(mut input: &'a str) -> Result<(usize, Token<'a>), ParseError
210fn parse_string<'a>(input: &'a str) -> Result<(usize, Token<'a>), ParseErrorKind> { 210fn parse_string<'a>(input: &'a str) -> Result<(usize, Token<'a>), ParseErrorKind> {
211 // count opening quote 211 // count opening quote
212 let mut size = 1; 212 let mut size = 1;
213 let mut closed = false;
213 let mut chars = input.char_indices().skip(1); 214 let mut chars = input.char_indices().skip(1);
214 while let Some((ind, chr)) = chars.next() { 215 while let Some((ind, chr)) = chars.next() {
215 match chr { 216 match chr {
@@ -218,12 +219,17 @@ fn parse_string<'a>(input: &'a str) -> Result<(usize, Token<'a>), ParseErrorKind
218 } 219 }
219 '"' => { 220 '"' => {
220 size += ind; 221 size += ind;
222 closed = true;
221 break; 223 break;
222 } 224 }
223 _ => (), 225 _ => (),
224 } 226 }
225 } 227 }
226 return Ok((size, Token::String(&input[..size]))); 228 if !closed {
229 Err(ParseErrorKind::UnterminatedString)
230 } else {
231 Ok((size, Token::String(&input[..size])))
232 }
227} 233}
228 234
229fn is_ident(ch: char) -> bool { 235fn is_ident(ch: char) -> bool {