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

Method parse_shift_expr

parser/src/parser/parser.rs:2147–2166  ·  view source on GitHub ↗

https://docs.python.org/3/reference/expressions.html#shifting-operations

(&mut self)

Source from the content-addressed store, hash-verified

2145
2146 // https://docs.python.org/3/reference/expressions.html#shifting-operations
2147 fn parse_shift_expr(&mut self) -> Result<Expression, ParsingError> {
2148 let node = self.start_node();
2149 let mut arith_expr = self.parse_binary_arithmetic_operation(0)?;
2150 if self.at(Kind::LeftShift) || self.at(Kind::RightShift) {
2151 let op = if self.eat(Kind::LeftShift) {
2152 BinaryOperator::LShift
2153 } else {
2154 self.bump(Kind::RightShift);
2155 BinaryOperator::RShift
2156 };
2157 let lhs = self.parse_binary_arithmetic_operation(0)?;
2158 arith_expr = Expression::BinOp(Box::new(BinOp {
2159 node: self.finish_node(node),
2160 op,
2161 left: arith_expr,
2162 right: lhs,
2163 }));
2164 }
2165 Ok(arith_expr)
2166 }
2167
2168 // https://docs.python.org/3/reference/expressions.html#binary-arithmetic-operations
2169 //

Callers 1

parse_and_exprMethod · 0.80

Calls 7

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

Tested by

no test coverage detected