raw strings

This commit is contained in:
2021-01-24 17:25:15 -07:00
parent b973158777
commit bce35bc6c0
4 changed files with 13 additions and 3 deletions

View File

@@ -47,7 +47,9 @@ class Reader {
readTable["("] = (stream, k) -> CallExp(assertRead(stream, k), readExpArray(stream, ")", k));
readTable["["] = (stream, k) -> ListExp(readExpArray(stream, "]", k));
readTable["\""] = (stream, k) -> StrExp(stream.expect("closing \"", () -> stream.takeUntilAndDrop("\"")));
readTable['"'] = readString;
readTable["#"] = readRawString;
readTable["/*"] = (stream, k) -> {
stream.takeUntilAndDrop("*/");
null;

View File

@@ -76,7 +76,7 @@ class Stream {
var lineLengths = [];
/** Every drop call should end up calling dropChars() or the position tracker will be wrong. **/
private function dropChars(count:Int) {
public function dropChars(count:Int) {
for (idx in 0...count) {
switch (content.charAt(idx)) {
case "\n":

View File

@@ -273,6 +273,10 @@ class BasicTestCase extends Test {
function testPatternLets() {
_testPatternLets();
}
function testRawString() {
_testRawString();
}
}
class BasicObject {

View File

@@ -454,4 +454,8 @@
(Assert.fail))
(unlessLet [(Some (or 5 6)) some5]
(print "something else went wrong!")
(Assert.fail))))
(Assert.fail))))
(defun _testRawString []
(Assert.equals #| "\\" |# #"\"#)
(Assert.equals #| "\"#" |# ##""#"##))