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

Method parse_module

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

215 ///
216 /// This is to be used for [`Mode::Module`] and [`Mode::Ipython`].
217 fn parse_module(&mut self) -> ModModule {
218 let body = self.parse_list_into_thin_vec(RecoveryContextKind::ModuleStatements, |p| {
219 p.parse_statement()
220 });
221
222 self.bump(TokenKind::EndOfFile);
223
224 ModModule {
225 body,
226 range: TextRange::new(self.start_offset, self.current_token_range().end()),
227 node_index: AtomicNodeIndex::NONE,
228 }
229 }
230
231 fn finish(self, syntax: Mod) -> Parsed<Mod> {
232 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