y_lang/ast/
prefix_expr.rs

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