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
|
||||
pgf_parsing_proceed(PgfParseState* state, void** output) {
|
||||
while (*output == NULL) {
|
||||
pgf_parsing_proceed(PgfParseState* state) {
|
||||
prob_t best_prob = INFINITY;
|
||||
PgfParseState* before = NULL;
|
||||
|
||||
@@ -1578,7 +1577,7 @@ pgf_parsing_proceed(PgfParseState* state, void** output) {
|
||||
}
|
||||
|
||||
if (before == NULL)
|
||||
break;
|
||||
return;
|
||||
|
||||
PgfParseState* after = NULL;
|
||||
|
||||
@@ -1602,7 +1601,6 @@ pgf_parsing_proceed(PgfParseState* state, void** output) {
|
||||
}
|
||||
state = before;
|
||||
}
|
||||
}
|
||||
|
||||
static PgfParsing*
|
||||
pgf_new_parsing(PgfConcr* concr, GuPool* pool)
|
||||
@@ -1693,7 +1691,8 @@ pgf_parser_next_state(PgfParseState* prev, PgfToken tok, GuPool* pool)
|
||||
pgf_new_parse_state(prev->ps, prev, ts, pool);
|
||||
|
||||
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) {
|
||||
return state;
|
||||
}
|
||||
@@ -1815,8 +1814,8 @@ pgf_parse_result_next(PgfParseResult* pr, GuPool* pool)
|
||||
|
||||
for (;;) {
|
||||
if (pr->state->ps->completed == NULL) {
|
||||
pgf_parsing_proceed(pr->state,
|
||||
(void**) &pr->state->ps->completed);
|
||||
while (pr->state->ps->completed == NULL)
|
||||
pgf_parsing_proceed(pr->state);
|
||||
if (pr->state->ps->completed == NULL)
|
||||
return NULL;
|
||||
pgf_result_cat_init(pr, NULL, 0, pr->state->ps->completed);
|
||||
|
||||
Reference in New Issue
Block a user