y_lang/ast/
ident.rs

1use pest::iterators::Pair;
2
3use super::{Position, Rule};
4
5#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
6pub struct Ident<T> {
7    pub value: String,
8    pub position: Position,
9    pub info: T,
10}
11
12impl Ident<()> {
13    pub fn from_pair(pair: Pair<Rule>, file: &str) -> Ident<()> {
14        let (line, col) = pair.line_col();
15        Ident {
16            value: pair.as_str().to_owned(),
17            position: (file.to_owned(), line, col),
18            info: (),
19        }
20    }
21}