From bf75bfec8d060cd786588d838f3536efd5ae7596 Mon Sep 17 00:00:00 2001 From: Jan Moringen Date: Fri, 26 Jul 2024 17:09:18 +0200 Subject: [PATCH] Add limited evaluation of feature expressions --- code/client.lisp | 5 ++++- test/test.lisp | 9 +++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/code/client.lisp b/code/client.lisp index ce07316..890fc33 100644 --- a/code/client.lisp +++ b/code/client.lisp @@ -17,7 +17,10 @@ (defmethod reader:evaluate-feature-expression ((client client) (feature-expression t)) - nil) + (let ((features (eclector.reader:state-value client '*features*))) + (and (typep feature-expression 'symbol-token) + (find (name feature-expression) features :test #'string= + :key 'symbol-name)))) ;;; Read-time evaluation diff --git a/test/test.lisp b/test/test.lisp index 8ff2180..90441e9 100644 --- a/test/test.lisp +++ b/test/test.lisp @@ -67,6 +67,15 @@ (inc:block-comment-wad ((0 3) (0 8)) () (inc:word-wad ((0 5) (0 6)))) (inc:atom-wad ((0 8) (0 9)) (:raw 1))))) + ("#+common-lisp 1" + `((inc:read-positive-conditional-wad ((0 0) (0 15)) + (:feature-expression (inc:existing-symbol-token + :symbol ("KEYWORD" "COMMON-LISP"))) + ,(expected-symbol-wad '((0 2) (0 13)) "COMMON-LISP" + :token-class 'inc:existing-symbol-token + :package-name "KEYWORD" + :words '(:ignore-children)) + (inc:atom-wad ((0 14) (0 15)) (:raw 1))))) ("#+a b" `((inc:skipped-positive-conditional-wad ((0 0) (0 5)) (:feature-expression (inc:existing-symbol-token :symbol ("KEYWORD" "A")))