Skip to content

Commit

Permalink
reparse individual non-parsed words after full sentence
Browse files Browse the repository at this point in the history
mitigates #80
  • Loading branch information
unhammer committed Aug 28, 2023
1 parent cefc1de commit ee76cb5
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/rtx_processor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1798,6 +1798,32 @@ RTXProcessor::processGLR(UFILE *out)
currentBranch = parseGraph[0];
parseGraph[0]->getChunks(outputQueue, parseGraph[0]->length-1);
parseGraph.clear();

// We have now parsed input into a tree, and are ready to run
// output rules and do the output. But first: For every chunk
// that didn't get a parse, reparse it disregarding context, so
// we can at least use single-word rules on them.

for(auto it = outputQueue.begin(); it != outputQueue.end(); ++it) {
Chunk* ch = *it;
if(ch->rule == -1 && !ch->isBlank) { // -1 means didn't get a parse
ParseNode* temp = parsePool.next();
temp->init(mx, ch);
temp->id = ++newBranchId;
temp->stringVars = variables;
temp->wblankVars = wblank_variables;
temp->chunkVars = vector<Chunk*>(varCount, NULL);
checkForReduce(parseGraph, temp);

list<Chunk*> outputQueueReparsed;
parseGraph[0]->getChunks(outputQueueReparsed, parseGraph[0]->length-1);
for(Chunk* ch2 : outputQueueReparsed) { // should be at most one
*it = ch2;
}
parseGraph.clear();
}
}

outputAll(out);
variables = currentBranch->stringVars;
wblank_variables = currentBranch->wblankVars;
Expand Down

0 comments on commit ee76cb5

Please sign in to comment.