errorRepair method
Implementation
int errorRepair(IPrsStream stream, int recovery_token, int error_token) {
var temp_stack = List.filled(stateStackTop + 1, 0);
ArrayList.copy(stateStack, 0, temp_stack, 0, temp_stack.length);
for (;
stream.getKind(recovery_token) != EOFT_SYMBOL;
recovery_token = stream.getNext(recovery_token)) {
stream.reset(recovery_token);
if (repairable(error_token)) break;
stateStackTop = temp_stack.length - 1;
ArrayList.copy(temp_stack, 0, stateStack, 0, temp_stack.length);
}
if (stream.getKind(recovery_token) == EOFT_SYMBOL) {
stream.reset(recovery_token);
if (!repairable(error_token)) {
stateStackTop = temp_stack.length - 1;
ArrayList.copy(temp_stack, 0, stateStack, 0, temp_stack.length);
return 0;
}
}
//
//
//
stateStackTop = temp_stack.length - 1;
ArrayList.copy(temp_stack, 0, stateStack, 0, temp_stack.length);
stream.reset(recovery_token);
tokens.reset(locationStack[stateStackTop] - 1);
action.reset(actionStack[stateStackTop]);
return stream.makeErrorToken(tokens.get(locationStack[stateStackTop] - 1),
stream.getPrevious(recovery_token), error_token, ERROR_SYMBOL);
}