void (IElementType root, SyntaxTreeBuilder builder) { final SyntaxTreeBuilder.Marker rootMarker = builder.mark(); ParsingContext context = createParsingContext(builder, myLanguageLevel); StatementParsing statementParser = context.getStatementParser(); builder.setTokenTypeRemapper(statementParser); // must be done before touching the caching lexer with eof() call. boolean lastAfterSemicolon = false; while (!builder.eof()) { context.pushScope(context.emptyParsingScope()); if (lastAfterSemicolon) { statementParser.parseSimpleStatement(); } else { statementParser.parseStatement(); } lastAfterSemicolon = context.getScope().isAfterSemicolon(); context.popScope(); } rootMarker.done(root); }