y_lang/ast/
call.rs

1use pest::iterators::Pair;
2
3use super::{Expression, Position, Rule};
4
5#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
6pub struct Call<T> {
7    pub params: Vec<Expression<T>>,
8    pub position: Position,
9    pub info: T,
10}
11
12impl Call<()> {
13    pub fn from_pair(pair: Pair<Rule>, file: &str) -> Call<()> {
14        assert_eq!(pair.as_rule(), Rule::call);
15
16        let (line, col) = pair.line_col();
17
18        let inner = pair.into_inner();
19
20        let mut params = vec![];
21
22        for param in inner {
23            params.push(Expression::from_pair(param, file));
24        }
25
26        Call {
27            params,
28            position: (file.to_owned(), line, col),
29            info: (),
30        }
31    }
32}