diff options
author | Akshay <[email protected]> | 2021-03-27 07:46:25 +0000 |
---|---|---|
committer | Akshay <[email protected]> | 2021-03-27 07:46:25 +0000 |
commit | f94f22a3d0aeff98cc9169c94b683aa139e9c81c (patch) | |
tree | 6033f8601cdf33681b3fff1ab95be3ee12f4a176 /src/lisp/parse.rs | |
parent | 5824a40847ad9ae1f66dad3d9caa069d03f2a832 (diff) |
implement char literals
Diffstat (limited to 'src/lisp/parse.rs')
-rw-r--r-- | src/lisp/parse.rs | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/lisp/parse.rs b/src/lisp/parse.rs index 4e0f427..7cca434 100644 --- a/src/lisp/parse.rs +++ b/src/lisp/parse.rs | |||
@@ -58,7 +58,12 @@ impl<'lex> Parser<'lex> { | |||
58 | .parse::<i64>() | 58 | .parse::<i64>() |
59 | .map(|n| LispExpr::Number(LispNumber::Integer(n))) | 59 | .map(|n| LispExpr::Number(LispNumber::Integer(n))) |
60 | .map_err(|_| ParseError::new(span, ParseErrorKind::LiteralParseError).into()), | 60 | .map_err(|_| ParseError::new(span, ParseErrorKind::LiteralParseError).into()), |
61 | Token::String(s) => Ok(LispExpr::StringLit(s.into())), | 61 | Token::String(s) => Ok(LispExpr::StringLit(s[1..s.len() - 1].into())), |
62 | Token::Char(s) => Ok(LispExpr::Char(s.chars().nth(2).ok_or_else( | ||
63 | || -> LispError { | ||
64 | ParseError::new(span, ParseErrorKind::LiteralParseError).into() | ||
65 | }, | ||
66 | )?)), | ||
62 | Token::Name(n) => Ok(name_expr(n)), | 67 | Token::Name(n) => Ok(name_expr(n)), |
63 | Token::BackQuote => { | 68 | Token::BackQuote => { |
64 | total_backticks += 1; | 69 | total_backticks += 1; |