y_lang/ast/
postfix_expr.rs

1use pest::iterators::Pair;
2
3use super::{Expression, Position, PostfixOp, Rule};
4
5#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
6pub struct PostfixExpr<T> {
7    pub op: PostfixOp<T>,
8    pub lhs: Box<Expression<T>>,
9    pub position: Position,
10    pub info: T,
11}
12
13impl PostfixExpr<()> {
14    pub fn from_lhs_op(lhs: Expression<()>, op_pair: Pair<Rule>, file: &str) -> PostfixExpr<()> {
15        let (line, col) = op_pair.line_col();
16
17        let op = PostfixOp::from_pair(op_pair, file);
18
19        PostfixExpr {
20            op,
21            lhs: Box::new(lhs),
22            position: (file.to_owned(), line, col),
23            info: (),
24        }
25    }
26}