Compiler/AST interpreter: Difference between revisions

Corrected a bug with "\\n" and "\n" due to wrong behavior of "unescape". Used regular expression and replacements instead.
(Added output sample.)
(Corrected a bug with "\\n" and "\n" due to wrong behavior of "unescape". Used regular expression and replacements instead.)
Line 2,256:
 
#---------------------------------------------------------------------------------------------------
 
import re
 
proc loadAst(stream: Stream): Node =
Line 2,275 ⟶ 2,277:
return Node(kind: nIdentifier, name: fields[1])
of nString:
returnstr Node(kind: nString,= stringVal: unescape(fields[1]).replacereplacef(re"([^\\])(\\n)", "$1\n").replace(r"\\", r"\").replace("\"", "")
return Node(kind: nString, stringVal: str)
of nInteger:
return Node(kind: nInteger, intVal: parseInt(fields[1]))
Anonymous user