y_lang/ast/
boolean.rs

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