mirror of
https://github.com/kanaka/mal.git
synced 2024-11-10 02:45:44 +03:00
Fix unescaping in cs, hy, nim, objpascal, ps, rpython, vb
This commit is contained in:
parent
273226aa74
commit
42aecee642
@ -71,9 +71,10 @@ namespace Mal {
|
||||
} else if (match.Groups[6].Value != String.Empty) {
|
||||
string str = match.Groups[6].Value;
|
||||
str = str.Substring(1, str.Length-2)
|
||||
.Replace("\\\"", "\"")
|
||||
.Replace("\\n", "\n")
|
||||
.Replace("\\\\", "\\");
|
||||
.Replace("\\\\", "\u029e")
|
||||
.Replace("\\\"", "\"")
|
||||
.Replace("\\n", "\n")
|
||||
.Replace("\u029e", "\\");
|
||||
return new Mal.types.MalString(str);
|
||||
} else if (match.Groups[7].Value != String.Empty) {
|
||||
return new Mal.types.MalString("\u029e" + match.Groups[7].Value);
|
||||
|
@ -25,9 +25,10 @@
|
||||
(!= (get t 0) ";")))
|
||||
|
||||
(defn unescape [s]
|
||||
(-> s (.replace "\\\"" "\"")
|
||||
(.replace "\\n" "\n")
|
||||
(.replace "\\\\" "\\")))
|
||||
(-> s (.replace "\\\\" "\u029e")
|
||||
(.replace "\\\"" "\"")
|
||||
(.replace "\\n" "\n")
|
||||
(.replace "\u029e" "\\")))
|
||||
|
||||
(defn read-atom [rdr]
|
||||
(setv token (.next rdr))
|
||||
|
@ -26,10 +26,10 @@ RUN apt-get -y install g++
|
||||
|
||||
# Nim
|
||||
RUN apt-get -y install xz-utils
|
||||
RUN cd /tmp && curl -O http://nim-lang.org/download/nim-0.17.0.tar.xz \
|
||||
&& tar xvJf /tmp/nim-0.17.0.tar.xz && cd nim-0.17.0 \
|
||||
RUN cd /tmp && curl -O https://nim-lang.org/download/nim-0.17.2.tar.xz \
|
||||
&& tar xvJf /tmp/nim-0.17.2.tar.xz && cd nim-0.17.2 \
|
||||
&& make && sh install.sh /usr/local/bin \
|
||||
&& cp bin/nim /usr/local/bin/ \
|
||||
&& rm -r /tmp/nim-0.17.0
|
||||
&& rm -r /tmp/nim-0.17.2
|
||||
|
||||
ENV HOME /mal
|
||||
|
@ -61,7 +61,7 @@ proc read_hash_map(r: var Reader): MalType =
|
||||
proc read_atom(r: var Reader): MalType =
|
||||
let t = r.next
|
||||
if t.match(intRE): number t.parseInt
|
||||
elif t[0] == '"': str t[1 .. <t.high].replace("\\\"", "\"").replace("\\n", "\n").replace("\\\\", "\\")
|
||||
elif t[0] == '"': str t[1 .. <t.high].multiReplace(("\\\"", "\""), ("\\n", "\n"), ("\\\\", "\\"))
|
||||
elif t[0] == ':': keyword t[1 .. t.high]
|
||||
elif t == "nil": nilObj
|
||||
elif t == "true": trueObj
|
||||
|
@ -110,9 +110,10 @@ begin
|
||||
else if RE.Match[6] <> '' then
|
||||
begin
|
||||
Str := copy(Token, 2, Length(Token)-2);
|
||||
Str := StringReplace(Str, '\"', '"', [rfReplaceAll]);
|
||||
Str := StringReplace(Str, '\n', #10, [rfReplaceAll]);
|
||||
Str := StringReplace(Str, '\\', '\', [rfReplaceAll]);
|
||||
Str := StringReplace(Str, '\\', #127, [rfReplaceAll]);
|
||||
Str := StringReplace(Str, '\"', '"', [rfReplaceAll]);
|
||||
Str := StringReplace(Str, '\n', #10, [rfReplaceAll]);
|
||||
Str := StringReplace(Str, #127, '\', [rfReplaceAll]);
|
||||
read_atom := TMalString.Create(Str)
|
||||
end
|
||||
else if RE.Match[7] <> '' then
|
||||
|
@ -102,9 +102,10 @@ end } def
|
||||
/cnt cnt 1 add def
|
||||
} loop
|
||||
str start cnt getinterval % the matched string
|
||||
(\\") (") replace
|
||||
(\\n) (\n) replace
|
||||
(\\\\) (\\) replace
|
||||
(\\\\) (\177) replace
|
||||
(\\") (") replace
|
||||
(\\n) (\n) replace
|
||||
(\177) (\\) replace
|
||||
str idx % return: new_string string new_idx
|
||||
end } def
|
||||
|
||||
|
@ -51,9 +51,9 @@ def read_atom(reader):
|
||||
return MalStr(u"")
|
||||
else:
|
||||
s = unicode(token[1:end])
|
||||
s = types._replace(u'\\\\', u"\u029e", s)
|
||||
s = types._replace(u'\\"', u'"', s)
|
||||
s = types._replace(u'\\n', u"\n", s)
|
||||
s = types._replace(u'\\\\', u"\u029e", s)
|
||||
s = types._replace(u'\\"', u'"', s)
|
||||
s = types._replace(u'\\n', u"\n", s)
|
||||
s = types._replace(u"\u029e", u"\\", s)
|
||||
return MalStr(s)
|
||||
elif token[0] == ':': return _keywordu(unicode(token[1:]))
|
||||
|
@ -83,9 +83,10 @@ Namespace Mal
|
||||
Dim str As String = match.Groups(6).Value
|
||||
return New Mal.types.MalString(
|
||||
str.Substring(1, str.Length-2) _
|
||||
.Replace("\""", """") _
|
||||
.Replace("\n", Environment.NewLine) _
|
||||
.Replace("\\", "\"))
|
||||
.Replace("\\", ChrW(&H029e)) _
|
||||
.Replace("\""", """") _
|
||||
.Replace("\n", Environment.NewLine) _
|
||||
.Replace(ChrW(&H029e), "\"))
|
||||
Else If match.Groups(7).Value <> String.Empty Then
|
||||
return New Mal.types.MalString(ChrW(&H029e) & match.Groups(7).Value)
|
||||
Else If match.Groups(8).Value <> String.Empty Then
|
||||
|
Loading…
Reference in New Issue
Block a user