Merge pull request #116 from mrdomino/h-validate-apply
H_VALIDATE_APPLY macro
This commit is contained in:
commit
b2f247b029
1 changed files with 14 additions and 7 deletions
21
src/glue.h
21
src/glue.h
|
|
@ -11,7 +11,8 @@
|
||||||
//
|
//
|
||||||
// A few standard semantic actions are defined below. The H_ACT_APPLY macro
|
// A few standard semantic actions are defined below. The H_ACT_APPLY macro
|
||||||
// allows semantic actions to be defined by "partial application" of
|
// 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
|
// The definition of more complex semantic actions will usually consist of
|
||||||
// extracting data from the given parse tree and constructing a token of custom
|
// extracting data from the given parse tree and constructing a token of custom
|
||||||
|
|
@ -66,13 +67,13 @@
|
||||||
h_attr_bool(h_action(def, act_ ## rule, NULL), validate_ ## rule, NULL)
|
h_attr_bool(h_action(def, act_ ## rule, NULL), validate_ ## rule, NULL)
|
||||||
#define H_AVRULE(rule, def) HParser *rule = \
|
#define H_AVRULE(rule, def) HParser *rule = \
|
||||||
h_action(h_attr_bool(def, validate_ ## rule, NULL), act_ ## rule, NULL)
|
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)
|
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)
|
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)
|
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)
|
h_action(h_attr_bool(def, validate_ ## rule, data), act_ ## rule, data)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -109,8 +110,14 @@ HParsedToken *h_act_ignore(const HParseResult *p, void* user_data);
|
||||||
// Define 'myaction' as a specialization of 'paction' by supplying the leading
|
// Define 'myaction' as a specialization of 'paction' by supplying the leading
|
||||||
// parameters.
|
// parameters.
|
||||||
#define H_ACT_APPLY(myaction, paction, ...) \
|
#define H_ACT_APPLY(myaction, paction, ...) \
|
||||||
HParsedToken *myaction(const HParseResult *p, void* user_data) { \
|
HParsedToken *myaction(const HParseResult *p, void* user_data) { \
|
||||||
return paction(__VA_ARGS__, p, 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); \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue