From b9c34297a97a0cb9b8d5042baeeb30c4034d73bc Mon Sep 17 00:00:00 2001 From: HAYAMA_Kaoru Date: Tue, 3 Dec 2024 18:15:33 +0900 Subject: [PATCH] Implement `$MATCH` --- global.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/global.go b/global.go index f253824..ac4a5ff 100644 --- a/global.go +++ b/global.go @@ -14,6 +14,7 @@ import ( var ( symTimeout = gmnlisp.NewSymbol("timeout") symInterval = gmnlisp.NewSymbol("interval") + symMatch = gmnlisp.NewSymbol("$MATCH") ) var ErrCtrlC = errors.New("^C") @@ -173,7 +174,8 @@ func (g *Global) expectX(ctx context.Context, w *gmnlisp.World, node gmnlisp.Nod if result == EventCtrlC { return nil, ErrCtrlC } else if result >= 0 { - return gmnlisp.Progn(ctx, w, actions[result]) + _w := w.Let(&gmnlisp.Pair{Key: symMatch, Value: gmnlisp.String(patterns[result])}) + return gmnlisp.Progn(ctx, _w, actions[result]) } else { return gmnlisp.Progn(ctx, w, timeoutAct) }