Remove parse_program_tokens

This commit is contained in:
Charlie Marsh 2022-10-17 11:59:22 -04:00
parent 8adc74fe26
commit 02953b9fe6

View file

@ -5,11 +5,10 @@
//! parse a whole program, a single statement, or a single
//! expression.
use std::iter;
use crate::lexer::LexResult;
pub use crate::mode::Mode;
use crate::{ast, error::ParseError, lexer, python};
use std::iter;
/*
* Parse python code.
@ -25,17 +24,6 @@ pub fn parse_program(source: &str, source_path: &str) -> Result<ast::Suite, Pars
})
}
/// Parse the token stream for a full python program.
pub fn parse_program_tokens(
lxr: impl IntoIterator<Item=LexResult>,
source_path: &str,
) -> Result<ast::Suite, ParseError> {
parse_tokens(lxr, Mode::Module, source_path).map(|top| match top {
ast::Mod::Module { body, .. } => body,
_ => unreachable!(),
})
}
/// Parses a python expression
///
/// # Example
@ -95,7 +83,7 @@ pub fn parse(source: &str, mode: Mode, source_path: &str) -> Result<ast::Mod, Pa
// Parse a given token iterator.
pub fn parse_tokens(
lxr: impl IntoIterator<Item=LexResult>,
lxr: impl IntoIterator<Item = LexResult>,
mode: Mode,
source_path: &str,
) -> Result<ast::Mod, ParseError> {