redef fun visit(n)
do
- if n != null then
- n.accept_literal(self)
- n.visit_all(self)
- end
+ n.accept_literal(self)
+ n.visit_all(self)
end
end
redef fun accept_literal(v)
do
var txt = self.n_string.text
- self.value = txt.substring(1, txt.length-2).unescape_nit
+ var skip = 1
+ if txt[0] == txt[1] and txt.length >= 6 then skip = 3
+ self.value = txt.substring(skip, txt.length-(2*skip)).unescape_nit
end
end
#
# Example:
# var s = "\\n"
- # print s.length # -> 2
+ # assert s.length == 2
# var u = s.unescape_nit
- # print s.length # -> 1
- # print s[0].ascii # -> 10 (the ASCII value of the "new line" character)
+ # assert u.length == 1
+ # assert u[0].ascii == 10 # (the ASCII value of the "new line" character)
fun unescape_nit: String
do
var res = new Buffer.with_capacity(self.length)