Factorize in m-core.h the pattern recognication.
This commit is contained in:
1 parent
86b6ad54d5
commit
068d023917
2 files changed
+21
-12
No files matched your search
@@ -866,15 +866,6 @@
|
||||
} while (0)
|
||||
|
||||
|
||||
/* The different special patterns which will interpret as special */
|
||||
#define ALGOI_PATTERN_and_and ,
|
||||
#define ALGOI_PATTERN_or_or ,
|
||||
#define ALGOI_PATTERN_sum_sum ,
|
||||
#define ALGOI_PATTERN_sum_add ,
|
||||
/* Test function for theses patterns */
|
||||
#define ALGOI_REDUCE_IS_FUNC(refFunc, reduceFunc) \
|
||||
M_COMMA_P(M_C4(ALGOI_PATTERN_, refFunc, _, reduceFunc))
|
||||
|
||||
/* The special function handler */
|
||||
#define ALGOI_REDUCE_AND(a,b) ((a) &= (b))
|
||||
#define ALGOI_REDUCE_OR(a,b) ((a) |= (b))
|
||||
@@ -884,11 +875,11 @@
|
||||
It returns the special function handler if function is and, or, sum or add.
|
||||
Otherwise it returns the original function */
|
||||
#define ALGOI_REDUCE_FUNC(reduceFunc) \
|
||||
M_IF(ALGOI_REDUCE_IS_FUNC(and, reduceFunc)) \
|
||||
M_IF(M_KEYWORD_P(and, reduceFunc)) \
|
||||
(ALGOI_REDUCE_AND, \
|
||||
M_IF(ALGOI_REDUCE_IS_FUNC(or, reduceFunc)) \
|
||||
M_IF(M_KEYWORD_P(or, reduceFunc)) \
|
||||
(ALGOI_REDUCE_OR, \
|
||||
M_IF(ALGOI_REDUCE_IS_FUNC(sum, reduceFunc)) \
|
||||
M_IF(M_KEYWORD_P(sum, reduceFunc)) \
|
||||
(ALGOI_REDUCE_SUM, reduceFunc) \
|
||||
) \
|
||||
)
|
||||
|
||||
@@ -802,6 +802,24 @@ extern void m_no_default_function(void) __attribute__((error("The requested op
|
||||
#define M_PARENTHESISI_DETECT(...) 0, 1,
|
||||
#define M_PARENTHESIS_P(...) M_AND(M_COMMA_P(M_PARENTHESISI_DETECT __VA_ARGS__), M_INV(M_COMMA_P(__VA_ARGS__)))
|
||||
|
||||
|
||||
/* Return 1 if argument type or variable or function is the keyword.
|
||||
- refFunc is the reference keyword.
|
||||
It shall be either 'and', 'or', 'sum' (equivalent to 'add'), 'bool'
|
||||
- testedFunc is the tested keyword.
|
||||
It cannot start with a special character */
|
||||
#define M_KEYWORD_P(refFunc, testedFunc) \
|
||||
M_COMMA_P(M_C4(M_PATTERN_, refFunc, _, testedFunc))
|
||||
/* The different special recognized patterns: */
|
||||
#define M_PATTERN_and_and ,
|
||||
#define M_PATTERN_or_or ,
|
||||
#define M_PATTERN_sum_sum ,
|
||||
#define M_PATTERN_sum_add ,
|
||||
#define M_PATTERN_add_add ,
|
||||
#define M_PATTERN_add_sum ,
|
||||
#define M_PATTERN_bool_bool ,
|
||||
|
||||
|
||||
/* Necessary macros to handle recursivity,
|
||||
delaying the evaluation by one (or more) level of macro expansion.
|
||||
The argument is a macro-function which has to be deferred */
|
||||
|
||||
Reference in new issue
Block a user