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

Method parse_module

crates/ruff_python_parser/src/parser/mod.rs:248–260  ·  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

246 ///
247 /// This is to be used for [`Mode::Module`] and [`Mode::Ipython`].
248 fn parse_module(&mut self) -> ModModule {
249 let body = self.parse_list_into_thin_vec(RecoveryContextKind::ModuleStatements, |p| {
250 p.parse_statement()
251 });
252
253 self.bump(TokenKind::EndOfFile);
254
255 ModModule {
256 body,
257 range: TextRange::new(self.start_offset, self.current_token_range().end()),
258 node_index: AtomicNodeIndex::NONE,
259 }
260 }
261
262 fn finish(self, syntax: Mod) -> Parsed<Mod> {
263 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