Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
try {
// The {classModifier} is a super grammar of the "interfaceModifier"
// So we must parse all the "{classModifier}" before we can distinguish
// between the alternatives.
$.MANY({
GATE: () =>
(tokenMatcher($.LA(1).tokenType, t.At) &&
tokenMatcher($.LA(2).tokenType, t.Interface)) === false,
DEF: () => {
$.SUBRULE($.classModifier);
}
});
} catch (e) {
if (isRecognitionException(e)) {
// TODO: add original syntax error?
throw "Cannot Identify if the is a or an ";
} else {
throw e;
}
}
if (isEmptyTypeDeclaration) {
return false;
}
const nextTokenType = this.LA(1).tokenType;
return (
tokenMatcher(nextTokenType, t.Class) ||
tokenMatcher(nextTokenType, t.Enum)
);
$.SUBRULE2($.importDeclaration);
});
$.MANY2({
// To avoid ambiguity with @interface ("AnnotationTypeDeclaration" vs "Annotaion")
GATE: () =>
(tokenMatcher($.LA(1).tokenType, t.At) &&
tokenMatcher($.LA(2).tokenType, t.Interface)) === false,
DEF: () => {
$.SUBRULE($.annotation);
}
});
} catch (e) {
// This means we had a syntax error in the imports or annotations
// So we can't keep parsing deep enough to make the decision
if (isRecognitionException(e)) {
// TODO: add original syntax error?
throw "Cannot Identify if the source code is an OrdinaryCompilationUnit or ModularCompilationUnit";
} else {
throw e;
}
}
const nextTokenType = this.LA(1).tokenType;
return (
tokenMatcher(nextTokenType, t.Open) ||
tokenMatcher(nextTokenType, t.Module)
);
});
}
}
try {
// The {classModifier} is a super grammar of the "interfaceModifier"
// So we must parse all the "{classModifier}" before we can distinguish
// between the alternatives.
$.MANY({
GATE: () =>
($.LA(1).tokenType === t.At && $.LA(2).tokenType === t.Interface) ===
false,
DEF: () => {
$.SUBRULE($.classModifier);
}
});
} catch (e) {
if (isRecognitionException(e)) {
// TODO: add original syntax error?
throw "Cannot Identify if the is a or an ";
} else {
throw e;
}
}
const nextTokenType = this.LA(1).tokenType;
return nextTokenType === t.Class || nextTokenType === t.Enum;
});
return this.ACTION(() => {
this.isBackTrackingStack.push(1);
// TODO: "saveRecogState" does not handle the occurrence stack
const orgState = this.saveRecogState();
try {
// hack to enable outputting none CST values from grammar rules.
this.outputCst = false;
return production.call(this);
} catch (e) {
if (isRecognitionException(e)) {
return errValue;
}
throw e;
} finally {
this.outputCst = true;
this.reloadRecogState(orgState);
this.isBackTrackingStack.pop();
}
});
}