protospec-build 0.3.0

One binary format language to rule them all, One binary format language to find them, One binary format language to bring them all and in the darkness bind them.
Documentation
use super::*;

pub fn parse_shift_expression(t: &mut TokenIter) -> ParseResult<Expression> {
    let mut expr = parse_add_expression(t)?;
    while let Some(SpannedToken { token: op, .. }) =
        t.eat_any(&[Token::Shl, Token::Shr, Token::ShrSigned])
    {
        let right = parse_add_expression(t)?;
        expr = Expression::Binary(BinaryExpression {
            span: *expr.span() + *right.span(),
            op: match op {
                Token::Shl => BinaryOp::Shl,
                Token::Shr => BinaryOp::Shr,
                Token::ShrSigned => BinaryOp::ShrSigned,
                _ => unimplemented!(),
            },
            left: Box::new(expr),
            right: Box::new(right),
        })
    }
    Ok(expr)
}