MCPcopy Create free account
hub / github.com/astral-sh/ruff / parse_block

Method parse_block

crates/ruff_python_parser/src/parser/statement.rs:3133–3154  ·  view source on GitHub ↗

Parses a block of statements. # Panics If the parser isn't positioned at an `Indent` token.

(&mut self)

Source from the content-addressed store, hash-verified

3131 ///
3132 /// If the parser isn't positioned at an `Indent` token.
3133 fn parse_block(&mut self) -> Suite {
3134 self.bump(TokenKind::Indent);
3135
3136 let statements = if let Some(statements) = self.with_recursion(|parser| {
3137 let snapshot = parser.stmt_scratch.snapshot();
3138 parser.parse_list(RecoveryContextKind::BlockStatements, |parser| {
3139 let statement = parser.parse_statement();
3140 parser.stmt_scratch.push(statement);
3141 });
3142
3143 parser.stmt_scratch.take_thin_vec(snapshot)
3144 }) {
3145 statements
3146 } else {
3147 self.report_recursion_limit_exceeded(self.current_token_range());
3148 Suite::new()
3149 };
3150
3151 self.expect(TokenKind::Dedent);
3152
3153 statements
3154 }
3155
3156 /// Parses a single parameter for the given function kind.
3157 ///

Callers 1

parse_bodyMethod · 0.80

Calls 10

with_recursionMethod · 0.80
parse_listMethod · 0.80
parse_statementMethod · 0.80
take_thin_vecMethod · 0.80
current_token_rangeMethod · 0.80
expectMethod · 0.80
bumpMethod · 0.45
snapshotMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected