Hastily implement a quick new type of alias
This commit is contained in:
@@ -231,6 +231,21 @@ class Reader {
|
||||
readTable["->"] = arrowSyntax.bind(false);
|
||||
readTable["-+>"] = arrowSyntax.bind(true);
|
||||
|
||||
// New: Quickly define an "alias" for the next expression and return it.
|
||||
// The catch is that it doesn't have to be a valid symbol--it can be anything that doesn't have a terminator in it.
|
||||
// Also, the 'alias' is made immediately when the expression is first read.
|
||||
// Example:
|
||||
// $>1 (first parts)
|
||||
// (print $1)
|
||||
readTable["$>"] = (stream:Stream, k:HasReadTables) -> {
|
||||
var alias = nextToken(stream, "quick alias");
|
||||
var nextExp = assertRead(stream, k);
|
||||
readTable["$" + alias] = (stream:Stream, k:HasReadTables) -> {
|
||||
nextExp.def;
|
||||
};
|
||||
nextExp.def;
|
||||
};
|
||||
|
||||
// Because macro keys are sorted by length and peekChars(0) returns "", this will be used as the default reader macro:
|
||||
readTable[""] = (stream:Stream, k:HasReadTables) -> {
|
||||
var position = stream.position();
|
||||
|
||||
Reference in New Issue
Block a user