End Of Line character and others not working.

H. S. Teoh hsteoh at quickfur.ath.cx
Fri Aug 16 22:03:41 PDT 2013


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

-- 
Written on the window of a clothing store: No shirt, no shoes, no service.


More information about the Digitalmars-d-learn mailing list