nextTokenOnChannel method
Given a starting index, return the index of the next token on channel.
Return i
if {@code tokensi
} is on channel. Return the index of
the EOF token if there are no tokens on channel between i
and
EOF.
Implementation
int nextTokenOnChannel(int i, int channel) {
sync(i);
if (i >= size) {
return size - 1;
}
var token = tokens[i];
while (token.channel != channel) {
if (token.type == Token.EOF) {
return i;
}
i++;
sync(i);
token = tokens[i];
}
return i;
}