munificent / craftinginterpreters

Repository for the book "Crafting Interpreters"
http://www.craftinginterpreters.com/
Other
8.84k stars 1.04k forks source link

\n in a String is not despecialized #101

Closed forax closed 7 years ago

forax commented 7 years ago

The scanner does not de-specialize '\' character in String.

munificent commented 7 years ago

Yes! Lox supports multi-line strings, but no actual string escapes. I know, weird, right? Escapes are certainly useful in a real language, but they aren't that interesting to teach so I left them out.

Multi-line strings were easier to support than prohibit (I tried both ways and found the code a little cleaner for the former) so I left them in. The Scanning chapter says:

For no particular reason, Lox supports multi-line strings. There are pros and cons to that, but prohibiting them was a little more complex than allowing them, so I left them in.

:neutral_face: