Implement escapable characters in strings

This commit is contained in:
Thomas Pelletier
2013-03-26 11:45:36 +01:00
parent 8c48e59100
commit 329092b812
2 changed files with 36 additions and 3 deletions
+12
View File
@@ -311,6 +311,18 @@ func lexString(l *lexer) stateFn {
if l.follow("\\\"") {
l.pos += 1
growing_string += "\""
} else if l.follow("\\n") {
l.pos += 1
growing_string += "\n"
} else if l.follow("\\t") {
l.pos += 1
growing_string += "\t"
} else if l.follow("\\r") {
l.pos += 1
growing_string += "\r"
} else if l.follow("\\\\") {
l.pos += 1
growing_string += "\\"
} else {
growing_string += string(l.peek())
}