ErrorReporter errorReporter,
Logger logger) throws IOException {
Context cx = Context.enter();
cx.setErrorReporter(errorReporter);
cx.setLanguageVersion(Context.VERSION_1_5);
CompilerEnvirons compilerEnv = new CompilerEnvirons();
compilerEnv.initFromContext(cx);
compilerEnv.setRecordingComments(true);
compilerEnv.setRecordingLocalJsDocComments(true);
// ES5 specifically allows trailing commas
compilerEnv.setWarnTrailingComma(
config.languageMode == LanguageMode.ECMASCRIPT3);
if (config.isIdeMode || config.languageMode != LanguageMode.ECMASCRIPT3) {
// Do our own identifier check for ECMASCRIPT 5
compilerEnv.setReservedKeywordAsIdentifier(true);
compilerEnv.setAllowKeywordAsObjectPropertyName(true);
}
if (config.isIdeMode) {
compilerEnv.setAllowMemberExprAsFunctionName(true);
}
compilerEnv.setIdeMode(config.isIdeMode);
Parser p = new Parser(compilerEnv, errorReporter);
AstRoot astRoot = null;
try {
astRoot = p.parse(sourceString, sourceFile.getName(), 1);