def parse_unary(self): token_type = self.stream.current.type lineno = self.stream.current.lineno if token_type == 'sub': next(self.stream) node = self.parse_unary() return nodes.Neg(node, lineno=lineno) if token_type == 'add': next(self.stream) node = self.parse_unary() return nodes.Pos(node, lineno=lineno) return self.parse_primary()
def parse_unary(self, with_postfix=True): token_type = self.stream.current.type lineno = self.stream.current.lineno if token_type == 'sub': next(self.stream) node = nodes.Neg(self.parse_unary(False), lineno=lineno) elif token_type == 'add': next(self.stream) node = nodes.Pos(self.parse_unary(False), lineno=lineno) else: node = self.parse_primary() if with_postfix: node = self.parse_postfix(node) return node
def parse_unary(self, with_filter=True): token_type = self.stream.current.type lineno = self.stream.current.lineno if token_type == "sub": next(self.stream) node = nodes.Neg(self.parse_unary(False), lineno=lineno) elif token_type == "add": next(self.stream) node = nodes.Pos(self.parse_unary(False), lineno=lineno) else: node = self.parse_primary() node = self.parse_postfix(node) if with_filter: node = self.parse_filter_expr(node) return node
def parse_unary(self): token_type = self.stream.current.type lineno = self.stream.current.lineno if token_type is 'name' and self.stream.current.value == 'not': self.stream.next() node = self.parse_unary() return nodes.Not(node, lineno=lineno) if token_type is 'sub': self.stream.next() node = self.parse_unary() return nodes.Neg(node, lineno=lineno) if token_type is 'add': self.stream.next() node = self.parse_unary() return nodes.Pos(node, lineno=lineno) return self.parse_primary()