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 sith_python_parser::parse_expression; let expr = parse_expression("1 + 2"); assert!(expr.is_ok()); ```
(source: &str)
| 128 | /// assert!(expr.is_ok()); |
| 129 | /// ``` |
| 130 | pub fn parse_expression(source: &str) -> Result<Parsed<ModExpression>, ParseError> { |
| 131 | Parser::new(source, Mode::Expression) |
| 132 | .parse() |
| 133 | .try_into_expression() |
| 134 | .unwrap() |
| 135 | .into_result() |
| 136 | } |
| 137 | |
| 138 | /// Parses a Python expression for the given range in the source. |
| 139 | /// |