fuzzyParseEntry method
Object?
fuzzyParseEntry(
- int marker_kind, [
- int? max_error_count
])
Implementation
Object? fuzzyParseEntry(int marker_kind, [int? max_error_count]) {
max_error_count ??= pow(2, 32).floor();
action.reset();
tokStream.reset(); // Position at first token.
reallocateStateStack();
stateStackTop = 0;
stateStack[0] = START_STATE;
//
// The tuple tokens will eventually contain the sequence
// of tokens that resulted in a successful parse. We leave
// it up to the "Stream" implementer to define the predecessor
// of the first token as he sees fit.
//
var first_token = tokStream.peek(),
start_token = first_token,
marker_token = getMarkerToken(marker_kind, first_token);
tokens = IntTuple(tokStream.getStreamLength());
tokens.add(tokStream.getPrevious(first_token));
var error_token = backtrackParseInternal(action, marker_token);
if (error_token != 0) // an error was detected?
{
if (!(tokStream is IPrsStream)) {
throw TokenStreamNotIPrsStreamException();
}
var rp = RecoveryParser(this, action, tokens, tokStream as IPrsStream,
prs, max_error_count, 0, monitor);
start_token = rp.recover(marker_token, error_token);
}
if (marker_token != 0 && start_token == first_token) {
tokens.add(marker_token);
}
int t;
for (t = start_token;
tokStream.getKind(t) != EOFT_SYMBOL;
t = tokStream.getNext(t)) {
tokens.add(t);
}
tokens.add(t);
return parseActions(marker_kind);
}