Function rustpython_vm::compiler::parser::parse_expression
source · pub fn parse_expression(
source: &str,
path: &str
) -> Result<Expr<TextRange>, BaseError<ParseErrorType>>
👎Deprecated: Use ast::Expr::parse from rustpython_parser::Parse trait.
Expand description
Parses a single Python expression.
This convenience function can be used to parse a single expression without having to specify the Mode or the location.
Example
For example, parsing a single expression denoting the addition of two numbers:
use rustpython_parser as parser;
let expr = parser::parse_expression("1 + 2", "<embedded>");
assert!(expr.is_ok());