Function rustpython_parser::parse_program
source · pub fn parse_program(
source: &str,
source_path: &str,
) -> Result<Suite, ParseError>
👎Deprecated: Use ast::Suite::parse from rustpython_parser::Parse trait.
Expand description
Parse a full Python program usually consisting of multiple lines.
This is a convenience function that can be used to parse a full Python program without having to
specify the Mode
or the location. It is probably what you want to use most of the time.
§Example
For example, parsing a simple function definition and a call to that function:
use rustpython_parser as parser;
let source = r#"
def foo():
return 42
print(foo())
"#;
let program = parser::parse_program(source, "<embedded>");
assert!(program.is_ok());