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() {
|
||||
if (!tokens_[next_token_idx_].IsEof() && !tokens_[next_token_idx_].IsError()) {
|
||||
// Skip over any placeholder elements
|
||||
while (true) {
|
||||
if (!tokens_[next_token_idx_].IsPlaceholder()) {
|
||||
break;
|
||||
}
|
||||
next_token_idx_++;
|
||||
// If the next token is already an error or the end of file, stay there.
|
||||
if (tokens_[next_token_idx_].IsEof() || tokens_[next_token_idx_].IsError()) {
|
||||
return tokens_[next_token_idx_];
|
||||
}
|
||||
|
||||
// Skip over any placeholder elements
|
||||
while (true) {
|
||||
if (!tokens_[next_token_idx_].IsPlaceholder()) {
|
||||
break;
|
||||
}
|
||||
next_token_idx_++;
|
||||
}
|
||||
last_source_idx_ = next_token_idx_;
|
||||
return tokens_[next_token_idx_++];
|
||||
|
|
Loading…
Reference in New Issue