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

Method parse_block

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

3122 ///
3123 /// If the parser isn't positioned at an `Indent` token.
3124 fn parse_block(&mut self) -> Suite {
3125 self.bump(TokenKind::Indent);
3126
3127 let statements = if let Some(statements) = self.with_recursion(|parser| {
3128 parser.parse_list_into_thin_vec(
3129 RecoveryContextKind::BlockStatements,
3130 Parser::parse_statement,
3131 )
3132 }) {
3133 statements
3134 } else {
3135 self.report_recursion_limit_exceeded(self.current_token_range());
3136 Suite::new()
3137 };
3138
3139 self.expect(TokenKind::Dedent);
3140
3141 statements
3142 }
3143
3144 /// Parses a single parameter for the given function kind.
3145 ///

Callers 1

parse_bodyMethod · 0.80

Calls 6

with_recursionMethod · 0.80
current_token_rangeMethod · 0.80
expectMethod · 0.80
bumpMethod · 0.45

Tested by

no test coverage detected