forked from GitHub/gf-core
a simple refactoring in the statistical parser
This commit is contained in:
@@ -1559,8 +1559,7 @@ pgf_parsing_item(PgfParseState* before, PgfParseState* after, PgfItem* item)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
pgf_parsing_proceed(PgfParseState* state, void** output) {
|
pgf_parsing_proceed(PgfParseState* state) {
|
||||||
while (*output == NULL) {
|
|
||||||
prob_t best_prob = INFINITY;
|
prob_t best_prob = INFINITY;
|
||||||
PgfParseState* before = NULL;
|
PgfParseState* before = NULL;
|
||||||
|
|
||||||
@@ -1578,7 +1577,7 @@ pgf_parsing_proceed(PgfParseState* state, void** output) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (before == NULL)
|
if (before == NULL)
|
||||||
break;
|
return;
|
||||||
|
|
||||||
PgfParseState* after = NULL;
|
PgfParseState* after = NULL;
|
||||||
|
|
||||||
@@ -1601,7 +1600,6 @@ pgf_parsing_proceed(PgfParseState* state, void** output) {
|
|||||||
after = tmp;
|
after = tmp;
|
||||||
}
|
}
|
||||||
state = before;
|
state = before;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static PgfParsing*
|
static PgfParsing*
|
||||||
@@ -1693,7 +1691,8 @@ 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;
|
||||||
pgf_parsing_proceed(state, (void**) &state->ps->target);
|
while (state->ps->target == NULL)
|
||||||
|
pgf_parsing_proceed(state);
|
||||||
if (state->ps->target != NULL) {
|
if (state->ps->target != NULL) {
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
@@ -1815,8 +1814,8 @@ pgf_parse_result_next(PgfParseResult* pr, GuPool* pool)
|
|||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
if (pr->state->ps->completed == NULL) {
|
if (pr->state->ps->completed == NULL) {
|
||||||
pgf_parsing_proceed(pr->state,
|
while (pr->state->ps->completed == NULL)
|
||||||
(void**) &pr->state->ps->completed);
|
pgf_parsing_proceed(pr->state);
|
||||||
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);
|
||||||
|
|||||||
Reference in New Issue
Block a user