On Saturday, 17 August 2013 at 05:05:12 UTC, H. S. Teoh wrote:
On Sat, Aug 17, 2013 at 06:53:16AM +0200, Alan wrote:
Hello! The past few hours I've been working on some things and I
came accross a small bug.

I'm essentially practicing lexing and parsing by implementing a
(very) simple language. Everything is going great so far (variable declarations, writing to stdout etc...) but I have a small problem with my string literals. I've got them working fine, quotes can be escaped etc... But when they include the new line character (\n) for example and it's written out it doesn't create a new line but prints
out those characters raw.  Does anyone have any idea why?
Any help is very much appreciated!

Which quotation marks did you use for your string literals?

If you use double quotes, then it should work: "\n"

But if you use the other quoting syntaxes, the \n may be treated
literally rather than as an escape sequence, e.g., `\n` is a string of
two characters '\' and 'n'.


T

I don't think it matters how my string literals are recoginized, they can be recognized by double or single quotes. Either way the value is stored in a string then written out, but \n is written out raw for some reason.

Reply via email to