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

Method parse_module

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

188 ///
189 /// This is to be used for [`Mode::Module`] and [`Mode::Ipython`].
190 fn parse_module(&mut self) -> ModModule {
191 let body = self.parse_list_into_thin_vec(RecoveryContextKind::ModuleStatements, |p| {
192 p.parse_statement()
193 });
194
195 self.bump(TokenKind::EndOfFile);
196
197 ModModule {
198 body,
199 range: TextRange::new(self.start_offset, self.current_token_range().end()),
200 node_index: AtomicNodeIndex::NONE,
201 }
202 }
203
204 fn finish(self, syntax: Mod) -> Parsed<Mod> {
205 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