From 2dad0c48b41408ef6e1a23cec9552f3bc36bbcef Mon Sep 17 00:00:00 2001 From: Steven Dee <steve@smartercode.net> Date: Sat, 3 Jan 2015 16:42:45 -0500 Subject: [PATCH] H_VALIDATE_APPLY macro I've found this especially useful in combination with my own _attr_uint_const for things like flags and type specifiers. It's possible that its usefulness might be diminished significantly if there were a built-in bitfield constant parser -- that certainly would eliminate all of my current uses of it -- but it still seems nicely symmetric with H_ACT_APPLY. --- src/glue.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/glue.h b/src/glue.h index 18e25eca..6c1c56ca 100644 --- a/src/glue.h +++ b/src/glue.h @@ -11,7 +11,8 @@ // // A few standard semantic actions are defined below. The H_ACT_APPLY macro // allows semantic actions to be defined by "partial application" of -// a generic action to fixed paramters. +// a generic action to fixed paramters. H_VALIDATE_APPLY is similar for +// h_atter_bool. // // The definition of more complex semantic actions will usually consist of // extracting data from the given parse tree and constructing a token of custom @@ -113,6 +114,12 @@ HParsedToken *h_act_ignore(const HParseResult *p, void* user_data); return paction(__VA_ARGS__, p, user_data); \ } +// Similar, but for validations. +#define H_VALIDATE_APPLY(myvalidation, pvalidation, ...) \ + bool myvalidation(HParseResult* p, void* user_data) { \ + return pvalidation(__VA_ARGS__, p, user_data); \ + } + // // Working with HParsedTokens -- GitLab