void (boolean checkLanguageLevel) { SyntaxTreeBuilder builder = myContext.getBuilder(); final IElementType firstToken = builder.getTokenType(); if (firstToken == null) { return; } if (firstToken == PyTokenTypes.PRINT_KEYWORD && hasPrintStatement()) { parsePrintStatement(builder); return; } if (firstToken == PyTokenTypes.ASSERT_KEYWORD) { parseAssertStatement(); return; } if (firstToken == PyTokenTypes.BREAK_KEYWORD) { parseKeywordStatement(builder, PyElementTypes.BREAK_STATEMENT); return; } if (firstToken == PyTokenTypes.CONTINUE_KEYWORD) { parseKeywordStatement(builder, PyElementTypes.CONTINUE_STATEMENT); return; } if (firstToken == PyTokenTypes.DEL_KEYWORD) { parseDelStatement(); return; } if (firstToken == PyTokenTypes.EXEC_KEYWORD) { parseExecStatement(); return; } if (firstToken == PyTokenTypes.GLOBAL_KEYWORD) { parseNameDefiningStatement(PyElementTypes.GLOBAL_STATEMENT); return; } if (firstToken == PyTokenTypes.NONLOCAL_KEYWORD) { parseNameDefiningStatement(PyElementTypes.NONLOCAL_STATEMENT); return; } if (firstToken == PyTokenTypes.IMPORT_KEYWORD) { parseImportStatement(PyElementTypes.IMPORT_STATEMENT, PyElementTypes.IMPORT_ELEMENT); return; } if (firstToken == PyTokenTypes.FROM_KEYWORD) { parseFromImportStatement(); return; } if (firstToken == PyTokenTypes.PASS_KEYWORD) { parseKeywordStatement(builder, PyElementTypes.PASS_STATEMENT); return; } if (firstToken == PyTokenTypes.RETURN_KEYWORD) { parseReturnStatement(builder); return; } if (firstToken == PyTokenTypes.RAISE_KEYWORD) { parseRaiseStatement(); return; } SyntaxTreeBuilder.Marker exprStatement = builder.mark(); if (builder.getTokenType() == PyTokenTypes.YIELD_KEYWORD) { getExpressionParser().parseYieldOrTupleExpression(false); checkEndOfStatement(); exprStatement.done(PyElementTypes.EXPRESSION_STATEMENT); return; } else if (getExpressionParser().parseExpressionOptional()) { IElementType statementType = PyElementTypes.EXPRESSION_STATEMENT; if (PyTokenTypes.AUG_ASSIGN_OPERATIONS.contains(builder.getTokenType())) { statementType = PyElementTypes.AUG_ASSIGNMENT_STATEMENT; builder.advanceLexer(); if (!getExpressionParser().parseYieldOrTupleExpression(false)) { builder.error(PyParsingBundle.message("PARSE.expected.expression")); } } else if (atToken(PyTokenTypes.EQ) || (atToken(PyTokenTypes.COLON) && (!checkLanguageLevel || myContext.getLanguageLevel().isPy3K()))) { exprStatement.rollbackTo(); exprStatement = builder.mark(); getExpressionParser().parseExpression(false, true); LOG.assertTrue(builder.getTokenType() == PyTokenTypes.EQ || builder.getTokenType() == PyTokenTypes.COLON, builder.getTokenType()); if (builder.getTokenType() == PyTokenTypes.COLON) { statementType = PyElementTypes.TYPE_DECLARATION_STATEMENT; getFunctionParser().parseParameterAnnotation(); } if (builder.getTokenType() == PyTokenTypes.EQ) { statementType = PyElementTypes.ASSIGNMENT_STATEMENT; builder.advanceLexer(); while (true) { SyntaxTreeBuilder.Marker maybeExprMarker = builder.mark(); final boolean isYieldExpr = builder.getTokenType() == PyTokenTypes.YIELD_KEYWORD; if (!getExpressionParser().parseYieldOrTupleExpression(false)) { maybeExprMarker.drop(); builder.error(PyParsingBundle.message("PARSE.expected.expression")); break; } if (builder.getTokenType() == PyTokenTypes.EQ) { if (isYieldExpr) { maybeExprMarker.drop(); builder.error(PyParsingBundle.message("cannot.assign.to.yield.expression")); } else { maybeExprMarker.rollbackTo(); getExpressionParser().parseExpression(false, true); LOG.assertTrue(builder.getTokenType() == PyTokenTypes.EQ, builder.getTokenType()); } builder.advanceLexer(); } else { maybeExprMarker.drop(); break; } } } } checkEndOfStatement(); exprStatement.done(statementType); return; } else { exprStatement.drop(); } builder.advanceLexer(); reportParseStatementError(builder, firstToken); }