raw strings

This commit is contained in:
2021-01-24 17:25:15 -07:00
parent 48a7fb4f73
commit 9dd9c2d13d
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) -> CallExp(assertRead(stream, k), readExpArray(stream, ")", k));
readTable["["] = (stream, k) -> ListExp(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) -> { readTable["/*"] = (stream, k) -> {
stream.takeUntilAndDrop("*/"); stream.takeUntilAndDrop("*/");
null; null;

View File

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

View File

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

View File

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