From fd832ac38ec339afa10bada542ac9f150a78bbec Mon Sep 17 00:00:00 2001 From: Scott Richmond Date: Fri, 8 Apr 2022 18:26:36 -0400 Subject: [PATCH] Allow _ as else in cond --- src/ludus/parser.clj | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/ludus/parser.clj b/src/ludus/parser.clj index 040acb7..ffba19a 100644 --- a/src/ludus/parser.clj +++ b/src/ludus/parser.clj @@ -576,11 +576,12 @@ (panic parser "Expected with after match expression")))) (defn- parse-cond-clause [parser] - (let [expr (if (= ::token/else (token-type parser)) + (let [expr (if + (contains? #{::token/else ::token/placeholder} (token-type parser)) (-> parser (advance) (assoc ::ast {::ast/type ::ast/atom - :token ::token/else + :token (current parser) :value true})) (parse-expr parser)) rarrow (expect* #{::token/rarrow} "Expected arrow after expression in cond clause" expr)] @@ -789,9 +790,9 @@ (parser) (parse-script))) -(comment +(do (def pp pp/pprint) - (def source "import \"f\" as foo + (def source "cond { _ -> :foo } ") (def lexed (scanner/scan source))