MCPcopy Create free account
hub / github.com/Glyphack/enderpy / parse_power_expression

Method parse_power_expression

parser/src/parser/parser.rs:2214–2237  ·  view source on GitHub ↗

https://docs.python.org/3/reference/expressions.html#the-power-operator

(&mut self)

Source from the content-addressed store, hash-verified

2212
2213 // https://docs.python.org/3/reference/expressions.html#the-power-operator
2214 fn parse_power_expression(&mut self) -> Result<Expression, ParsingError> {
2215 let node = self.start_node();
2216 let base = if self.at(Kind::Await) {
2217 self.bump(Kind::Await);
2218 let value = self.parse_primary(None)?;
2219 Ok(Expression::Await(Box::new(Await {
2220 node: self.finish_node(node),
2221 value,
2222 })))
2223 } else {
2224 self.parse_primary(None)
2225 };
2226 if self.eat(Kind::Pow) {
2227 let exponent = self.parse_unary_arithmetic_operation()?;
2228 return Ok(Expression::BinOp(Box::new(BinOp {
2229 node: self.finish_node(node),
2230 op: BinaryOperator::Pow,
2231 left: base?,
2232 right: exponent,
2233 })));
2234 }
2235
2236 base
2237 }
2238
2239 // https://docs.python.org/3/reference/expressions.html#primaries
2240 // primaries can be chained together, when they are chained the base is the

Callers 1

Calls 9

AwaitClass · 0.85
BinOpClass · 0.85
start_nodeMethod · 0.80
atMethod · 0.80
bumpMethod · 0.80
parse_primaryMethod · 0.80
finish_nodeMethod · 0.80
eatMethod · 0.80

Tested by

no test coverage detected