diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2022-03-28 23:40:14 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2022-03-28 23:40:14 -0700 |
commit | f303567317771d66b4cff4a2cb9361647da3f3be (patch) | |
tree | 10dc5c62205fdf571b2070636e4d89f96d922f13 /cppawk-include/case-priv.h | |
parent | bced9e4d93f25baebeb47ae2d6356843fcbba0f7 (diff) | |
download | cppawk-f303567317771d66b4cff4a2cb9361647da3f3be.tar.gz cppawk-f303567317771d66b4cff4a2cb9361647da3f3be.tar.bz2 cppawk-f303567317771d66b4cff4a2cb9361647da3f3be.zip |
Settle on single, most general __varexpand.
The nested form based on the reduce concept is more general;
one macro does it all.
Diffstat (limited to 'cppawk-include/case-priv.h')
-rw-r--r-- | cppawk-include/case-priv.h | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/cppawk-include/case-priv.h b/cppawk-include/case-priv.h index 9a62647..2d99533 100644 --- a/cppawk-include/case-priv.h +++ b/cppawk-include/case-priv.h @@ -38,12 +38,13 @@ #if __have_switch -#define __casx(x) case x: +#define __ca_first(x) case x: +#define __ca_next(p, x) p case x: #define __case_temps __ign #define __case(expr) switch (expr) -#define __of(...) __varexpand_simple(__casx, __VA_ARGS__) {{{ -#define __matching(...) __varexpand_simple(__casx, __VA_ARGS__) {{{ +#define __of(...) __varexpand(__ca_first, __ca_next, __VA_ARGS__) {{{ +#define __matching(...) __varexpand(__ca_first, __ca_next, __VA_ARGS__) {{{ #define __cbreak break; }}} #define __cfall }}} #define __cret(val) return val; }}} @@ -53,18 +54,19 @@ #define __clause(expr) if (__pass || (expr) && (__pass = 1)) #define __of_first(x) (__val == (x)) -#define __of_next(x) || (__val == (x)) +#define __of_next(p, x) p || (__val == (x)) #define __mtch_first(x) (__val ~ (x)) -#define __mtch_next(x) || (__val ~ (x)) +#define __mtch_next(p, \ + x) p || (__val ~ (x)) #define __case_temps __val, __once, __pass #define __case(expr) for ((__once = 1) && (__pass = 0) || (__val = expr); \ __once; \ __once = 0) -#define __of(...) __clause(__varexpand_infix(__of_first, __of_next, \ - __VA_ARGS__)) {{{ -#define __matching(...) __clause(__varexpand_infix(__mtch_first, mtch_next, \ - __VA_ARGS__)) {{{ +#define __of(...) __clause(__varexpand(__of_first, __of_next, \ + __VA_ARGS__)) {{{ +#define __matching(...) __clause(__varexpand(__mtch_first, mtch_next, \ + __VA_ARGS__)) {{{ #define __cbreak break; }}} #define __creturn(val) return val; }}} #define __cfall }}} |