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

Method parse_block

crates/ruff_python_parser/src/parser/statement.rs:3139–3160  ·  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

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

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