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

Method parse_module

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

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