Enum rslua_march1917::ast::UnOp
source · pub enum UnOp {
Minus,
BNot,
Not,
Len,
None,
}Variants§
Implementations§
source§impl UnOp
impl UnOp
sourcepub fn from_token(token: TokenType) -> UnOp
pub fn from_token(token: TokenType) -> UnOp
sourcepub fn priority(self) -> u8
pub fn priority(self) -> u8
Examples found in repository?
src/parser.rs (line 436)
431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454
fn subexpr(&mut self, limit: u8) -> ParseResult<Expr> {
let mut left;
let unop = self.get_unop();
if unop != UnOp::None {
self.next_and_skip_comment();
let expr = Box::new(self.subexpr(unop.priority())?);
left = Expr::UnExpr(UnExpr { op: unop, expr });
} else {
left = self.simpleexpr()?;
}
let mut binop = self.get_binop();
while binop != BinOp::None && binop.priority().left > limit {
self.skip_comment();
self.next_and_skip_comment();
let right = self.subexpr(binop.priority().right)?;
left = Expr::BinExpr(BinExpr {
left: Box::new(left),
right: Box::new(right),
op: binop,
});
binop = self.get_binop();
}
Ok(left)
}