mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-22 01:52:50 +00:00
Re-integrate RustPython parser repository (#4359)
Co-authored-by: Micha Reiser <micha@reiser.io>
This commit is contained in:
parent
865205d992
commit
be6e00ef6e
270 changed files with 3061 additions and 3361 deletions
|
@ -1,10 +1,8 @@
|
|||
use rustpython_parser as parser;
|
||||
use rustpython_parser::ast::{Mod, Suite};
|
||||
use rustpython_parser::ast::{Mod, ModModule, Suite};
|
||||
use rustpython_parser::lexer::LexResult;
|
||||
use rustpython_parser::{lexer, Mode, ParseError};
|
||||
|
||||
pub mod vendor;
|
||||
|
||||
/// Collect tokens up to and including the first error.
|
||||
pub fn tokenize(contents: &str) -> Vec<LexResult> {
|
||||
let mut tokens: Vec<LexResult> = vec![];
|
||||
|
@ -24,7 +22,7 @@ pub fn parse_program_tokens(
|
|||
source_path: &str,
|
||||
) -> anyhow::Result<Suite, ParseError> {
|
||||
parser::parse_tokens(lxr, Mode::Module, source_path).map(|top| match top {
|
||||
Mod::Module { body, .. } => body,
|
||||
Mod::Module(ModModule { body, .. }) => body,
|
||||
_ => unreachable!(),
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue