Merge branch 'h_action_fail'

This commit is contained in:
Sven M. Hallberg 2012-06-09 14:42:48 +02:00
commit 90d55139e2
2 changed files with 6 additions and 2 deletions

View file

@ -457,6 +457,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_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_in(void) { static void test_in(void) {

View file

@ -10,8 +10,11 @@ static HParseResult* parse_action(void *env, HParseState *state) {
if (a->p && a->action) { if (a->p && a->action) {
HParseResult *tmp = h_do_parse(a->p, state); HParseResult *tmp = h_do_parse(a->p, state);
//HParsedToken *tok = a->action(h_do_parse(a->p, state)); //HParsedToken *tok = a->action(h_do_parse(a->p, state));
if(tmp) {
const HParsedToken *tok = a->action(tmp); const HParsedToken *tok = a->action(tmp);
return make_result(state, (HParsedToken*)tok); return make_result(state, (HParsedToken*)tok);
} else
return NULL;
} else // either the parser's missing or the action's missing } else // either the parser's missing or the action's missing
return NULL; return NULL;
} }