From afdf531eba459a7a7b6505b037dbe48a363c2c79 Mon Sep 17 00:00:00 2001 From: Joel Martin Date: Mon, 7 Apr 2014 00:17:13 -0500 Subject: CS: add step4_if_fn_do --- cs/reader.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'cs/reader.cs') diff --git a/cs/reader.cs b/cs/reader.cs index 5e38136..a6d22c5 100644 --- a/cs/reader.cs +++ b/cs/reader.cs @@ -52,7 +52,7 @@ namespace Mal { public static MalVal read_atom(Reader rdr) { string token = rdr.next(); - string pattern = @"(^-?[0-9]+$)|(^-?[0-9][0-9.]*$)|(^nil$)|(^true$)|(^false$)|^""(.*)""$|(^[^""]*$)"; + string pattern = @"(^-?[0-9]+$)|(^-?[0-9][0-9.]*$)|(^nil$)|(^true$)|(^false$)|^("".*"")$|(^[^""]*$)"; Regex regex = new Regex(pattern); Match match = regex.Match(token); //Console.WriteLine("token: ^" + token + "$"); @@ -68,8 +68,11 @@ namespace Mal { } else if (match.Groups[5].Value != String.Empty) { return Mal.types.False; } else if (match.Groups[6].Value != String.Empty) { - //return new MalString(StringEscapeUtils.unescapeJson(match.Groups[6])); - return new Mal.types.MalString(match.Groups[6].Value); + string str = match.Groups[6].Value; + str = str.Substring(1, str.Length-2) + .Replace("\\\"", "\"") + .Replace("\\n", "\n"); + return new Mal.types.MalString(str); } else if (match.Groups[7].Value != String.Empty) { return new Mal.types.MalSymbol(match.Groups[7].Value); } else { -- cgit v1.2.3