MCPcopy Create free account
hub / github.com/dylan-sutton-chavez/edge-python / parse_unary

Method parse_unary

compiler/src/modules/parser/expr.rs:142–167  ·  view source on GitHub ↗
(&mut self)

Source from the content-addressed store, hash-verified

140 }
141
142 pub(super) fn parse_unary(&mut self) {
143 match self.peek() {
144 Some(TokenType::Minus) => {
145 self.advance();
146 self.expr_bp(21);
147 self.chunk.emit(OpCode::Minus, 0);
148 }
149 Some(TokenType::Plus) => {
150 // Unary plus calls `__pos__` and coerces bool to int.
151 self.advance();
152 self.expr_bp(21);
153 self.chunk.emit(OpCode::Pos, 0);
154 }
155 Some(TokenType::Tilde) => {
156 self.advance();
157 self.expr_bp(21);
158 self.chunk.emit(OpCode::BitNot, 0);
159 }
160 Some(TokenType::Await) => {
161 self.advance();
162 self.expr_bp(21);
163 self.chunk.emit(OpCode::Await, 0);
164 }
165 _ => self.parse_atom()
166 }
167 }
168
169 /* Atoms: literals, names, numbers, strings, f-strings, containers. */
170 pub(super) fn parse_atom(&mut self) {

Callers 1

expr_bpMethod · 0.80

Calls 5

advanceMethod · 0.80
expr_bpMethod · 0.80
emitMethod · 0.80
parse_atomMethod · 0.80
peekMethod · 0.45

Tested by

no test coverage detected