MCPcopy Create free account
hub / github.com/LaBatata101/sith-language-server / parse_expression

Function parse_expression

crates/sith_python_parser/src/lib.rs:130–136  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

128/// assert!(expr.is_ok());
129/// ```
130pub 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///

Calls 3

into_resultMethod · 0.80
try_into_expressionMethod · 0.80
parseMethod · 0.45