From 5abe74f890825047a6117320d7dbe3590bfd5534 Mon Sep 17 00:00:00 2001 From: Steven Dee Date: Sat, 3 Jan 2015 16:35:56 -0500 Subject: [PATCH 1/2] Retab as though tabstop were 8 Tabs after the first non-tab character are crazymaking. I picked 8 because it wasn't 7 and caused the backslashes to line up on H_ACT_APPLY. --- src/glue.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/glue.h b/src/glue.h index 1fe6ce4..18e25ec 100644 --- a/src/glue.h +++ b/src/glue.h @@ -66,13 +66,13 @@ h_attr_bool(h_action(def, act_ ## rule, NULL), validate_ ## rule, NULL) #define H_AVRULE(rule, def) HParser *rule = \ h_action(h_attr_bool(def, validate_ ## rule, NULL), act_ ## rule, NULL) -#define H_ADRULE(rule, def, data) HParser *rule = \ +#define H_ADRULE(rule, def, data) HParser *rule = \ h_action(def, act_ ## rule, data) -#define H_VDRULE(rule, def, data) HParser *rule = \ +#define H_VDRULE(rule, def, data) HParser *rule = \ h_attr_bool(def, validate_ ## rule, data) -#define H_VADRULE(rule, def, data) HParser *rule = \ +#define H_VADRULE(rule, def, data) HParser *rule = \ h_attr_bool(h_action(def, act_ ## rule, data), validate_ ## rule, data) -#define H_AVDRULE(rule, def, data) HParser *rule = \ +#define H_AVDRULE(rule, def, data) HParser *rule = \ h_action(h_attr_bool(def, validate_ ## rule, data), act_ ## rule, data) @@ -109,8 +109,8 @@ HParsedToken *h_act_ignore(const HParseResult *p, void* user_data); // Define 'myaction' as a specialization of 'paction' by supplying the leading // parameters. #define H_ACT_APPLY(myaction, paction, ...) \ - HParsedToken *myaction(const HParseResult *p, void* user_data) { \ - return paction(__VA_ARGS__, p, user_data); \ + HParsedToken *myaction(const HParseResult *p, void* user_data) { \ + return paction(__VA_ARGS__, p, user_data); \ } From 2dad0c48b41408ef6e1a23cec9552f3bc36bbcef Mon Sep 17 00:00:00 2001 From: Steven Dee Date: Sat, 3 Jan 2015 16:42:45 -0500 Subject: [PATCH 2/2] 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 18e25ec..6c1c56c 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