Skip to content
Snippets Groups Projects
Commit ddad3ba4 authored by Franck Dary's avatar Franck Dary
Browse files

Fixed costs functions of transitions : if a stack element is out of bound, ignore it

parent 34dc3a6f
No related branches found
No related tags found
No related merge requests found
......@@ -93,6 +93,9 @@ void Transition::initShift()
int cost = 0;
for (int i = 0; config.hasStack(i); ++i)
{
if (!config.has(0, config.getStack(i), 0))
continue;
auto stackIndex = config.getStack(i);
auto stackId = config.getConst(Config::idColName, stackIndex, 0);
auto stackGov = config.getConst(Config::headColName, stackIndex, 0);
......@@ -184,6 +187,9 @@ void Transition::initRight(std::string label)
for (int i = 1; config.hasStack(i); ++i)
{
if (!config.has(0, config.getStack(i), 0))
continue;
auto otherStackIndex = config.getStack(i);
auto stackId = config.getConst(Config::idColName, otherStackIndex, 0);
auto stackGov = config.getConst(Config::headColName, otherStackIndex, 0);
......@@ -209,7 +215,10 @@ void Transition::initReduce()
cost = [](const Config & config)
{
if (!config.isToken(config.getWordIndex()))
if (!config.has(0, config.getStack(0), 0))
return 0;
if (!config.isToken(config.getStack(0)))
return 0;
int cost = 0;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment