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