mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-16 13:35:22 +02:00
Fix for backtracking bug in TrialUndoParser
This commit is contained in:
parent
9c64384d62
commit
c3dba4bb6b
1 changed files with 9 additions and 4 deletions
|
@ -261,11 +261,12 @@ public class TrialUndoParser {
|
||||||
if (state.act == ERROR_ACTION) {
|
if (state.act == ERROR_ACTION) {
|
||||||
error_token = (error_token > state.curtok ? error_token : state.curtok);
|
error_token = (error_token > state.curtok ? error_token : state.curtok);
|
||||||
|
|
||||||
undoActions();
|
|
||||||
ConfigurationElement configuration = state.configurationStack.pop();
|
ConfigurationElement configuration = state.configurationStack.pop();
|
||||||
if (configuration == null)
|
if (configuration == null)
|
||||||
state.act = ERROR_ACTION;
|
state.act = ERROR_ACTION;
|
||||||
else {
|
else {
|
||||||
|
boolean shouldPop = prs.baseAction(configuration.conflict_index) == 0;
|
||||||
|
undoActions(shouldPop);
|
||||||
state.actionCount = configuration.action_length;
|
state.actionCount = configuration.action_length;
|
||||||
state.act = configuration.act;
|
state.act = configuration.act;
|
||||||
state.curtok = configuration.curtok;
|
state.curtok = configuration.curtok;
|
||||||
|
@ -366,11 +367,12 @@ public class TrialUndoParser {
|
||||||
state.tokens.add(state.curtok);
|
state.tokens.add(state.curtok);
|
||||||
} else if (state.act == ERROR_ACTION) {
|
} else if (state.act == ERROR_ACTION) {
|
||||||
if (state.curtok != error_token) {
|
if (state.curtok != error_token) {
|
||||||
undoActions();
|
|
||||||
ConfigurationElement configuration = state.configurationStack.pop();
|
ConfigurationElement configuration = state.configurationStack.pop();
|
||||||
if (configuration == null)
|
if (configuration == null)
|
||||||
state.act = ERROR_ACTION;
|
state.act = ERROR_ACTION;
|
||||||
else {
|
else {
|
||||||
|
boolean shouldPop = prs.baseAction(configuration.conflict_index) == 0;
|
||||||
|
undoActions(shouldPop);
|
||||||
state.actionCount = configuration.action_length;
|
state.actionCount = configuration.action_length;
|
||||||
state.act = configuration.act;
|
state.act = configuration.act;
|
||||||
int next_token_index = configuration.curtok;
|
int next_token_index = configuration.curtok;
|
||||||
|
@ -610,12 +612,15 @@ public class TrialUndoParser {
|
||||||
* Performs the undo actions (in reverse order) for the corresponding trial
|
* Performs the undo actions (in reverse order) for the corresponding trial
|
||||||
* actions that have been executed since the last backtrackable point.
|
* actions that have been executed since the last backtrackable point.
|
||||||
*/
|
*/
|
||||||
private void undoActions() {
|
private void undoActions(boolean shouldPop) {
|
||||||
int oldTrialActionCount;
|
int oldTrialActionCount;
|
||||||
if (state.trialActionStack.size() == 0) {
|
if (state.trialActionStack.size() == 0) {
|
||||||
oldTrialActionCount = 0;
|
oldTrialActionCount = 0;
|
||||||
} else {
|
} else {
|
||||||
oldTrialActionCount = state.trialActionStack.removeLast();
|
oldTrialActionCount = state.trialActionStack.getLast();
|
||||||
|
if (shouldPop) {
|
||||||
|
state.trialActionStack.removeLast();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
safeUndoActions(oldTrialActionCount);
|
safeUndoActions(oldTrialActionCount);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue