Skip to content

Commit

Permalink
[23] JEP 476: Module Import Declarations (Preview)
Browse files Browse the repository at this point in the history
Fix Scanner: "import module." does not start a module import!
  • Loading branch information
stephan-herrmann committed May 26, 2024
1 parent da25625 commit a8772ee
Showing 1 changed file with 14 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5415,21 +5415,17 @@ int disambiguatedRestrictedKeyword(int restrictedKeywordToken) {
if (this.scanContext != ScanContext.AFTER_REQUIRES) {
token = TokenNameIdentifier;
} else {
getVanguardParser();
this.vanguardScanner.resetTo(this.currentPosition, this.eofPosition - 1, true, ScanContext.EXPECTING_IDENTIFIER);
try {
int lookAhead = this.vanguardScanner.getNextToken();
if (lookAhead == TokenNameSEMICOLON)
token = TokenNameIdentifier;
} catch (InvalidInputException e) {
//
}
if (lookAhead(true, ScanContext.EXPECTING_IDENTIFIER) == TokenNameSEMICOLON)
token = TokenNameIdentifier;
}
break;
case TokenNamemodule:
switch (this.scanContext) {
case EXPECTING_KEYWORD:
break;
case AFTER_IMPORT:
if (lookAhead(true, ScanContext.EXPECTING_IDENTIFIER) == TokenNameDOT)
token = TokenNameIdentifier;
break;
default:
token = TokenNameIdentifier;
Expand All @@ -5450,6 +5446,15 @@ int disambiguatedRestrictedKeyword(int restrictedKeywordToken) {
}
return token;
}
int lookAhead(boolean isModuleInfo, ScanContext context) {
getVanguardParser();
this.vanguardScanner.resetTo(this.currentPosition, this.eofPosition - 1, isModuleInfo, context);
try {
return this.vanguardScanner.getNextToken();
} catch (InvalidInputException e) {
return TokenNameNotAToken;
}
}
int disambiguatesRestrictedIdentifierWithLookAhead(Predicate<Integer> checkPrecondition, int restrictedIdentifierToken, Goal goal) {
if (checkPrecondition.test(restrictedIdentifierToken)) {
VanguardParser vp = getNewVanguardParser();
Expand Down

0 comments on commit a8772ee

Please sign in to comment.