mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-05-22 17:42:51 -06:00
bugfixes
This commit is contained in:
@@ -1003,36 +1003,39 @@ ref<PgfLRTable> PgfLRTableMaker::make()
|
|||||||
ref<PgfLRState> lrstate = vector_elem(lrtable, state->id);
|
ref<PgfLRState> lrstate = vector_elem(lrtable, state->id);
|
||||||
|
|
||||||
size_t index = 0;
|
size_t index = 0;
|
||||||
lrstate->shifts = vector_new<PgfLRShift>(state->ccats1.size());
|
auto shifts = vector_new<PgfLRShift>(state->ccats1.size());
|
||||||
for (auto i : state->ccats1) {
|
for (auto i : state->ccats1) {
|
||||||
ref<PgfLRShift> shift = vector_elem(lrstate->shifts,index++);
|
ref<PgfLRShift> shift = vector_elem(shifts,index++);
|
||||||
shift->lincat = i.first.first;
|
shift->lincat = i.first.first;
|
||||||
shift->exact = i.second.second;
|
shift->exact = i.second.second;
|
||||||
shift->r = i.first.second;
|
shift->r = i.first.second;
|
||||||
shift->next_state = i.second.first->id;
|
shift->next_state = i.second.first->id;
|
||||||
}
|
}
|
||||||
|
lrstate->shifts = shifts;
|
||||||
|
|
||||||
lrstate->reductions = vector_new<PgfLRReduce>(state->completed.size());
|
auto reductions = vector_new<PgfLRReduce>(state->completed.size());
|
||||||
for (size_t i = 0; i < state->completed.size(); i++) {
|
for (size_t i = 0; i < state->completed.size(); i++) {
|
||||||
Item *item = state->completed[i];
|
Item *item = state->completed[i];
|
||||||
ref<PgfLRReduce> reduction = vector_elem(lrstate->reductions,i);
|
ref<PgfLRReduce> reduction = vector_elem(reductions,i);
|
||||||
reduction->lin_obj = item->lin_obj;
|
reduction->lin_obj = item->lin_obj;
|
||||||
reduction->seq_idx = item->seq_idx;
|
reduction->seq_idx = item->seq_idx;
|
||||||
reduction->depth = item->stk_size;
|
reduction->depth = item->stk_size;
|
||||||
reduction->args = vector_new<object>(item->args.count);
|
|
||||||
|
|
||||||
|
auto args = vector_new<object>(item->args.count);
|
||||||
for (size_t j = 0; j < item->args.count; j++) {
|
for (size_t j = 0; j < item->args.count; j++) {
|
||||||
if (item->args[j].ccat == NULL) {
|
if (item->args[j].ccat == NULL) {
|
||||||
if (item->args[j].stk_idx == 0)
|
if (item->args[j].stk_idx == 0)
|
||||||
*vector_elem(reduction->args, j) = 0;
|
*vector_elem(args, j) = 0;
|
||||||
else
|
else
|
||||||
*vector_elem(reduction->args, j) = PgfLRReducePop::from_idx(item->args[j].stk_idx);
|
*vector_elem(args, j) = PgfLRReducePop::from_idx(item->args[j].stk_idx);
|
||||||
} else {
|
} else {
|
||||||
ref<PgfLRReduceArg> arg = item->args[j].ccat->persist();
|
ref<PgfLRReduceArg> arg = item->args[j].ccat->persist();
|
||||||
*vector_elem(reduction->args, j) = arg.tagged();
|
*vector_elem(args, j) = arg.tagged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
reduction->args = args;
|
||||||
}
|
}
|
||||||
|
lrstate->reductions = reductions;
|
||||||
}
|
}
|
||||||
return lrtable;
|
return lrtable;
|
||||||
}
|
}
|
||||||
@@ -1308,15 +1311,20 @@ PgfParser::Choice *PgfParser::retrieve_choice(ref<PgfLRReduceArg> arg)
|
|||||||
if (arg == 0)
|
if (arg == 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
Choice *choice = new Choice(++last_fid);
|
Choice *&tmp = persistant[arg.tagged()];
|
||||||
for (size_t i = 0; i < arg->n_prods; i++) {
|
Choice *choice = tmp;
|
||||||
Production *prod = new(arg->prods[i].lin, arg->prods[i].index) Production();
|
if (choice == NULL) {
|
||||||
for (size_t i = 0; i < prod->n_args; i++) {
|
tmp = new Choice(++last_fid); choice = tmp;
|
||||||
auto child = *vector_elem(arg->prods[i].args, i);
|
for (size_t i = 0; i < arg->n_prods; i++) {
|
||||||
prod->args[i] = retrieve_choice(child);
|
Production *prod = new(arg->prods[i].lin, arg->prods[i].index) Production();
|
||||||
|
for (size_t j = 0; j < prod->n_args; j++) {
|
||||||
|
auto child = *vector_elem(arg->prods[i].args, j);
|
||||||
|
prod->args[j] = retrieve_choice(child);
|
||||||
|
}
|
||||||
|
choice->prods.push_back(prod);
|
||||||
}
|
}
|
||||||
choice->prods.push_back(prod);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return choice;
|
return choice;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -109,6 +109,8 @@ class PGF_INTERNAL_DECL PgfParser : public PgfPhraseScanner, public PgfExprEnum
|
|||||||
std::priority_queue<ExprState*, std::vector<ExprState*>, CompareExprState> queue;
|
std::priority_queue<ExprState*, std::vector<ExprState*>, CompareExprState> queue;
|
||||||
int last_fid;
|
int last_fid;
|
||||||
|
|
||||||
|
std::map<object,Choice*> persistant;
|
||||||
|
|
||||||
Choice *top_choice;
|
Choice *top_choice;
|
||||||
size_t top_choice_index;
|
size_t top_choice_index;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user