1
0
forked from GitHub/gf-core

bugfix in the statistical parser

This commit is contained in:
kr.angelov
2012-11-13 09:48:23 +00:00
parent 4d34018abb
commit 70c68f0527

View File

@@ -1534,7 +1534,7 @@ pgf_parsing_item(PgfParseState* before, PgfParseState* after, PgfItem* item)
} }
} }
static void static bool
pgf_parsing_proceed(PgfParseState* state) { pgf_parsing_proceed(PgfParseState* state) {
prob_t best_prob = INFINITY; prob_t best_prob = INFINITY;
PgfParseState* before = NULL; PgfParseState* before = NULL;
@@ -1557,7 +1557,7 @@ pgf_parsing_proceed(PgfParseState* state) {
} }
if (before == NULL) if (before == NULL)
return; return false;
PgfParseState* after = NULL; PgfParseState* after = NULL;
@@ -1580,6 +1580,8 @@ pgf_parsing_proceed(PgfParseState* state) {
after = tmp; after = tmp;
} }
state = before; state = before;
return true;
} }
static PgfParsing* static PgfParsing*
@@ -1673,8 +1675,10 @@ pgf_parser_next_state(PgfParseState* prev, PgfToken tok, GuPool* pool)
pgf_new_parse_state(prev->ps, prev, ts, pool); pgf_new_parse_state(prev->ps, prev, ts, pool);
state->ps->target = NULL; state->ps->target = NULL;
while (state->ps->target == NULL) while (state->ps->target == NULL) {
pgf_parsing_proceed(state); if (!pgf_parsing_proceed(state))
break;
}
if (state->ps->target != NULL) { if (state->ps->target != NULL) {
return state; return state;
} }
@@ -1796,8 +1800,10 @@ pgf_parse_result_next(PgfParseResult* pr, GuPool* pool)
for (;;) { for (;;) {
if (pr->state->ps->completed == NULL) { if (pr->state->ps->completed == NULL) {
while (pr->state->ps->completed == NULL) while (pr->state->ps->completed == NULL) {
pgf_parsing_proceed(pr->state); if (!pgf_parsing_proceed(pr->state))
break;
}
if (pr->state->ps->completed == NULL) if (pr->state->ps->completed == NULL)
return NULL; return NULL;
pgf_result_cat_init(pr, NULL, 0, pr->state->ps->completed); pgf_result_cat_init(pr, NULL, 0, pr->state->ps->completed);