pub fn parse_expression_range(
source: &str,
range: TextRange,
) -> Result<Parsed<ModExpression>, ParseError>Expand description
Parses a Python expression for the given range in the source.
This function allows to specify the range of the expression in the source code, other than
that, it behaves exactly like parse_expression.
ยงExample
Parsing one of the numeric literal which is part of an addition expression:
use ruff_python_parser::parse_expression_range;
let parsed = parse_expression_range("11 + 22 + 33", TextRange::new(TextSize::new(5), TextSize::new(7)));
assert!(parsed.is_ok());