From 1773146668b6b90261889db537b4984944606991 Mon Sep 17 00:00:00 2001 From: Nat Quayle Nelson Date: Fri, 31 Oct 2025 18:28:36 -0500 Subject: [PATCH] Hastily implement a quick new type of alias --- src/kiss/Reader.hx | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/kiss/Reader.hx b/src/kiss/Reader.hx index a531938..4b69bd6 100644 --- a/src/kiss/Reader.hx +++ b/src/kiss/Reader.hx @@ -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();