Make empty string the default read macro
This commit is contained in:
@@ -38,6 +38,9 @@ class Reader {
|
|||||||
|
|
||||||
readTable[":"] = (stream) -> TypedExp(nextToken(stream, "a type path"), assertRead(stream, readTable));
|
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;
|
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> {
|
public static function readExpArray(stream:Stream, end:String, readTable:Map<String, ReadFunction>):Array<ReaderExp> {
|
||||||
|
|||||||
@@ -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() {
|
function testTypedDefvar() {
|
||||||
Assert.equals(8, BasicTestCase.myInt);
|
Assert.equals(8, BasicTestCase.myInt);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user