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

Method parse_module

crates/ruff_python_parser/src/parser/mod.rs:238–250  ·  view source on GitHub ↗

Parses a Python module. This is to be used for [`Mode::Module`] and [`Mode::Ipython`].

(&mut self)

Source from the content-addressed store, hash-verified

236 ///
237 /// This is to be used for [`Mode::Module`] and [`Mode::Ipython`].
238 fn parse_module(&mut self) -> ModModule {
239 let body = self.parse_list_into_thin_vec(RecoveryContextKind::ModuleStatements, |p| {
240 p.parse_statement()
241 });
242
243 self.bump(TokenKind::EndOfFile);
244
245 ModModule {
246 body,
247 range: TextRange::new(self.start_offset, self.current_token_range().end()),
248 node_index: AtomicNodeIndex::NONE,
249 }
250 }
251
252 fn finish(self, syntax: Mod) -> Parsed<Mod> {
253 assert_eq!(

Callers 1

parseMethod · 0.80

Calls 5

parse_statementMethod · 0.80
current_token_rangeMethod · 0.80
bumpMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected