call actions only on successful parse
This commit is contained in:
parent
6d755efbde
commit
10154622b8
2 changed files with 6 additions and 2 deletions
|
|
@ -426,6 +426,7 @@ static void test_action(void) {
|
|||
|
||||
g_check_parse_ok(action_, "ab", 2, "(u0x41 u0x42)");
|
||||
g_check_parse_ok(action_, "AB", 2, "(u0x41 u0x42)");
|
||||
g_check_parse_failed(action_, "XX", 2);
|
||||
}
|
||||
|
||||
static void test_not_in(void) {
|
||||
|
|
|
|||
|
|
@ -10,8 +10,11 @@ static HParseResult* parse_action(void *env, HParseState *state) {
|
|||
if (a->p && a->action) {
|
||||
HParseResult *tmp = h_do_parse(a->p, state);
|
||||
//HParsedToken *tok = a->action(h_do_parse(a->p, state));
|
||||
if(tmp) {
|
||||
const HParsedToken *tok = a->action(tmp);
|
||||
return make_result(state, (HParsedToken*)tok);
|
||||
} else
|
||||
return NULL;
|
||||
} else // either the parser's missing or the action's missing
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue