y_lang/ast/
postfix_op.rs

1use pest::iterators::Pair;
2
3use super::{Call, Indexing, Rule};
4
5#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
6pub enum PostfixOp<T> {
7    Call(Call<T>),
8    Indexing(Indexing<T>),
9}
10
11impl PostfixOp<()> {
12    pub fn from_pair(pair: Pair<Rule>, file: &str) -> PostfixOp<()> {
13        match pair.as_rule() {
14            Rule::call => PostfixOp::Call(Call::from_pair(pair, file)),
15            Rule::indexing => PostfixOp::Indexing(Indexing::from_pair(pair, file)),
16            rule => unreachable!("Unexpected rule {:?} while parsing postfix op", rule),
17        }
18    }
19}