1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
use crate::ast::{Condition, Else, ExprBlock, If};
use crate::error::ParseError;
use crate::parser::Parser;
use crate::traits::Parse;
use runestick::unit::Span;
#[derive(Debug, Clone)]
pub struct ExprElseIf {
pub else_: Else,
pub if_: If,
pub condition: Condition,
pub block: Box<ExprBlock>,
}
impl ExprElseIf {
pub fn span(&self) -> Span {
self.else_.span().join(self.block.span())
}
}
impl Parse for ExprElseIf {
fn parse(parser: &mut Parser) -> Result<Self, ParseError> {
Ok(Self {
else_: parser.parse()?,
if_: parser.parse()?,
condition: parser.parse()?,
block: Box::new(parser.parse()?),
})
}
}