Stay at the EOF or Error token.
When the `next` token is requested, if we're already at EOF or Error we can just return that token and stay at that index. Bug: crbug:1347298 Change-Id: I1c31cf32a7030166c174d336455c7adabf97c6c9 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/97220 Reviewed-by: Ben Clayton <bclayton@google.com> Commit-Queue: Ben Clayton <bclayton@google.com> Auto-Submit: Dan Sinclair <dsinclair@chromium.org> Kokoro: Kokoro <noreply+kokoro@google.com>
This commit is contained in:
parent
ee36e39296
commit
62c58a076c
|
@ -275,14 +275,17 @@ void ParserImpl::deprecated(const Source& source, const std::string& msg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const Token& ParserImpl::next() {
|
const Token& ParserImpl::next() {
|
||||||
if (!tokens_[next_token_idx_].IsEof() && !tokens_[next_token_idx_].IsError()) {
|
// If the next token is already an error or the end of file, stay there.
|
||||||
// Skip over any placeholder elements
|
if (tokens_[next_token_idx_].IsEof() || tokens_[next_token_idx_].IsError()) {
|
||||||
while (true) {
|
return tokens_[next_token_idx_];
|
||||||
if (!tokens_[next_token_idx_].IsPlaceholder()) {
|
}
|
||||||
break;
|
|
||||||
}
|
// Skip over any placeholder elements
|
||||||
next_token_idx_++;
|
while (true) {
|
||||||
|
if (!tokens_[next_token_idx_].IsPlaceholder()) {
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
next_token_idx_++;
|
||||||
}
|
}
|
||||||
last_source_idx_ = next_token_idx_;
|
last_source_idx_ = next_token_idx_;
|
||||||
return tokens_[next_token_idx_++];
|
return tokens_[next_token_idx_++];
|
||||||
|
|
Loading…
Reference in New Issue