parse labels and break/continue targets

This commit is contained in:
Dave Holoway
2020-06-10 18:43:43 +01:00
parent 87a2d72ae3
commit cd725638cd
2 changed files with 54 additions and 3 deletions

View File

@@ -25,6 +25,24 @@ class TokenList {
}
}
}
/**
* Token lookahead. The current token is unaffected by this method.
* @param {number} n number of tokens to look ahead
*/
peek(n) {
let token, idx = this.idx;
while (--n >= 0) {
for (; ;) {
token = this.tokens[idx += 1];
if (!token || token.kind !== 'wsc') {
break;
}
}
}
return token;
}
/**
* Check if the current token matches the specified value and consumes it
* @param {string} value