Code review comment: I was mimicking `ACCESS_EXPRESSION` there btw

Code before review:
private Result seekMatch(ParserRuleContext currentCtx, int lookahead, int currentDepth) {
boolean hasMatch;
boolean skipRule;
int matchingRulesCount = 0;
while (currentDepth < lookaheadLimit) {
hasMatch = true;
skipRule = false;
STToken nextToken = this.tokenReader.peek(lookahead);
switch (currentCtx) {
case EOF:
hasMatch = nextToken.kind == SyntaxKind.EOF_TOKEN;
break;
case PUBLIC_KEYWORD:
hasMatch = nextToken.kind == SyntaxKind.PUBLIC_KEYWORD;
break;
case PRIVATE_KEYWORD:
hasMatch = nextToken.kind == SyntaxKind.PRIVATE_KEYWORD;
break;
case REMOTE_KEYWORD:
hasMatch = nextToken.kind == SyntaxKind.REMOTE_KEYWORD;
break;
case TOP_LEVEL_NODE_WITHOUT_MODIFIER:
return seekInAlternativesPaths(lookahead, currentDepth, matchingRulesCount,
TOP_LEVEL_NODE_WITHOUT_MODIFIER);
case TOP_LEVEL_NODE:
return seekInAlternativesPaths(lookahead, currentDepth, matchingRulesCount, TOP_LEVEL_NODE);
case FUNCTION_KEYWORD:
hasMatch = nextToken.kind == SyntaxKind.FUNCTION_KEYWORD;
break;
case FUNC_NAME:
case VARIABLE_NAME:
case TYPE_NAME:
case TYPE_REFERENCE:
case FIELD_OR_FUNC_NAME:
case IMPORT_ORG_OR_MODULE_NAME:
case IMPORT_MODULE_NAME:
case IMPORT_PREFIX:
case VARIABLE_REF:
case MAPPING_FIELD_NAME:
case SERVICE_NAME:
hasMatch = nextToken.kind == SyntaxKind.IDENTIFIER_TOKEN;
break;
case OPEN_PARENTHESIS:
hasMatch = nextToken.kind == SyntaxKind.OPEN_PAREN_TOKEN;
break;
case CLOSE_PARENTHESIS:
hasMatch = nextToken.kind == SyntaxKind.CLOSE_PAREN_TOKEN;
break;
case RETURNS_KEYWORD:
hasMatch = nextToken.kind == SyntaxKind.RETURNS_KEYWORD;
if (!hasMatch) {
skipRule = true;
}
break;
case SIMPLE_TYPE_DESCRIPTOR:
case CONST_DECL_TYPE:
hasMatch =
nextToken.kind == SyntaxKind.SIMPLE_TYPE || nextToken.kind == SyntaxKind.SERVICE_KEYWORD ||
nextToken.kind == SyntaxKind.IDENTIFIER_TOKEN;
break;
case FUNC_BODY:
return seekInFuncBodies(lookahead, currentDepth, matchingRulesCount);
case OPEN_BRACE:
if (getParentContext() == ParserRuleContext.LISTENERS_LIST) {
endContext();
}
hasMatch = nextToken.kind == SyntaxKind.OPEN_BRACE_TOKEN;
break;
case CLOSE_BRACE:
hasMatch = nextToken.kind == SyntaxKind.CLOSE_BRACE_TOKEN;
break;
case ASSIGN_OP:
hasMatch = nextToken.kind == SyntaxKind.EQUAL_TOKEN;
break;
case ANNOTATION_ATTACHMENT:
case EXTERNAL_KEYWORD:
hasMatch = nextToken.kind == SyntaxKind.EXTERNAL_KEYWORD;
break;
case SEMICOLON:
hasMatch = nextToken.kind == SyntaxKind.SEMICOLON_TOKEN;
break;
case STATEMENT:
if (isEndOfBlock(nextToken)) {
skipRule = true;
break;
}
return seekInStatements(currentCtx, nextToken, lookahead, currentDepth, matchingRulesCount);
case BINARY_OPERATOR:
hasMatch = isBinaryOperator(nextToken);
break;
case EXPRESSION:
return seekInAlternativesPaths(lookahead, currentDepth, matchingRulesCount, EXPRESSIONS);
case VAR_DECL_STMT_RHS:
return seekInAlternativesPaths(lookahead, currentDepth, matchingRulesCount, VAR_DECL_RHS);
case EXPRESSION_RHS:
return seekMatchInExpressionRhs(nextToken, lookahead, currentDepth, matchingRulesCount);
case COMMA:
hasMatch = nextToken.kind == SyntaxKind.COMMA_TOKEN;
break;
case PARAM_LIST:
return seekInAlternativesPaths(lookahead, currentDepth, matchingRulesCount, PARAM_LIST);
case PARAMETER_RHS:
ParserRuleContext parentCtx = getParentContext();
switch (parentCtx) {
case REQUIRED_PARAM:
return seekInAlternativesPaths(lookahead, currentDepth, matchingRulesCount, PARAMETER_RHS);
case DEFAULTABLE_PARAM:
case REST_PARAM:
skipRule = true;
break;
default:
throw new IllegalStateException();
}
break;
case STATEMENT_START_IDENTIFIER:
return seekInAlternativesPaths(lookahead, currentDepth, matchingRulesCount, TYPE_OR_VAR_NAME);
case ASSIGNMENT_OR_VAR_DECL_STMT_RHS:
return seekInAlternativesPaths(lookahead, currentDepth, matchingRulesCount,
ASSIGNMENT_OR_VAR_DECL_SECOND_TOKEN);
case CLOSED_RECORD_BODY_END:
hasMatch = nextToken.kind == SyntaxKind.CLOSE_BRACE_PIPE_TOKEN;
break;
case CLOSED_RECORD_BODY_START:
hasMatch = nextToken.kind == SyntaxKind.OPEN_BRACE_PIPE_TOKEN;
break;
case ELLIPSIS:
hasMatch = nextToken.kind == SyntaxKind.ELLIPSIS_TOKEN;
break;
case QUESTION_MARK:
hasMatch = nextToken.kind == SyntaxKind.QUESTION_MARK_TOKEN;
break;
case RECORD_KEYWORD:
hasMatch = nextToken.kind == SyntaxKind.RECORD_KEYWORD;
break;
case TYPE_KEYWORD:
hasMatch = nextToken.kind == SyntaxKind.TYPE_KEYWORD;
break;
case FIELD_DESCRIPTOR_RHS:
return seekInAlternativesPaths(lookahead, currentDepth, matchingRulesCount, FIELD_DESCRIPTOR_RHS);
case FIELD_OR_REST_DESCIPTOR_RHS:
return seekInAlternativesPaths(lookahead, currentDepth, matchingRulesCount,
FIELD_OR_REST_DESCIPTOR_RHS);
case RECORD_BODY_END:
return seekInAlternativesPaths(lookahead, currentDepth, matchingRulesCount, RECORD_BODY_END);
case RECORD_BODY_START:
return seekInAlternativesPaths(lookahead, currentDepth, matchingRulesCount, RECORD_BODY_START);
case TYPE_DESCRIPTOR:
return seekInAlternativesPaths(lookahead, currentDepth, matchingRulesCount, TYPE_DESCRIPTORS);
case RECORD_FIELD:
return seekInAlternativesPaths(lookahead, currentDepth, matchingRulesCount, RECORD_FIELD);
case ARG:
return seekInAlternativesPaths(lookahead, currentDepth, matchingRulesCount, ARG_START);
case NAMED_OR_POSITIONAL_ARG_RHS:
return seekInAlternativesPaths(lookahead, currentDepth, matchingRulesCount,
NAMED_OR_POSITIONAL_ARG_RHS);
case OBJECT_MEMBER:
return seekInAlternativesPaths(lookahead, currentDepth, matchingRulesCount, OBJECT_MEMBER_START);
case OBJECT_FIELD_RHS:
return seekInAlternativesPaths(lookahead, currentDepth, matchingRulesCount, OBJECT_FIELD_RHS);
case OBJECT_METHOD_START:
return seekInAlternativesPaths(lookahead, currentDepth, matchingRulesCount, OBJECT_METHOD_START);
case OBJECT_KEYWORD:
hasMatch = nextToken.kind == SyntaxKind.OBJECT_KEYWORD;
break;
case OBJECT_FUNC_OR_FIELD:
return seekInAlternativesPaths(lookahead, currentDepth, matchingRulesCount, OBJECT_FUNC_OR_FIELD);
case OBJECT_FUNC_OR_FIELD_WITHOUT_VISIBILITY:
return seekInAlternativesPaths(lookahead, currentDepth, matchingRulesCount,
OBJECT_FUNC_OR_FIELD_WITHOUT_VISIBILITY);
case OBJECT_TYPE_DESCRIPTOR_START:
return seekInAlternativesPaths(lookahead, currentDepth, matchingRulesCount,
OBJECT_TYPE_DESCRIPTOR_START);
case OBJECT_TYPE_FIRST_QUALIFIER:
case OBJECT_TYPE_SECOND_QUALIFIER:
if (currentDepth == 0) {
hasMatch = false;
break;
}
hasMatch = nextToken.kind == SyntaxKind.ABSTRACT_KEYWORD ||
nextToken.kind == SyntaxKind.CLIENT_KEYWORD;
break;
case ABSTRACT_KEYWORD:
hasMatch = nextToken.kind == SyntaxKind.ABSTRACT_KEYWORD;
break;
case CLIENT_KEYWORD:
hasMatch = nextToken.kind == SyntaxKind.CLIENT_KEYWORD;
break;
case OPEN_BRACKET:
hasMatch = nextToken.kind == SyntaxKind.OPEN_BRACKET_TOKEN;
break;
case CLOSE_BRACKET:
hasMatch = nextToken.kind == SyntaxKind.CLOSE_BRACKET_TOKEN;
break;
case DOT:
hasMatch = nextToken.kind == SyntaxKind.DOT_TOKEN;
break;
case IF_KEYWORD:
hasMatch = nextToken.kind == SyntaxKind.IF_KEYWORD;
break;
case ELSE_KEYWORD:
hasMatch = nextToken.kind == SyntaxKind.ELSE_KEYWORD;
break;
case ELSE_BLOCK:
return seekInAlternativesPaths(lookahead, currentDepth, matchingRulesCount, ELSE_BLOCK);
case ELSE_BODY:
return seekInAlternativesPaths(lookahead, currentDepth, matchingRulesCount, ELSE_BODY);
case WHILE_KEYWORD:
hasMatch = nextToken.kind == SyntaxKind.WHILE_KEYWORD;
break;
case CHECKING_KEYWORD:
hasMatch = nextToken.kind == SyntaxKind.CHECK_KEYWORD ||
nextToken.kind == SyntaxKind.CHECKPANIC_KEYWORD;
break;
case CALL_STMT_START:
return seekInAlternativesPaths(lookahead, currentDepth, matchingRulesCount, CALL_STATEMENT);
case PANIC_KEYWORD:
hasMatch = nextToken.kind == SyntaxKind.PANIC_KEYWORD;
break;
case AS_KEYWORD:
hasMatch = nextToken.kind == SyntaxKind.AS_KEYWORD;
break;
case BOOLEAN_LITERAL:
hasMatch = nextToken.kind == SyntaxKind.TRUE_KEYWORD || nextToken.kind == SyntaxKind.FALSE_KEYWORD;
break;
case DECIMAL_INTEGER_LITERAL:
case MAJOR_VERSION:
case MINOR_VERSION:
case PATCH_VERSION:
hasMatch = nextToken.kind == SyntaxKind.DECIMAL_INTEGER_LITERAL;
break;
case IMPORT_KEYWORD:
hasMatch = nextToken.kind == SyntaxKind.IMPORT_KEYWORD;
break;
case SLASH:
hasMatch = nextToken.kind == SyntaxKind.SLASH_TOKEN;
break;
case VERSION_KEYWORD:
hasMatch = nextToken.kind == SyntaxKind.VERSION_KEYWORD;
break;
case CONTINUE_KEYWORD:
hasMatch = nextToken.kind == SyntaxKind.CONTINUE_KEYWORD;
break;
case BREAK_KEYWORD:
hasMatch = nextToken.kind == SyntaxKind.BREAK_KEYWORD;
break;
case IMPORT_PREFIX_DECL:
return seekInAlternativesPaths(lookahead, currentDepth, matchingRulesCount, IMPORT_PREFIX_DECL);
case IMPORT_VERSION_DECL:
return seekInAlternativesPaths(lookahead, currentDepth, matchingRulesCount, IMPORT_VERSION);
case IMPORT_DECL_RHS:
return seekInAlternativesPaths(lookahead, currentDepth, matchingRulesCount, IMPORT_DECL_RHS);
case AFTER_IMPORT_MODULE_NAME:
return seekInAlternativesPaths(lookahead, currentDepth, matchingRulesCount,
AFTER_IMPORT_MODULE_NAME);
case MAJOR_MINOR_VERSION_END:
return seekInAlternativesPaths(lookahead, currentDepth, matchingRulesCount,
MAJOR_MINOR_VERSION_END);
case RETURN_KEYWORD:
hasMatch = nextToken.kind == SyntaxKind.RETURN_KEYWORD;
break;
case RETURN_STMT_RHS:
return seekInAlternativesPaths(lookahead, currentDepth, matchingRulesCount, RETURN_RHS);
case ACCESS_EXPRESSION:
return seekInAccessExpression(currentCtx, lookahead, currentDepth, matchingRulesCount);
case BASIC_LITERAL:
hasMatch = isBasicLiteral(nextToken.kind);
break;
case COLON:
hasMatch = nextToken.kind == SyntaxKind.COLON_TOKEN;
break;
case STRING_LITERAL:
hasMatch = nextToken.kind == SyntaxKind.STRING_LITERAL;
break;
case MAPPING_FIELD:
return seekInAlternativesPaths(lookahead, currentDepth, matchingRulesCount, MAPPING_FIELD_START);
case SPECIFIC_FIELD_RHS:
return seekInAlternativesPaths(lookahead, currentDepth, matchingRulesCount, SPECIFIC_FIELD_RHS);
case SERVICE_KEYWORD:
hasMatch = nextToken.kind == SyntaxKind.SERVICE_KEYWORD;
break;
case ON_KEYWORD:
hasMatch = nextToken.kind == SyntaxKind.ON_KEYWORD;
break;
case OPTIONAL_SERVICE_NAME:
return seekInAlternativesPaths(lookahead, currentDepth, matchingRulesCount, OPTIONAL_SERVICE_NAME);
case RESOURCE_DEF:
return seekInAlternativesPaths(lookahead, currentDepth, matchingRulesCount, RESOURCE_DEF_START);
case RESOURCE_KEYWORD:
hasMatch = nextToken.kind == SyntaxKind.RESOURCE_KEYWORD;
break;
case LISTENER_KEYWORD:
hasMatch = nextToken.kind == SyntaxKind.LISTENER_KEYWORD;
break;
case CONST_KEYWORD:
hasMatch = nextToken.kind == SyntaxKind.CONST_KEYWORD;
break;
case FINAL_KEYWORD:
hasMatch = nextToken.kind == SyntaxKind.FINAL_KEYWORD;
break;
case CONST_DECL_RHS:
return seekInAlternativesPaths(lookahead, currentDepth, matchingRulesCount, CONST_DECL_RHS);
case TYPEOF_KEYWORD:
hasMatch = nextToken.kind == SyntaxKind.TYPEOF_KEYWORD;
break;
case UNARY_OPERATOR:
hasMatch = isUnaryOperator(nextToken);
break;
case IS_KEYWORD:
hasMatch = nextToken.kind == SyntaxKind.IS_KEYWORD;
break;
case IS_EXPRESSION:
return seekInIsExpression(currentCtx, lookahead, currentDepth, matchingRulesCount);
case COMP_UNIT:
case FUNC_DEFINITION:
case RETURN_TYPE_DESCRIPTOR:
case EXTERNAL_FUNC_BODY:
case FUNC_BODY_BLOCK:
case ASSIGNMENT_STMT:
case VAR_DECL_STMT:
case REQUIRED_PARAM:
case AFTER_PARAMETER_TYPE:
case DEFAULTABLE_PARAM:
case REST_PARAM:
case MODULE_TYPE_DEFINITION:
case ARG_LIST:
case ASTERISK:
case FUNC_CALL:
case RECORD_TYPE_DESCRIPTOR:
case OBJECT_TYPE_DESCRIPTOR:
case ASSIGNMENT_OR_VAR_DECL_STMT:
case CALL_STMT:
case IF_BLOCK:
case BLOCK_STMT:
case WHILE_BLOCK:
case VERSION_NUMBER:
case IMPORT_DECL:
case IMPORT_SUB_VERSION:
case MAPPING_CONSTRUCTOR:
case PANIC_STMT:
case COMPUTED_FIELD_NAME:
case RETURN_STMT:
case LISTENERS_LIST:
case SERVICE_DECL:
case BREAK_STATEMENT:
case CONTINUE_STATEMENT:
case LISTENER_DECL:
case CONSTANT_DECL:
case NIL_TYPE_DESCRIPTOR:
case OPTIONAL_TYPE_DESCRIPTOR:
default:
skipRule = true;
hasMatch = true;
break;
}
if (!hasMatch) {
Result fixedPathResult = fixAndContinue(currentCtx, lookahead, currentDepth + 1);
return getFinalResult(matchingRulesCount, fixedPathResult);
}
currentCtx = getNextRule(currentCtx, lookahead + 1);
if (!skipRule) {
currentDepth++;
matchingRulesCount++;
lookahead++;
}
}
return new Result(new ArrayDeque<>(), matchingRulesCount, currentCtx);
}

Line under review: return seekInIsExpression(currentCtx, lookahead, currentDepth, matchingRulesCount);

Code after addressing the review:
private Result seekMatch(ParserRuleContext currentCtx, int lookahead, int currentDepth) {
boolean hasMatch;
boolean skipRule;
int matchingRulesCount = 0;
boolean isEntryPoint = true;
while (currentDepth < lookaheadLimit) {
hasMatch = true;
skipRule = false;
STToken nextToken = this.tokenReader.peek(lookahead);
switch (currentCtx) {
case EOF:
hasMatch = nextToken.kind == SyntaxKind.EOF_TOKEN;
break;
case PUBLIC_KEYWORD:
hasMatch = nextToken.kind == SyntaxKind.PUBLIC_KEYWORD;
break;
case PRIVATE_KEYWORD:
hasMatch = nextToken.kind == SyntaxKind.PRIVATE_KEYWORD;
break;
case REMOTE_KEYWORD:
hasMatch = nextToken.kind == SyntaxKind.REMOTE_KEYWORD;
break;
case TOP_LEVEL_NODE:
return seekInAlternativesPaths(lookahead, currentDepth, matchingRulesCount, TOP_LEVEL_NODE);
case TOP_LEVEL_NODE_WITHOUT_MODIFIER:
return seekInAlternativesPaths(lookahead, currentDepth, matchingRulesCount,
TOP_LEVEL_NODE_WITHOUT_MODIFIER);
case TOP_LEVEL_NODE_WITHOUT_METADATA:
return seekInAlternativesPaths(lookahead, currentDepth, matchingRulesCount,
TOP_LEVEL_NODE_WITHOUT_METADATA);
case FUNCTION_KEYWORD:
hasMatch = nextToken.kind == SyntaxKind.FUNCTION_KEYWORD;
break;
case FUNC_NAME:
case VARIABLE_NAME:
case TYPE_NAME:
case FIELD_OR_FUNC_NAME:
case IMPORT_ORG_OR_MODULE_NAME:
case IMPORT_MODULE_NAME:
case IMPORT_PREFIX:
case MAPPING_FIELD_NAME:
case SERVICE_NAME:
case QUALIFIED_IDENTIFIER:
case IDENTIFIER:
hasMatch = nextToken.kind == SyntaxKind.IDENTIFIER_TOKEN;
break;
case OPEN_PARENTHESIS:
hasMatch = nextToken.kind == SyntaxKind.OPEN_PAREN_TOKEN;
break;
case CLOSE_PARENTHESIS:
hasMatch = nextToken.kind == SyntaxKind.CLOSE_PAREN_TOKEN;
break;
case RETURNS_KEYWORD:
hasMatch = nextToken.kind == SyntaxKind.RETURNS_KEYWORD;
if (!hasMatch) {
skipRule = true;
}
break;
case SIMPLE_TYPE_DESCRIPTOR:
case CONST_DECL_TYPE:
hasMatch =
nextToken.kind == SyntaxKind.SIMPLE_TYPE || nextToken.kind == SyntaxKind.SERVICE_KEYWORD ||
nextToken.kind == SyntaxKind.IDENTIFIER_TOKEN;
break;
case FUNC_BODY:
return seekInFuncBodies(lookahead, currentDepth, matchingRulesCount);
case OPEN_BRACE:
hasMatch = nextToken.kind == SyntaxKind.OPEN_BRACE_TOKEN;
break;
case CLOSE_BRACE:
hasMatch = nextToken.kind == SyntaxKind.CLOSE_BRACE_TOKEN;
break;
case ASSIGN_OP:
hasMatch = nextToken.kind == SyntaxKind.EQUAL_TOKEN;
break;
case EXTERNAL_KEYWORD:
hasMatch = nextToken.kind == SyntaxKind.EXTERNAL_KEYWORD;
break;
case SEMICOLON:
hasMatch = nextToken.kind == SyntaxKind.SEMICOLON_TOKEN;
break;
case STATEMENT:
case STATEMENT_WITHOUT_ANNOTS:
if (isEndOfBlock(nextToken)) {
skipRule = true;
break;
}
return seekInStatements(currentCtx, nextToken, lookahead, currentDepth, matchingRulesCount);
case BINARY_OPERATOR:
hasMatch = isBinaryOperator(nextToken);
break;
case EXPRESSION:
return seekInAlternativesPaths(lookahead, currentDepth, matchingRulesCount, EXPRESSIONS);
case VAR_DECL_STMT_RHS:
return seekInAlternativesPaths(lookahead, currentDepth, matchingRulesCount, VAR_DECL_RHS);
case EXPRESSION_RHS:
return seekMatchInExpressionRhs(nextToken, lookahead, currentDepth, matchingRulesCount);
case COMMA:
hasMatch = nextToken.kind == SyntaxKind.COMMA_TOKEN;
break;
case PARAM_LIST:
return seekInAlternativesPaths(lookahead, currentDepth, matchingRulesCount, PARAM_LIST);
case PARAMETER_RHS:
ParserRuleContext parentCtx = getParentContext();
switch (parentCtx) {
case REQUIRED_PARAM:
return seekInAlternativesPaths(lookahead, currentDepth, matchingRulesCount, PARAMETER_RHS);
case DEFAULTABLE_PARAM:
case REST_PARAM:
skipRule = true;
break;
default:
throw new IllegalStateException();
}
break;
case STATEMENT_START_IDENTIFIER:
return seekInAlternativesPaths(lookahead, currentDepth, matchingRulesCount, TYPE_OR_VAR_NAME);
case ASSIGNMENT_OR_VAR_DECL_STMT_RHS:
return seekInAlternativesPaths(lookahead, currentDepth, matchingRulesCount,
ASSIGNMENT_OR_VAR_DECL_SECOND_TOKEN);
case CLOSED_RECORD_BODY_END:
hasMatch = nextToken.kind == SyntaxKind.CLOSE_BRACE_PIPE_TOKEN;
break;
case CLOSED_RECORD_BODY_START:
hasMatch = nextToken.kind == SyntaxKind.OPEN_BRACE_PIPE_TOKEN;
break;
case ELLIPSIS:
hasMatch = nextToken.kind == SyntaxKind.ELLIPSIS_TOKEN;
break;
case QUESTION_MARK:
hasMatch = nextToken.kind == SyntaxKind.QUESTION_MARK_TOKEN;
break;
case RECORD_KEYWORD:
hasMatch = nextToken.kind == SyntaxKind.RECORD_KEYWORD;
break;
case TYPE_KEYWORD:
hasMatch = nextToken.kind == SyntaxKind.TYPE_KEYWORD;
break;
case FIELD_DESCRIPTOR_RHS:
return seekInAlternativesPaths(lookahead, currentDepth, matchingRulesCount, FIELD_DESCRIPTOR_RHS);
case FIELD_OR_REST_DESCIPTOR_RHS:
return seekInAlternativesPaths(lookahead, currentDepth, matchingRulesCount,
FIELD_OR_REST_DESCIPTOR_RHS);
case RECORD_BODY_END:
return seekInAlternativesPaths(lookahead, currentDepth, matchingRulesCount, RECORD_BODY_END);
case RECORD_BODY_START:
return seekInAlternativesPaths(lookahead, currentDepth, matchingRulesCount, RECORD_BODY_START);
case TYPE_DESCRIPTOR:
return seekInAlternativesPaths(lookahead, currentDepth, matchingRulesCount, TYPE_DESCRIPTORS);
case RECORD_FIELD:
return seekInAlternativesPaths(lookahead, currentDepth, matchingRulesCount, RECORD_FIELD);
case RECORD_FIELD_WITHOUT_METADATA:
return seekInAlternativesPaths(lookahead, currentDepth, matchingRulesCount,
RECORD_FIELD_WITHOUT_METADATA);
case ARG:
return seekInAlternativesPaths(lookahead, currentDepth, matchingRulesCount, ARG_START);
case NAMED_OR_POSITIONAL_ARG_RHS:
return seekInAlternativesPaths(lookahead, currentDepth, matchingRulesCount,
NAMED_OR_POSITIONAL_ARG_RHS);
case OBJECT_MEMBER:
return seekInAlternativesPaths(lookahead, currentDepth, matchingRulesCount, OBJECT_MEMBER_START);
case OBJECT_MEMBER_WITHOUT_METADATA:
return seekInAlternativesPaths(lookahead, currentDepth, matchingRulesCount,
OBJECT_MEMBER_WITHOUT_METADATA);
case OBJECT_FIELD_RHS:
return seekInAlternativesPaths(lookahead, currentDepth, matchingRulesCount, OBJECT_FIELD_RHS);
case OBJECT_METHOD_START:
return seekInAlternativesPaths(lookahead, currentDepth, matchingRulesCount, OBJECT_METHOD_START);
case OBJECT_KEYWORD:
hasMatch = nextToken.kind == SyntaxKind.OBJECT_KEYWORD;
break;
case OBJECT_FUNC_OR_FIELD:
return seekInAlternativesPaths(lookahead, currentDepth, matchingRulesCount, OBJECT_FUNC_OR_FIELD);
case OBJECT_FUNC_OR_FIELD_WITHOUT_VISIBILITY:
return seekInAlternativesPaths(lookahead, currentDepth, matchingRulesCount,
OBJECT_FUNC_OR_FIELD_WITHOUT_VISIBILITY);
case OBJECT_TYPE_DESCRIPTOR_START:
return seekInAlternativesPaths(lookahead, currentDepth, matchingRulesCount,
OBJECT_TYPE_DESCRIPTOR_START);
case OBJECT_TYPE_FIRST_QUALIFIER:
case OBJECT_TYPE_SECOND_QUALIFIER:
if (currentDepth == 0) {
hasMatch = false;
break;
}
hasMatch = nextToken.kind == SyntaxKind.ABSTRACT_KEYWORD ||
nextToken.kind == SyntaxKind.CLIENT_KEYWORD;
break;
case ABSTRACT_KEYWORD:
hasMatch = nextToken.kind == SyntaxKind.ABSTRACT_KEYWORD;
break;
case CLIENT_KEYWORD:
hasMatch = nextToken.kind == SyntaxKind.CLIENT_KEYWORD;
break;
case OPEN_BRACKET:
hasMatch = nextToken.kind == SyntaxKind.OPEN_BRACKET_TOKEN;
break;
case CLOSE_BRACKET:
hasMatch = nextToken.kind == SyntaxKind.CLOSE_BRACKET_TOKEN;
break;
case DOT:
hasMatch = nextToken.kind == SyntaxKind.DOT_TOKEN;
break;
case IF_KEYWORD:
hasMatch = nextToken.kind == SyntaxKind.IF_KEYWORD;
break;
case ELSE_KEYWORD:
hasMatch = nextToken.kind == SyntaxKind.ELSE_KEYWORD;
break;
case ELSE_BLOCK:
return seekInAlternativesPaths(lookahead, currentDepth, matchingRulesCount, ELSE_BLOCK);
case ELSE_BODY:
return seekInAlternativesPaths(lookahead, currentDepth, matchingRulesCount, ELSE_BODY);
case WHILE_KEYWORD:
hasMatch = nextToken.kind == SyntaxKind.WHILE_KEYWORD;
break;
case CHECKING_KEYWORD:
hasMatch = nextToken.kind == SyntaxKind.CHECK_KEYWORD ||
nextToken.kind == SyntaxKind.CHECKPANIC_KEYWORD;
break;
case CALL_STMT_START:
return seekInAlternativesPaths(lookahead, currentDepth, matchingRulesCount, CALL_STATEMENT);
case PANIC_KEYWORD:
hasMatch = nextToken.kind == SyntaxKind.PANIC_KEYWORD;
break;
case AS_KEYWORD:
hasMatch = nextToken.kind == SyntaxKind.AS_KEYWORD;
break;
case BOOLEAN_LITERAL:
hasMatch = nextToken.kind == SyntaxKind.TRUE_KEYWORD || nextToken.kind == SyntaxKind.FALSE_KEYWORD;
break;
case DECIMAL_INTEGER_LITERAL:
case MAJOR_VERSION:
case MINOR_VERSION:
case PATCH_VERSION:
hasMatch = nextToken.kind == SyntaxKind.DECIMAL_INTEGER_LITERAL;
break;
case IMPORT_KEYWORD:
hasMatch = nextToken.kind == SyntaxKind.IMPORT_KEYWORD;
break;
case SLASH:
hasMatch = nextToken.kind == SyntaxKind.SLASH_TOKEN;
break;
case VERSION_KEYWORD:
hasMatch = nextToken.kind == SyntaxKind.VERSION_KEYWORD;
break;
case CONTINUE_KEYWORD:
hasMatch = nextToken.kind == SyntaxKind.CONTINUE_KEYWORD;
break;
case BREAK_KEYWORD:
hasMatch = nextToken.kind == SyntaxKind.BREAK_KEYWORD;
break;
case IMPORT_PREFIX_DECL:
return seekInAlternativesPaths(lookahead, currentDepth, matchingRulesCount, IMPORT_PREFIX_DECL);
case IMPORT_VERSION_DECL:
return seekInAlternativesPaths(lookahead, currentDepth, matchingRulesCount, IMPORT_VERSION);
case IMPORT_DECL_RHS:
return seekInAlternativesPaths(lookahead, currentDepth, matchingRulesCount, IMPORT_DECL_RHS);
case AFTER_IMPORT_MODULE_NAME:
return seekInAlternativesPaths(lookahead, currentDepth, matchingRulesCount,
AFTER_IMPORT_MODULE_NAME);
case MAJOR_MINOR_VERSION_END:
return seekInAlternativesPaths(lookahead, currentDepth, matchingRulesCount,
MAJOR_MINOR_VERSION_END);
case RETURN_KEYWORD:
hasMatch = nextToken.kind == SyntaxKind.RETURN_KEYWORD;
break;
case RETURN_STMT_RHS:
return seekInAlternativesPaths(lookahead, currentDepth, matchingRulesCount, RETURN_RHS);
case ACCESS_EXPRESSION:
return seekInAccessExpression(currentCtx, lookahead, currentDepth, matchingRulesCount);
case BASIC_LITERAL:
hasMatch = isBasicLiteral(nextToken.kind);
break;
case COLON:
hasMatch = nextToken.kind == SyntaxKind.COLON_TOKEN;
break;
case STRING_LITERAL:
hasMatch = nextToken.kind == SyntaxKind.STRING_LITERAL;
break;
case MAPPING_FIELD:
return seekInAlternativesPaths(lookahead, currentDepth, matchingRulesCount, MAPPING_FIELD_START);
case SPECIFIC_FIELD_RHS:
return seekInAlternativesPaths(lookahead, currentDepth, matchingRulesCount, SPECIFIC_FIELD_RHS);
case SERVICE_KEYWORD:
hasMatch = nextToken.kind == SyntaxKind.SERVICE_KEYWORD;
break;
case ON_KEYWORD:
hasMatch = nextToken.kind == SyntaxKind.ON_KEYWORD;
break;
case OPTIONAL_SERVICE_NAME:
return seekInAlternativesPaths(lookahead, currentDepth, matchingRulesCount, OPTIONAL_SERVICE_NAME);
case RESOURCE_DEF:
return seekInAlternativesPaths(lookahead, currentDepth, matchingRulesCount, RESOURCE_DEF_START);
case RESOURCE_KEYWORD:
hasMatch = nextToken.kind == SyntaxKind.RESOURCE_KEYWORD;
break;
case LISTENER_KEYWORD:
hasMatch = nextToken.kind == SyntaxKind.LISTENER_KEYWORD;
break;
case CONST_KEYWORD:
hasMatch = nextToken.kind == SyntaxKind.CONST_KEYWORD;
break;
case FINAL_KEYWORD:
hasMatch = nextToken.kind == SyntaxKind.FINAL_KEYWORD;
break;
case CONST_DECL_RHS:
return seekInAlternativesPaths(lookahead, currentDepth, matchingRulesCount, CONST_DECL_RHS);
case TYPEOF_KEYWORD:
hasMatch = nextToken.kind == SyntaxKind.TYPEOF_KEYWORD;
break;
case UNARY_OPERATOR:
hasMatch = isUnaryOperator(nextToken);
break;
case AT:
hasMatch = nextToken.kind == SyntaxKind.AT_TOKEN;
break;
case PARAMETER:
return seekInAlternativesPaths(lookahead, currentDepth, matchingRulesCount, PARAMETER);
case PARAMETER_WITHOUT_ANNOTS:
return seekInAlternativesPaths(lookahead, currentDepth, matchingRulesCount,
PARAMETER_WITHOUT_ANNOTS);
case IS_KEYWORD:
hasMatch = nextToken.kind == SyntaxKind.IS_KEYWORD;
break;
case IS_EXPRESSION:
return seekInIsExpression(currentCtx, lookahead, currentDepth, matchingRulesCount);
case COMP_UNIT:
case FUNC_DEFINITION:
case RETURN_TYPE_DESCRIPTOR:
case EXTERNAL_FUNC_BODY:
case FUNC_BODY_BLOCK:
case ASSIGNMENT_STMT:
case VAR_DECL_STMT:
case REQUIRED_PARAM:
case AFTER_PARAMETER_TYPE:
case DEFAULTABLE_PARAM:
case REST_PARAM:
case MODULE_TYPE_DEFINITION:
case ARG_LIST:
case ASTERISK:
case FUNC_CALL:
case RECORD_TYPE_DESCRIPTOR:
case OBJECT_TYPE_DESCRIPTOR:
case ASSIGNMENT_OR_VAR_DECL_STMT:
case CALL_STMT:
case IF_BLOCK:
case BLOCK_STMT:
case WHILE_BLOCK:
case VERSION_NUMBER:
case IMPORT_DECL:
case IMPORT_SUB_VERSION:
case MAPPING_CONSTRUCTOR:
case PANIC_STMT:
case COMPUTED_FIELD_NAME:
case RETURN_STMT:
case LISTENERS_LIST:
case SERVICE_DECL:
case BREAK_STATEMENT:
case CONTINUE_STATEMENT:
case LISTENER_DECL:
case CONSTANT_DECL:
case NIL_TYPE_DESCRIPTOR:
case OPTIONAL_TYPE_DESCRIPTOR:
case ANNOTATIONS:
case DOC_STRING:
case VARIABLE_REF:
case TYPE_REFERENCE:
case ANNOT_REFERENCE:
default:
skipRule = true;
hasMatch = true;
break;
}
if (!hasMatch) {
Result fixedPathResult = fixAndContinue(currentCtx, lookahead, currentDepth + 1);
if (isEntryPoint) {
fixedPathResult.solution = fixedPathResult.fixes.peek();
} else {
fixedPathResult.solution = new Solution(Action.KEEP, currentCtx, getExpectedTokenKind(currentCtx),
currentCtx.toString());
}
return getFinalResult(matchingRulesCount, fixedPathResult);
}
currentCtx = getNextRule(currentCtx, lookahead + 1);
if (!skipRule) {
currentDepth++;
matchingRulesCount++;
lookahead++;
isEntryPoint = false;
}
}
Result result = new Result(new ArrayDeque<>(), matchingRulesCount, currentCtx);
result.solution =
new Solution(Action.KEEP, currentCtx, getExpectedTokenKind(currentCtx), currentCtx.toString());
return result;
}