added string escaping

master
Jordan Orelli 12 years ago
parent ab97429e98
commit 6dd75298e5

@ -8,7 +8,9 @@
4.0 4.0
(dave (dave
1 1
"here's an escaped quote: \" how neat!!!"
2 2
"and here's an escaped \\, sweet!"
albert-camus albert-camus
3 3
(sam 3 2 2))) (sam 3 2 2)))

@ -150,6 +150,17 @@ func lexString(l *lexer) (stateFn, error) {
case '"': case '"':
l.emit(str1ng) l.emit(str1ng)
return lexWhitespace, nil return lexWhitespace, nil
case '\\':
return lexStringEsc, nil
}
l.append(r)
return lexString, nil
}
func lexStringEsc(l *lexer) (stateFn, error) {
r, err := l.next()
if err != nil {
return nil, err
} }
l.append(r) l.append(r)
return lexString, nil return lexString, nil

Loading…
Cancel
Save