Make empty string the default read macro

This commit is contained in:
2020-11-18 19:15:31 -07:00
parent 2832cc55fc
commit 93b6a5d930
2 changed files with 5 additions and 1 deletions

View File

@@ -38,6 +38,9 @@ class Reader {
readTable[":"] = (stream) -> TypedExp(nextToken(stream, "a type path"), assertRead(stream, readTable));
// Because macro keys are sorted by length and peekChars(0) returns "", this will be used as the default reader macro:
readTable[""] = (stream) -> Symbol(nextToken(stream, "a symbol name"));
return readTable;
}
@@ -74,7 +77,7 @@ class Reader {
}
}
return Some(Symbol(nextToken(stream, "a symbol name")));
throw 'No macro to read next expression';
}
public static function readExpArray(stream:Stream, end:String, readTable:Map<String, ReadFunction>):Array<ReaderExp> {

View File

@@ -128,6 +128,7 @@ class BasicTestCase extends Test {
}));
}
// TODO to really test typed variable definitions, check for compilation failure on a bad example
function testTypedDefvar() {
Assert.equals(8, BasicTestCase.myInt);
}