raw strings
This commit is contained in:
@@ -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;
|
||||||
|
@@ -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":
|
||||||
|
@@ -273,6 +273,10 @@ class BasicTestCase extends Test {
|
|||||||
function testPatternLets() {
|
function testPatternLets() {
|
||||||
_testPatternLets();
|
_testPatternLets();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function testRawString() {
|
||||||
|
_testRawString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class BasicObject {
|
class BasicObject {
|
||||||
|
@@ -455,3 +455,7 @@
|
|||||||
(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 #| "\"#" |# ##""#"##))
|
Reference in New Issue
Block a user