diff options
Diffstat (limited to 'cs/reader.cs')
| -rw-r--r-- | cs/reader.cs | 9 |
1 files changed, 6 insertions, 3 deletions
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 { |
