mirror of
https://github.com/adelphes/android-dev-ext.git
synced 2025-12-23 01:48:18 +00:00
start separating validation from parsing
This commit is contained in:
@@ -57,6 +57,19 @@ class TokenList {
|
||||
return token;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the current token matches the specified kind, returns and consumes it
|
||||
* @param {string} kind
|
||||
*/
|
||||
getIfKind(kind) {
|
||||
const token = this.current;
|
||||
if (token && token.kind === kind) {
|
||||
this.inc();
|
||||
return token;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the current token matches the specified value, returns and consumes it
|
||||
* @param {string} value
|
||||
@@ -83,11 +96,7 @@ class TokenList {
|
||||
* @param {string} kind
|
||||
*/
|
||||
isKind(kind) {
|
||||
if (this.current && this.current.kind === kind) {
|
||||
this.inc();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return this.getIfKind(kind) !== null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user