From a2e471620d928310530d10dc1618c43db4deef78 Mon Sep 17 00:00:00 2001 From: Patrick Pelissier Date: Mon, 18 Apr 2022 09:24:32 +0200 Subject: [PATCH] Add support for '_' meta keyword --- m-core.h | 3 ++- tests/test-mcore.c | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/m-core.h b/m-core.h index c6d4a9cf..5b9fc8f6 100644 --- a/m-core.h +++ b/m-core.h @@ -1156,7 +1156,7 @@ M_BEGIN_PROTECTED_CODE #define M_PATTERN_queue_queue , #define M_PATTERN_QUEUE_QUEUE , #define M_PATTERN_INIT_WITH_INIT_WITH , - +#define M_PATTERN____ , /* Extract the VA ARGS of a keyword function like. Transform 'LIST( a, b, c)' into 'a, b, c' for keyword=LIST @@ -1167,6 +1167,7 @@ M_BEGIN_PROTECTED_CODE #define M_EAT_KEYWORD_LIST_LIST(...) __VA_ARGS__ #define M_EAT_KEYWORD_SEQ_SEQ(...) __VA_ARGS__ #define M_EAT_KEYWORD_QUEUE_QUEUE(...) __VA_ARGS__ +#define M_EAT_KEYWORD____(...) __VA_ARGS__ /* Necessary macros to handle recursivity, diff --git a/tests/test-mcore.c b/tests/test-mcore.c index 3583303a..01a99b29 100644 --- a/tests/test-mcore.c +++ b/tests/test-mcore.c @@ -406,6 +406,9 @@ static void test_test(void) assert(M_KEYWORD_P(sum, add)); assert(M_KEYWORD_P(product, product)); assert(M_KEYWORD_P(product, mul)); + assert(!M_KEYWORD_P(product, mul2)); + assert(M_KEYWORD_P(_, _)); + assert(M_KEYWORD_P(_, _() )); assert(M_KEYWORD_P(LIST, LIST)); assert(M_KEYWORD_P(LIST, LIST(1,23,4) )); @@ -416,6 +419,7 @@ static void test_test(void) assert(M_GET_AT( ( M_KEYWORD_TO_VA_ARGS(LIST, LIST(11, 22, 33)) ), 0) == 11); assert(M_GET_AT( ( M_KEYWORD_TO_VA_ARGS(LIST, LIST(11, 22, 33)) ), 1) == 22); assert(M_GET_AT( ( M_KEYWORD_TO_VA_ARGS(LIST, LIST(11, 22, 33)) ), 2) == 33); + assert(M_KEYWORD_TO_VA_ARGS(_, _(10)) == 10); } static void test_list(void)