Closed cpfr closed 9 years ago
Hey,
could you add some test cases using these escape sequences and a print()
statement?
I modified the PrintString test case so that it now also consideres escape sequences
The code looks fine. I would merge it within the next few days if noone else objects.
It would be nice to have a lot more test cases:
print/PrintChar.monty
with the different variances of escape sequencesprint/PrintString.monty
with the different variances of escape sequencesEach of those are different control paths within the source code. With different variances I mean at least all the special cases of control sequenes ('\t', '\b', '\n', ...).
The most recent commit adds test cases for all special escape sequences.
I also noticed that my first attempt to parse \uXXXX escape sequences was wrong, since it expected the 16 bit code to be UTF-8 encoded already. However, the XXXX code is expected to be a unicode index (different from the actual UTF-8 codes).
I fixed this and also added unicode support for String literals (meaning that you can directly type "Hällo Wörld"
).
Hi there,
I implemented the escape sequences in String literals, as suggested by the language specification. The current version in the master branch does not support escape sequences like
print("Hello\nWorld")
etc. Instead one had to literally break the String like that:This merge request fixes that issue and also introduces the following escape sequences:
\t
for horizontal tabs\b
for backspace\n
for line feeds\r
for carriage returns\'
for single quotes (those do not have to be escaped in Strings, but it is allowed to do so by specification)\"
for double quotes\\
for backslashes\uxxxx
for unicode symbols, where xxxx is a 16 bit hexadecimal UTF-8 codeAll of the mentioned escape sequences, except the unicode one are also implemented for Char literals. Unicode is not implemented for Char since the current implementation of this type seems to be restricted to 8 bit.